pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1798250 - in /pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf: MemoryTTFDataStream.java RAFDataStream.java TTCDataStream.java TTFDataStream.java TrueTypeFont.java
Date Fri, 09 Jun 2017 17:23:50 GMT
Author: tilman
Date: Fri Jun  9 17:23:50 2017
New Revision: 1798250

URL: http://svn.apache.org/viewvc?rev=1798250&view=rev
Log:
PDFBOX-3824: get the length of a ttf datastream

Modified:
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTCDataStream.java
    pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.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/MemoryTTFDataStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java?rev=1798250&r1=1798249&r2=1798250&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java
(original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/MemoryTTFDataStream.java
Fri Jun  9 17:23:50 2017
@@ -44,7 +44,7 @@ class MemoryTTFDataStream extends TTFDat
         {
             ByteArrayOutputStream output = new ByteArrayOutputStream( is.available() );
             byte[] buffer = new byte[1024];
-            int amountRead = 0;
+            int amountRead;
             while( (amountRead = is.read( buffer ) ) != -1 )
             {
                 output.write( buffer, 0, amountRead );
@@ -62,6 +62,7 @@ class MemoryTTFDataStream extends TTFDat
      * @return An unsigned byte.
      * @throws IOException If there is an error reading the data.
      */
+    @Override
     public long readLong() throws IOException
     {
         return ((long)(readSignedInt()) << 32) + (readSignedInt() & 0xFFFFFFFFL);
@@ -91,6 +92,7 @@ class MemoryTTFDataStream extends TTFDat
      * @return An unsigned byte.
      * @throws IOException If there is an error reading the data.
      */
+    @Override
     public int read() throws IOException
     {
         if (currentPosition >= data.length)
@@ -108,6 +110,7 @@ class MemoryTTFDataStream extends TTFDat
      * @return An unsigned short.
      * @throws IOException If there is an error reading the data.
      */
+    @Override
     public int readUnsignedShort() throws IOException
     {
         int ch1 = this.read();
@@ -125,6 +128,7 @@ class MemoryTTFDataStream extends TTFDat
      * @return An signed short.
      * @throws IOException If there is an error reading the data.
      */
+    @Override
     public short readSignedShort() throws IOException
     {
         int ch1 = this.read();
@@ -141,6 +145,7 @@ class MemoryTTFDataStream extends TTFDat
      * 
      * @throws IOException If there is an error closing the resources.
      */
+    @Override
     public void close() throws IOException
     {
     }
@@ -151,6 +156,7 @@ class MemoryTTFDataStream extends TTFDat
      * @param pos The position to seek to.
      * @throws IOException If there is an error seeking to that position.
      */
+    @Override
     public void seek(long pos) throws IOException
     {
         currentPosition = (int)pos;
@@ -167,6 +173,7 @@ class MemoryTTFDataStream extends TTFDat
      * 
      * @throws IOException If there is an error reading from the stream.
      */
+    @Override
     public int read(byte[] b,
             int off,
             int len)
@@ -190,6 +197,7 @@ class MemoryTTFDataStream extends TTFDat
      * @return The current position in the stream.
      * @throws IOException If an error occurs while reading the stream.
      */
+    @Override
     public long getCurrentPosition() throws IOException
     {
         return currentPosition;
@@ -198,8 +206,18 @@ class MemoryTTFDataStream extends TTFDat
     /**
      * {@inheritDoc}
      */
+    @Override
     public InputStream getOriginalData() throws IOException
     {
         return new ByteArrayInputStream( data );
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long getOriginalDataSize()
+    {
+        return data.length;
+    }
 }
\ No newline at end of file

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java?rev=1798250&r1=1798249&r2=1798250&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/RAFDataStream.java Fri
Jun  9 17:23:50 2017
@@ -175,4 +175,13 @@ class RAFDataStream extends TTFDataStrea
     {
         return new FileInputStream( ttfFile );
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long getOriginalDataSize()
+    {
+        return ttfFile.length();
+    }
 }

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTCDataStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTCDataStream.java?rev=1798250&r1=1798249&r2=1798250&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTCDataStream.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTCDataStream.java Fri
Jun  9 17:23:50 2017
@@ -88,4 +88,10 @@ class TTCDataStream extends TTFDataStrea
     {
         return stream.getOriginalData();
     }
+
+    @Override
+    public long getOriginalDataSize()
+    {
+        return stream.getOriginalDataSize();
+    }
 }

Modified: pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java?rev=1798250&r1=1798249&r2=1798250&view=diff
==============================================================================
--- pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java (original)
+++ pdfbox/branches/2.0/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java Fri
Jun  9 17:23:50 2017
@@ -304,4 +304,11 @@ abstract class TTFDataStream implements
      */
     public abstract InputStream getOriginalData() throws IOException;
 
+    /**
+     * This will get the original data size that was used for this stream.
+     * 
+     * @return The size of the original data.
+     * @throws IOException If there is an issue reading the data.
+     */
+    public abstract long getOriginalDataSize();
 }

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=1798250&r1=1798249&r2=1798250&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 Fri
Jun  9 17:23:50 2017
@@ -308,6 +308,19 @@ public class TrueTypeFont implements Fon
     {
        return data.getOriginalData(); 
     }
+
+    /**
+     * Get the data size of the TrueType Font program representing the stream used to build
this
+     * object (normally from the TTFParser object).
+     * 
+     * @return the size.
+     * 
+     * @throws IOException If there is an error getting the font data.
+     */
+    public long getOriginalDataSize()
+    {
+       return data.getOriginalDataSize(); 
+    }
     
     /**
      * Read the given table if necessary. Package-private, used by TTFParser only.



Mime
View raw message