]> source.dussan.org Git - poi.git/commitdiff
[bug-64605] add support for non-integer font sizes on character runs
authorPJ Fanning <fanningpj@apache.org>
Thu, 16 Jul 2020 12:31:53 +0000 (12:31 +0000)
committerPJ Fanning <fanningpj@apache.org>
Thu, 16 Jul 2020 12:31:53 +0000 (12:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879949 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/wp/usermodel/CharacterRun.java
src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java

index 549ef6779b7c9c779596a3c0dd159ad7fb8392eb..81117c2bd214800aaecfe2f816408a8c4859a39a 100644 (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);
index 3553015364ed3358ad8f0e6918fc46b8aeed63b4..530196eb26d231d7ca2dae21e1a12b55b4a8cad1 100644 (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();