#58220 - Improve the javadocs for XSSFFont and Font getFontHeight methods
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1695528 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac8ed40f80
commit
6d46fc382f
@ -138,20 +138,25 @@ public interface Font {
|
|||||||
void setFontHeightInPoints(short height);
|
void setFontHeightInPoints(short height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the font height in unit's of 1/20th of a point. Maybe you might want to
|
* Get the font height in unit's of 1/20th of a point.
|
||||||
* use the getFontHeightInPoints which matches to the familiar 10, 12, 14 etc..
|
* <p>
|
||||||
|
* For many users, the related {@link #getFontHeightInPoints()}
|
||||||
|
* will be more helpful, as that returns font heights in the
|
||||||
|
* more familiar points units, eg 10, 12, 14.
|
||||||
|
|
||||||
* @return short - height in 1/20ths of a point
|
* @return short - height in 1/20ths of a point
|
||||||
* @see #getFontHeightInPoints()
|
* @see #getFontHeightInPoints()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
short getFontHeight();
|
short getFontHeight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the font height
|
* Get the font height in points.
|
||||||
|
* <p>
|
||||||
|
* This will return the same font height that is shown in Excel,
|
||||||
|
* such as 10 or 14 or 28.
|
||||||
* @return short - height in the familiar unit of measure - points
|
* @return short - height in the familiar unit of measure - points
|
||||||
* @see #getFontHeight()
|
* @see #getFontHeight()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
short getFontHeightInPoints();
|
short getFontHeightInPoints();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,24 +174,42 @@ public class XSSFFont implements Font {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the font height in point.
|
* Get the font height in unit's of 1/20th of a point.
|
||||||
*
|
* <p>
|
||||||
* @return short - height in point
|
* For many users, the related {@link #getFontHeightInPoints()}
|
||||||
|
* will be more helpful, as that returns font heights in the
|
||||||
|
* more familiar points units, eg 10, 12, 14.
|
||||||
|
|
||||||
|
* @return short - height in 1/20ths of a point
|
||||||
|
* @see #getFontHeightInPoints()
|
||||||
*/
|
*/
|
||||||
public short getFontHeight() {
|
public short getFontHeight() {
|
||||||
CTFontSize size = _ctFont.sizeOfSzArray() == 0 ? null : _ctFont.getSzArray(0);
|
return (short)(getFontHeightRaw()*20);
|
||||||
if (size != null) {
|
|
||||||
double fontHeight = size.getVal();
|
|
||||||
return (short)(fontHeight*20);
|
|
||||||
}
|
|
||||||
return (short)(DEFAULT_FONT_SIZE*20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the font height in points.
|
||||||
|
* <p>
|
||||||
|
* This will return the same font height that is shown in Excel,
|
||||||
|
* such as 10 or 14 or 28.
|
||||||
|
* @return short - height in the familiar unit of measure - points
|
||||||
* @see #getFontHeight()
|
* @see #getFontHeight()
|
||||||
*/
|
*/
|
||||||
public short getFontHeightInPoints() {
|
public short getFontHeightInPoints() {
|
||||||
return (short)(getFontHeight()/20);
|
return (short)getFontHeightRaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the raw font height, in points, but also
|
||||||
|
* including fractions.
|
||||||
|
*/
|
||||||
|
private double getFontHeightRaw() {
|
||||||
|
CTFontSize size = _ctFont.sizeOfSzArray() == 0 ? null : _ctFont.getSzArray(0);
|
||||||
|
if (size != null) {
|
||||||
|
double fontHeight = size.getVal();
|
||||||
|
return fontHeight;
|
||||||
|
}
|
||||||
|
return DEFAULT_FONT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user