You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2020/06/14 12:56:02 UTC
svn commit: r1878829 - in
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox:
contentstream/PDFStreamEngine.java text/LegacyPDFStreamEngine.java
Author: lehmi
Date: Sun Jun 14 12:56:02 2020
New Revision: 1878829
URL: http://svn.apache.org/viewvc?rev=1878829&view=rev
Log:
PDFBOX-4879: call deprecated methods if not overwritten to reinstate binary compatibility
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java?rev=1878829&r1=1878828&r2=1878829&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java Sun Jun 14 12:56:02 2020
@@ -802,8 +802,8 @@ public abstract class PDFStreamEngine
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement)
throws IOException
{
- // call deprecated method to ensure binary compatibility
- showGlyph(textRenderingMatrix, font, code, null, displacement);
+ // call deprecated method to ensure binary compatibility if not overridden
+ showGlyph(textRenderingMatrix, font, code, font.toUnicode(code), displacement);
}
/**
@@ -840,7 +840,7 @@ public abstract class PDFStreamEngine
{
// overridden in subclasses
// call deprecated method to ensure binary compatibility if not overridden
- showFontGlyph(textRenderingMatrix, font, code, null, displacement);
+ showFontGlyph(textRenderingMatrix, font, code, font.toUnicode(code), displacement);
}
/**
@@ -853,6 +853,8 @@ public abstract class PDFStreamEngine
* @param unicode the Unicode text for this glyph, or null if the PDF does provide it
* @param displacement the displacement (i.e. advance) of the glyph in text space
* @throws IOException if the glyph cannot be processed
+ *
+ * @deprecated use {@link #showType3Glyph(Matrix, PDType3Font, int, Vector)} instead
*/
protected void showType3Glyph(Matrix textRenderingMatrix, PDType3Font font, int code,
String unicode, Vector displacement) throws IOException
@@ -878,7 +880,7 @@ public abstract class PDFStreamEngine
Vector displacement) throws IOException
{
// call deprecated method to ensure binary compatibility if not overridden
- showType3Glyph(textRenderingMatrix, font, code, null, displacement);
+ showType3Glyph(textRenderingMatrix, font, code, font.toUnicode(code), displacement);
}
/**
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java?rev=1878829&r1=1878828&r2=1878829&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java Sun Jun 14 12:56:02 2020
@@ -139,12 +139,22 @@ class LegacyPDFStreamEngine extends PDFS
super.processPage(page);
}
+ @Override
+ protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement)
+ throws IOException
+ {
+ // call deprecated method to ensure binary compatibility if not overridden
+ showGlyph(textRenderingMatrix, font, code, font.toUnicode(code), displacement);
+ }
+
/**
* Called when a glyph is to be processed. The heuristic calculations here were originally
* written by Ben Litchfield for PDFStreamEngine.
*/
@Override
- protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement)
+ protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code,
+ String unicode,
+ Vector displacement)
throws IOException
{
//
@@ -295,17 +305,17 @@ class LegacyPDFStreamEngine extends PDFS
float spaceWidthDisplay = spaceWidthText * textRenderingMatrix.getScalingFactorX();
// use our additional glyph list for Unicode mapping
- String unicode = font.toUnicode(code, glyphList);
+ String unicodeMapping = font.toUnicode(code, glyphList);
// when there is no Unicode mapping available, Acrobat simply coerces the character code
// into Unicode, so we do the same. Subclasses of PDFStreamEngine don't necessarily want
// this, which is why we leave it until this point in PDFTextStreamEngine.
- if (unicode == null)
+ if (unicodeMapping == null)
{
if (font instanceof PDSimpleFont)
{
char c = (char) code;
- unicode = new String(new char[] { c });
+ unicodeMapping = new String(new char[] { c });
}
else
{
@@ -331,7 +341,8 @@ class LegacyPDFStreamEngine extends PDFS
processTextPosition(new TextPosition(pageRotation, pageSize.getWidth(),
pageSize.getHeight(), translatedTextRenderingMatrix, nextX, nextY,
Math.abs(dyDisplay), dxDisplay,
- Math.abs(spaceWidthDisplay), unicode, new int[] { code } , font, fontSize,
+ Math.abs(spaceWidthDisplay), unicodeMapping, new int[] { code }, font,
+ fontSize,
(int)(fontSize * textMatrix.getScalingFactorX())));
}