pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1664658 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceStyle.java
Date Fri, 06 Mar 2015 15:35:29 GMT
Author: msahyoun
Date: Fri Mar  6 15:35:29 2015
New Revision: 1664658

URL: http://svn.apache.org/r1664658
Log:
PDFBOX-1402 add javadoc; simplify leading calculation

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceStyle.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceStyle.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceStyle.java?rev=1664658&r1=1664657&r2=1664658&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceStyle.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceStyle.java
Fri Mar  6 15:35:29 2015
@@ -16,55 +16,85 @@
  */
 package org.apache.pdfbox.pdmodel.interactive.form;
 
-import java.io.IOException;
-
 import org.apache.pdfbox.pdmodel.font.PDFont;
 
+/**
+ * Define styling attributes to be used for text formatting.
+ * 
+ */
 class AppearanceStyle
 {
-    private static final float FONTSCALE = 1000f;
-
     private PDFont font;
-    private float fontSize;
-    private float leading;
-    
+    /**
+     * The font size to be used for text formatting.
+     *
+     * Defaulting to 12 to math Acrobats default.
+     */
+    private float fontSize = 12.0f;
+    
+    /**
+     * The leading (distance between lines) to be used for text formatting.
+     *
+     * Defaulting to 1.2*fontSize to match Acrobats default.
+     */
+    private float leading = 14.4f;
+    
+    /**
+     * Get the font used for text formatting.
+     * 
+     * @return the font used for text formatting.
+     */
     PDFont getFont()
     {
         return font;
     }
     
+    /**
+     * Set the font to be used for text formatting.
+     * 
+     * @param font the font to be used.
+     */
     void setFont(PDFont font)
     {
         this.font = font;
     }
     
+    /**
+     * Get the fontSize used for text formatting.
+     * 
+     * @return the fontSize used for text formatting.
+     */
     float getFontSize()
     {
         return fontSize;
     }
     
+    /**
+     * Set the font size to be used for formatting.
+     * 
+     * @param fontSize the font size.
+     */
     void setFontSize(float fontSize)
     {
-        final float scale = fontSize/FONTSCALE;
         this.fontSize = fontSize;
-        if (leading == 0)
-        {
-            try
-            {
-                leading = font.getBoundingBox().getHeight() * scale;
-            }
-            catch (IOException e)
-            {
-                leading = fontSize * 1.2f;
-            }
-        }
+        leading = fontSize * 1.2f;
     }
-    
+
+    /**
+     * Get the leading used for text formatting.
+     * 
+     * @return the leading used for text formatting.
+     */
     float getLeading()
     {
         return leading;
     }
     
+    /**
+     * Set the leading used for text formatting.
+     * 
+     * @param leading the leading to be used.
+     */
     void setLeading(float leading)
     {
         this.leading = leading;



Mime
View raw message