pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1716736 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java
Date Thu, 26 Nov 2015 16:31:48 GMT
Author: tilman
Date: Thu Nov 26 16:31:48 2015
New Revision: 1716736

URL: http://svn.apache.org/viewvc?rev=1716736&view=rev
Log:
PDFBOX-3062: use CapHeight if smaller than half the bbox height to avoid "wild" bbox heights

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java?rev=1716736&r1=1716735&r2=1716736&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStreamEngine.java Thu
Nov 26 16:31:48 2015
@@ -54,6 +54,7 @@ import org.apache.pdfbox.contentstream.o
 import org.apache.pdfbox.contentstream.operator.text.SetTextRise;
 import org.apache.pdfbox.contentstream.operator.text.SetWordSpacing;
 import org.apache.pdfbox.contentstream.operator.text.ShowText;
+import org.apache.pdfbox.pdmodel.font.PDFontDescriptor;
 
 /**
  * PDFStreamEngine subclass for advanced processing of text via TextPosition.
@@ -155,6 +156,17 @@ class PDFTextStreamEngine extends PDFStr
         }
         // 1/2 the bbox is used as the height todo: why?
         float glyphHeight = bbox.getHeight() / 2;
+        
+        // sometimes the bbox has very high values, but CapHeight is OK
+        PDFontDescriptor fontDescriptor = font.getFontDescriptor();
+        if (fontDescriptor != null)
+        {
+            float capHeight = fontDescriptor.getCapHeight();
+            if (capHeight != 0 && capHeight < glyphHeight)
+            {
+                glyphHeight = capHeight;
+            }
+        }
 
         // transformPoint from glyph space -> text space
         float height = font.getFontMatrix().transformPoint(0, glyphHeight).y;



Mime
View raw message