pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1692002 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Date Mon, 20 Jul 2015 19:16:30 GMT
Author: msahyoun
Date: Mon Jul 20 19:16:30 2015
New Revision: 1692002

URL: http://svn.apache.org/r1692002
Log:
PDFBOX-2877: special handling if the font caps are taller than the fields clipping area 

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1692002&r1=1692001&r2=1692002&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Mon Jul 20 19:16:30 2015
@@ -243,16 +243,24 @@ class AppearanceGeneratorHelper
         }
         else
         {
-            // calculate the position based on the content rectangle
-            y = clipRect.getLowerLeftY() + (clipRect.getHeight() - fontCapAtSize) / 2;
-
-            // check to ensure that ascents and descents fit
-            if (y - clipRect.getLowerLeftY() < -fontDescentAtSize) {
-
-                float fontDescentBased = -fontDescentAtSize + contentRect.getLowerLeftY();
-                float fontCapBased = contentRect.getHeight() - contentRect.getLowerLeftY()
- fontCapAtSize;
-
-                y = Math.min(fontDescentBased, Math.max(y, fontCapBased));
+            // Adobe shows the text 'shiftet up' in case the caps don't fit into the clipping
area
+            if (fontCapAtSize > clipRect.getHeight())
+            {
+                y = clipRect.getLowerLeftY() + -fontDescentAtSize;
+            }
+            else
+            {
+                // calculate the position based on the content rectangle
+                y = clipRect.getLowerLeftY() + (clipRect.getHeight() - fontCapAtSize) / 2;
+    
+                // check to ensure that ascents and descents fit
+                if (y - clipRect.getLowerLeftY() < -fontDescentAtSize) {
+    
+                    float fontDescentBased = -fontDescentAtSize + contentRect.getLowerLeftY();
+                    float fontCapBased = contentRect.getHeight() - contentRect.getLowerLeftY()
- fontCapAtSize;
+    
+                    y = Math.min(fontDescentBased, Math.max(y, fontCapBased));
+                }
             }
             
         }



Mime
View raw message