pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1839175 - in /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf: GlyphTable.java TrueTypeFont.java
Date Sun, 26 Aug 2018 08:57:11 GMT
Author: tilman
Date: Sun Aug 26 08:57:11 2018
New Revision: 1839175

URL: http://svn.apache.org/viewvc?rev=1839175&view=rev
Log:
PDFBOX-4219:  synchronize on data because it is accessed by several threads when PDFBox is
accessing a standard 14 font for the first time

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java?rev=1839175&r1=1839174&r2=1839175&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java Sun Aug
26 08:57:11 2018
@@ -83,7 +83,9 @@ public class GlyphTable extends TTFTable
      */
     public GlyphData[] getGlyphs() throws IOException
     {
-        synchronized (font)
+        // PDFBOX-4219: synchronize on data because it is accessed by several threads
+        // when PDFBox is accessing a standard 14 font for the first time
+        synchronized (data)
         {
             // the glyph offsets
             long[] offsets = loca.getOffsets();
@@ -157,7 +159,9 @@ public class GlyphTable extends TTFTable
             return glyphs[gid];
         }
 
-        synchronized (font)
+        // PDFBOX-4219: synchronize on data because it is accessed by several threads
+        // when PDFBox is accessing a standard 14 font for the first time
+        synchronized (data)
         {
             // read a single glyph
             long[] offsets = loca.getOffsets();

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java?rev=1839175&r1=1839174&r2=1839175&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java Sun
Aug 26 08:57:11 2018
@@ -343,12 +343,17 @@ public class TrueTypeFont implements Fon
      */
     void readTable(TTFTable table) throws IOException
     {
-        // save current position
-        long currentPosition = data.getCurrentPosition();
-        data.seek(table.getOffset());
-        table.read(this, data);
-        // restore current position
-        data.seek(currentPosition);
+        // PDFBOX-4219: synchronize on data because it is accessed by several threads
+        // when PDFBox is accessing a standard 14 font for the first time
+        synchronized (data)
+        {
+            // save current position
+            long currentPosition = data.getCurrentPosition();
+            data.seek(table.getOffset());
+            table.read(this, data);
+            // restore current position
+            data.seek(currentPosition);
+        }
     }
 
     /**



Mime
View raw message