You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/08/28 12:17:04 UTC
svn commit: r1892672 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java
Author: tilman
Date: Sat Aug 28 12:17:03 2021
New Revision: 1892672
URL: http://svn.apache.org/viewvc?rev=1892672&view=rev
Log:
PDFBOX-5267: make glyphlist static, as suggested by Alistair Oldfield
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java?rev=1892672&r1=1892671&r2=1892672&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/text/LegacyPDFStreamEngine.java Sat Aug 28 12:17:03 2021
@@ -82,9 +82,24 @@ class LegacyPDFStreamEngine extends PDFS
private int pageRotation;
private PDRectangle pageSize;
private Matrix translateMatrix;
- private final GlyphList glyphList;
+ private static final GlyphList GLYPHLIST;
private final Map<COSDictionary, Float> fontHeightMap = new WeakHashMap<>();
+ static
+ {
+ // load additional glyph list for Unicode mapping
+ String path = "/org/apache/pdfbox/resources/glyphlist/additional.txt";
+ //no need to use a BufferedInputSteam here, as GlyphList uses a BufferedReader
+ try (InputStream input = GlyphList.class.getResourceAsStream(path))
+ {
+ GLYPHLIST = new GlyphList(GlyphList.getAdobeGlyphList(), input);
+ }
+ catch (IOException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
/**
* Constructor.
*/
@@ -112,14 +127,6 @@ class LegacyPDFStreamEngine extends PDFS
addOperator(new SetTextHorizontalScaling());
addOperator(new ShowTextLine());
addOperator(new ShowTextLineAndSpace());
-
- // load additional glyph list for Unicode mapping
- String path = "/org/apache/pdfbox/resources/glyphlist/additional.txt";
- //no need to use a BufferedInputSteam here, as GlyphList uses a BufferedReader
- try (InputStream input = GlyphList.class.getResourceAsStream(path))
- {
- glyphList = new GlyphList(GlyphList.getAdobeGlyphList(), input);
- }
}
/**
@@ -266,7 +273,7 @@ class LegacyPDFStreamEngine extends PDFS
float spaceWidthDisplay = spaceWidthText * textRenderingMatrix.getScalingFactorX();
// use our additional glyph list for Unicode mapping
- String unicode = font.toUnicode(code, glyphList);
+ String unicode = 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