Bug 60282 - getFontHeightInPoints() has wrong type
Summary: getFontHeightInPoints() has wrong type
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-20 12:04 UTC by najh
Modified: 2017-02-17 05:33 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description najh 2016-10-20 12:04:22 UTC
short	getFontHeight()
Get the font height in unit's of 1/20th of a point.

Type short is wrong. There must be a double.
The font size can be for example 8.5. Now it returns 8, throwing a fractional part.
   
  170 / 20 =8,5

from HSSFFont:
    public short getFontHeightInPoints()
    {
        return ( short ) (font.getFontHeight() / 20);
    }


from XSSFFont:
    public short getFontHeightInPoints() {
        return (short)(getFontHeight()/20);
    }
Comment 1 Javen O'Neal 2017-02-17 05:33:48 UTC
Unfortunately, changing the return type of this method would break backwards compatibility.

If you need the accuracy of fractional points, perform this computation yourself using getFontHeight.

We could add a warning in the JavaDoc that fractional values are discarded.
We could also make the 20 constant a public constant in Font.
Otherwise we could try to change the return type through some slow deprecation process.