[bug-64605] add support for non-integer font sizes on character runs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879949 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2020-07-16 12:31:53 +00:00
parent d928ac58a8
commit cb1d9a0061
2 changed files with 15 additions and 0 deletions

View File

@ -48,7 +48,9 @@ public interface CharacterRun {
void setImprinted(boolean imprint);
int getFontSize();
float getFontSizeAsFloat();
void setFontSize(int halfPoints);
void setFontSize(float halfPoints);
int getCharacterSpacing();
void setCharacterSpacing(int twips);

View File

@ -28,6 +28,9 @@ import org.apache.poi.hwpf.model.StyleSheet;
import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.util.Removal;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* This class represents a run of text that share common properties.
*/
@ -349,6 +352,11 @@ public final class CharacterRun extends Range implements Duplicatable, org.apach
return _props.getHps();
}
public float getFontSizeAsFloat()
{
return (float)getFontSize();
}
public void setFontSize(int halfPoints)
{
_props.setHps(halfPoints);
@ -357,6 +365,11 @@ public final class CharacterRun extends Range implements Duplicatable, org.apach
}
public void setFontSize(float halfPoints)
{
setFontSize(BigDecimal.valueOf(halfPoints).setScale(0, RoundingMode.HALF_UP).intValue());
}
public int getCharacterSpacing()
{
return _props.getDxaSpace();