Bug 64605

Summary: XWPFRun font size support float
Product: POI Reporter: 80101277
Component: XWPFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description 80101277 2020-07-16 09:41:23 UTC
XWPFRun interface define:
public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
    public void setFontSize(int size) {

my source code:

float fontSize = 10.5;
XWPFRun run = para.createRun();
run.setFontSize((int) fontSize);

i find other library support float, and poi truncate the float value to int(10.5 to 10), the text seems ugly.

can fix the problem?
Comment 1 PJ Fanning 2020-07-16 10:07:16 UTC
The number that is added the XML in the xlsx file is twice the value provided in our APIs. This XML number has to be an integer, so the POI API should really only accept whole numbers and numbers where the decimal part is .5.

Feel free the provide a patch but beware there is also a `getFontSize` -- we can't change its return type, so you'll need to add a `getFontSizeAsFloat` as an alternative method.
Comment 2 PJ Fanning 2020-07-16 12:32:28 UTC
I added https://github.com/apache/poi/commit/d928ac58a82b243138282ea69ee53b318b8a052c

Could do with more tests though
Comment 3 PJ Fanning 2020-07-16 12:52:11 UTC
changed to double to more closely match some other APIs (eg XDDF APIs) - https://github.com/apache/poi/commit/4a173780dd793aed02c54ba0a9c816ce1b1f8991
Comment 4 80101277 2020-07-17 05:52:11 UTC
hi, PJ Fanning ,
thanks for your job. please add the feature to next version.