pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1607236 - in /pdfbox/trunk: fontbox/src/main/java/org/apache/fontbox/ttf/ pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/ pdfbox/src/main/java/org/apache/pdfbox/rendering/ pdfbox/src/main/java/org/apache/pdfbox/rendering/font/
Date Wed, 02 Jul 2014 02:31:52 GMT
Author: jahewson
Date: Wed Jul  2 02:31:51 2014
New Revision: 1607236

URL: http://svn.apache.org/r1607236
Log:
PDFBOX-2149: Move TrueType glyph rendering into FontBox, move Glyph2D classes

Added:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/
      - copied from r1606966, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/font/
Removed:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/
Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Glyph2D.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/TTFGlyph2D.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Type1Glyph2D.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java?rev=1607236&r1=1607235&r2=1607236&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphData.java Wed Jul  2 02:31:51
2014
@@ -16,6 +16,7 @@
  */
 package org.apache.fontbox.ttf;
 
+import java.awt.geom.GeneralPath;
 import java.io.IOException;
 
 import org.apache.fontbox.util.BoundingBox;
@@ -70,6 +71,7 @@ public class GlyphData
     {
         return boundingBox;
     }
+
     /**
      * @param boundingBoxValue The boundingBox to set.
      */
@@ -77,6 +79,7 @@ public class GlyphData
     {
         this.boundingBox = boundingBoxValue;
     }
+
     /**
      * @return Returns the numberOfContours.
      */
@@ -84,6 +87,7 @@ public class GlyphData
     {
         return numberOfContours;
     }
+
     /**
      * @param numberOfContoursValue The numberOfContours to set.
      */
@@ -100,7 +104,16 @@ public class GlyphData
     {
         return glyphDescription;
     }
-    
+
+    /**
+     * Returns the path of the glyph.
+     * @return the path
+     */
+    public GeneralPath getPath()
+    {
+        return new GlyphRenderer(glyphDescription).getPath();
+    }
+
     /**
      * Returns the xMax value.
      * @return the XMax value
@@ -136,5 +149,4 @@ public class GlyphData
     {
         return yMin;
     }
-
 }

Added: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java?rev=1607236&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java (added)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphRenderer.java Wed Jul 
2 02:31:51 2014
@@ -0,0 +1,273 @@
+package org.apache.fontbox.ttf;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.geom.GeneralPath;
+
+/**
+ * This class provides a glyph to GeneralPath conversion for true type fonts.
+ * Based on code from Apache Batik a subproject of Apache XMLGraphics.
+ *
+ * @see <a href="http://xmlgraphics.apache.org/batik">http://xmlgraphics.apache.org/batik</a>
+ */
+class GlyphRenderer
+{
+    private static final Log LOG = LogFactory.getLog(GlyphRenderer.class);
+
+    private GlyphDescription glyphDescription;
+
+    public GlyphRenderer(GlyphDescription glyphDescription) {
+        this.glyphDescription = glyphDescription;
+    }
+
+    /**
+     * Returns the path of the glyph.
+     * @return the path
+     */
+    public GeneralPath getPath()
+    {
+        Point[] points = describe(glyphDescription);
+        return calculatePath(points);
+    }
+
+    /**
+     * Set the points of a glyph from the GlyphDescription.
+     */
+    private Point[] describe(GlyphDescription gd)
+    {
+        int endPtIndex = 0;
+        Point[] points = new Point[gd.getPointCount()];
+        for (int i = 0; i < gd.getPointCount(); i++)
+        {
+            boolean endPt = gd.getEndPtOfContours(endPtIndex) == i;
+            if (endPt)
+            {
+                endPtIndex++;
+            }
+            points[i] = new Point(gd.getXCoordinate(i), gd.getYCoordinate(i),
+                    (gd.getFlags(i) & GlyfDescript.ON_CURVE) != 0, endPt);
+        }
+        return points;
+    }
+
+    /**
+     * Use the given points to calculate a GeneralPath.
+     *
+     * @param points the points to be used to generate the GeneralPath
+     *
+     * @return the calculated GeneralPath
+     */
+    private GeneralPath calculatePath(Point[] points)
+    {
+        GeneralPath path = new GeneralPath();
+        int numberOfPoints = points.length;
+        int i = 0;
+        boolean endOfContour = true;
+        Point startingPoint = null;
+        Point offCurveStartPoint = null;
+        while (i < numberOfPoints)
+        {
+            Point point = points[i % numberOfPoints];
+            Point nextPoint1 = points[(i + 1) % numberOfPoints];
+            Point nextPoint2 = points[(i + 2) % numberOfPoints];
+            // new contour
+            if (endOfContour)
+            {
+                // skip endOfContour points
+                if (point.endOfContour)
+                {
+                    i++;
+                    continue;
+                }
+                // move to the starting point
+                moveTo(path, point);
+                endOfContour = false;
+                startingPoint = point;
+
+                offCurveStartPoint = null;
+                if (!point.onCurve && !nextPoint1.onCurve)
+                {
+                    // off curve start
+                    offCurveStartPoint = point;
+                    startingPoint = midValue(point, nextPoint1);
+                    moveTo(path, startingPoint);
+                }
+            }
+
+            if (point.onCurve)
+            {
+                offCurveStartPoint = null;
+            }
+            // lineTo
+            if (point.onCurve && nextPoint1.onCurve)
+            {
+                lineTo(path, nextPoint1);
+                i++;
+                if (point.endOfContour || nextPoint1.endOfContour)
+                {
+                    endOfContour = true;
+                    closePath(path);
+                }
+                continue;
+            }
+            // quadratic bezier
+            if (point.onCurve && !nextPoint1.onCurve && nextPoint2.onCurve)
+            {
+                if (nextPoint1.endOfContour)
+                {
+                    // use the starting point as end point
+                    quadTo(path, nextPoint1, startingPoint);
+                }
+                else
+                {
+                    quadTo(path, nextPoint1, nextPoint2);
+                }
+                if (nextPoint1.endOfContour || nextPoint2.endOfContour)
+                {
+                    endOfContour = true;
+                    closePath(path);
+                }
+                i += 2;
+                continue;
+            }
+
+            // TH segment for curves that start with an off-curve point
+            if (offCurveStartPoint != null && !nextPoint1.onCurve && !nextPoint2.onCurve)
+            {
+                // interpolate endPoint
+                quadTo(path, nextPoint1, midValue(nextPoint1, nextPoint2));
+                if (point.endOfContour || nextPoint1.endOfContour || nextPoint2.endOfContour)
+                {
+                    quadTo(path, nextPoint2, midValue(nextPoint2, offCurveStartPoint));
+                    quadTo(path, offCurveStartPoint, startingPoint);
+                    endOfContour = true;
+                    i += 2;
+                    continue;
+                }
+                ++i;
+                continue;
+            }
+
+            if (point.onCurve && !nextPoint1.onCurve && !nextPoint2.onCurve)
+            {
+                // interpolate endPoint
+                quadTo(path, nextPoint1, midValue(nextPoint1, nextPoint2));
+                if (point.endOfContour || nextPoint1.endOfContour || nextPoint2.endOfContour)
+                {
+                    quadTo(path, nextPoint2, startingPoint);
+                    endOfContour = true;
+                    closePath(path);
+                }
+                i += 2;
+                continue;
+            }
+
+            // TH the control point is never interpolated
+            if (!point.onCurve && !nextPoint1.onCurve)
+            {
+                quadTo(path, point, midValue(point, nextPoint1));
+                if (point.endOfContour || nextPoint1.endOfContour)
+                {
+                    endOfContour = true;
+                    quadTo(path, nextPoint1, startingPoint);
+                }
+                i++;
+                continue;
+            }
+
+            if (!point.onCurve && nextPoint1.onCurve)
+            {
+                quadTo(path, point, nextPoint1);
+                if (point.endOfContour || nextPoint1.endOfContour)
+                {
+                    endOfContour = true;
+                    closePath(path);
+                }
+                i++;
+                continue;
+            }
+            LOG.error("Unknown glyph command!!");
+            break;
+        }
+        return path;
+    }
+
+    private void closePath(GeneralPath path)
+    {
+        path.closePath();
+        if (LOG.isDebugEnabled())
+        {
+            LOG.debug("closePath");
+        }
+    }
+
+    private void moveTo(GeneralPath path, Point point)
+    {
+        path.moveTo(point.x, point.y);
+        if (LOG.isDebugEnabled())
+        {
+            LOG.debug("moveTo: " + String.format("%d,%d", point.x, point.y));
+        }
+    }
+
+    private void lineTo(GeneralPath path, Point point)
+    {
+        path.lineTo(point.x, point.y);
+        if (LOG.isDebugEnabled())
+        {
+            LOG.debug("lineTo: " + String.format("%d,%d", point.x, point.y));
+        }
+    }
+
+    private void quadTo(GeneralPath path, Point ctrlPoint, Point point)
+    {
+        path.quadTo(ctrlPoint.x, ctrlPoint.y, point.x, point.y);
+        if (LOG.isDebugEnabled())
+        {
+            LOG.debug("quadTo: " + String.format("%d,%d %d,%d", ctrlPoint.x, ctrlPoint.y,
+                    point.x, point.y));
+        }
+    }
+
+    private int midValue(int a, int b)
+    {
+        return a + (b - a) / 2;
+    }
+
+    private Point midValue(Point point1, Point point2)
+    {
+        return new Point(midValue(point1.x, point2.x), midValue(point1.y, point2.y));
+    }
+
+    /**
+     * This class represents one point of a glyph.
+     */
+    private class Point
+    {
+        private int x = 0;
+        private int y = 0;
+        private boolean onCurve = true;
+        private boolean endOfContour = false;
+
+        Point(int xValue, int yValue, boolean onCurveValue, boolean endOfContourValue)
+        {
+            x = xValue;
+            y = yValue;
+            onCurve = onCurveValue;
+            endOfContour = endOfContourValue;
+        }
+
+        Point(int xValue, int yValue)
+        {
+            this(xValue, yValue, false, false);
+        }
+
+        @Override
+        public String toString()
+        {
+            return String.format("Point(%d,%d,%s,%s)", x, y, onCurve ? "onCurve" : "",
+                    endOfContour ? "endOfContour" : "");
+        }
+    }
+}

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1607236&r1=1607235&r2=1607236&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Wed Jul
 2 02:31:51 2014
@@ -50,9 +50,9 @@ import org.apache.fontbox.ttf.TrueTypeFo
 import org.apache.fontbox.type1.Type1Font;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.pdfviewer.font.Glyph2D;
-import org.apache.pdfbox.pdfviewer.font.TTFGlyph2D;
-import org.apache.pdfbox.pdfviewer.font.Type1Glyph2D;
+import org.apache.pdfbox.rendering.font.Glyph2D;
+import org.apache.pdfbox.rendering.font.TTFGlyph2D;
+import org.apache.pdfbox.rendering.font.Type1Glyph2D;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.PDMatrix;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Glyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Glyph2D.java?rev=1607236&r1=1606966&r2=1607236&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Glyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Glyph2D.java Wed Jul
 2 02:31:51 2014
@@ -17,14 +17,13 @@
 
  */
 
-package org.apache.pdfbox.pdfviewer.font;
+package org.apache.pdfbox.rendering.font;
 
 import java.awt.geom.GeneralPath;
 
 /**
- * This interface is implemented by several font specific classes which is called to get
the general path of a single
- * glyph of the represented font most likely to render it.
- * 
+ * This interface is implemented by several font specific classes which is called to get
the
+ * general path of a single glyph of the represented font most likely to render it.
  */
 public interface Glyph2D
 {
@@ -38,15 +37,7 @@ public interface Glyph2D
     public GeneralPath getPathForCharacterCode(int code);
 
     /**
-     * Returns the number of glyphs provided by the given font.
-     * 
-     * @return the number of glyphs
-     */
-    public int getNumberOfGlyphs();
-
-    /**
      * Remove all cached resources.
      */
     public void dispose();
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/TTFGlyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/TTFGlyph2D.java?rev=1607236&r1=1606966&r2=1607236&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/TTFGlyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/TTFGlyph2D.java Wed
Jul  2 02:31:51 2014
@@ -16,7 +16,7 @@
    limitations under the License.
 
  */
-package org.apache.pdfbox.pdfviewer.font;
+package org.apache.pdfbox.rendering.font;
 
 import java.awt.geom.AffineTransform;
 import java.awt.geom.GeneralPath;
@@ -27,9 +27,7 @@ import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fontbox.cmap.CMap;
-import org.apache.fontbox.ttf.GlyfDescript;
 import org.apache.fontbox.ttf.GlyphData;
-import org.apache.fontbox.ttf.GlyphDescription;
 import org.apache.fontbox.ttf.HeaderTable;
 import org.apache.fontbox.ttf.TrueTypeFont;
 import org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font;
@@ -38,10 +36,7 @@ import org.apache.pdfbox.pdmodel.font.PD
 import org.apache.pdfbox.pdmodel.font.PDType0Font;
 
 /**
- * This class provides a glyph to GeneralPath conversion for true type fonts.
- * Based on code from Apache Batik a subproject of Apache XMLGraphics.
- *
- * @see <a href="http://xmlgraphics.apache.org/batik">http://xmlgraphics.apache.org/batik</a>
+ * This class provides a glyph to GeneralPath conversion for TrueType fonts.
  */
 public class TTFGlyph2D implements Glyph2D
 {
@@ -121,67 +116,6 @@ public class TTFGlyph2D implements Glyph
     }
 
     /**
-     * Set the points of a glyph from the GlyphDescription.
-     */
-    private Point[] describe(GlyphDescription gd)
-    {
-        int endPtIndex = 0;
-        Point[] points = new Point[gd.getPointCount()];
-        for (int i = 0; i < gd.getPointCount(); i++)
-        {
-            boolean endPt = gd.getEndPtOfContours(endPtIndex) == i;
-            if (endPt)
-            {
-                endPtIndex++;
-            }
-            points[i] = new Point(gd.getXCoordinate(i), gd.getYCoordinate(i),
-                    (gd.getFlags(i) & GlyfDescript.ON_CURVE) != 0, endPt);
-        }
-        return points;
-    }
-
-    /**
-     * Returns the path describing the glyph for the given glyphId.
-     *
-     * @param glyphId the glyphId
-     *
-     * @return the GeneralPath for the given glyphId
-     */
-    public GeneralPath getPathForGlyphId(int glyphId)
-    {
-        GeneralPath glyphPath = null;
-        if (glyphs.containsKey(glyphId))
-        {
-            glyphPath = glyphs.get(glyphId);
-        }
-        else
-        {
-            GlyphData[] glyphData = ttf.getGlyph().getGlyphs();
-            if (glyphId < glyphData.length && glyphData[glyphId] != null)
-            {
-                GlyphData glyph = glyphData[glyphId];
-                GlyphDescription gd = glyph.getDescription();
-                Point[] points = describe(gd);
-                glyphPath = calculatePath(points);
-                if (hasScaling)
-                {
-                    AffineTransform atScale = AffineTransform.getScaleInstance(scale, scale);
-                    glyphPath.transform(atScale);
-                }
-                glyphs.put(glyphId, glyphPath);
-            }
-            else
-            {
-                if (LOG.isDebugEnabled())
-                {
-                    LOG.debug(name + ": Glyph not found:" + glyphId);
-                }
-            }
-        }
-        return glyphPath != null ? (GeneralPath) glyphPath.clone() : null;
-    }
-
-    /**
      * Get the GID for the given CIDFont.
      * 
      * @param code the given CID
@@ -246,229 +180,42 @@ public class TTFGlyph2D implements Glyph
     }
 
     /**
-     * Use the given points to calculate a GeneralPath.
-     * 
-     * @param points the points to be used to generate the GeneralPath
-     * 
-     * @return the calculated GeneralPath
+     * Returns the path describing the glyph for the given glyphId.
+     *
+     * @param glyphId the glyphId
+     *
+     * @return the GeneralPath for the given glyphId
      */
-    private GeneralPath calculatePath(Point[] points)
+    public GeneralPath getPathForGlyphId(int glyphId)
     {
-        GeneralPath path = new GeneralPath();
-        int numberOfPoints = points.length;
-        int i = 0;
-        boolean endOfContour = true;
-        Point startingPoint = null;
-        Point offCurveStartPoint = null;
-        while (i < numberOfPoints)
-        {
-            Point point = points[i % numberOfPoints];
-            Point nextPoint1 = points[(i + 1) % numberOfPoints];
-            Point nextPoint2 = points[(i + 2) % numberOfPoints];
-            // new contour
-            if (endOfContour)
-            {
-                // skip endOfContour points
-                if (point.endOfContour)
-                {
-                    i++;
-                    continue;
-                }
-                // move to the starting point
-                moveTo(path, point);
-                endOfContour = false;
-                startingPoint = point;
-
-                offCurveStartPoint = null;
-                if (!point.onCurve && !nextPoint1.onCurve)
-                {
-                    // off curve start
-                    offCurveStartPoint = point;
-                    startingPoint = midValue(point, nextPoint1);
-                    moveTo(path, startingPoint);
-                }
-            }
-
-            if (point.onCurve)
-            {
-                offCurveStartPoint = null;
-            }
-            // lineTo
-            if (point.onCurve && nextPoint1.onCurve)
-            {
-                lineTo(path, nextPoint1);
-                i++;
-                if (point.endOfContour || nextPoint1.endOfContour)
-                {
-                    endOfContour = true;
-                    closePath(path);
-                }
-                continue;
-            }
-            // quadratic bezier
-            if (point.onCurve && !nextPoint1.onCurve && nextPoint2.onCurve)
-            {
-                if (nextPoint1.endOfContour)
-                {
-                    // use the starting point as end point
-                    quadTo(path, nextPoint1, startingPoint);
-                }
-                else
-                {
-                    quadTo(path, nextPoint1, nextPoint2);
-                }
-                if (nextPoint1.endOfContour || nextPoint2.endOfContour)
-                {
-                    endOfContour = true;
-                    closePath(path);
-                }
-                i += 2;
-                continue;
-            }
-
-            // TH segment for curves that start with an off-curve point
-            if (offCurveStartPoint != null && !nextPoint1.onCurve && !nextPoint2.onCurve)
-            {
-                // interpolate endPoint
-                quadTo(path, nextPoint1, midValue(nextPoint1, nextPoint2));
-                if (point.endOfContour || nextPoint1.endOfContour || nextPoint2.endOfContour)
-                {
-                    quadTo(path, nextPoint2, midValue(nextPoint2, offCurveStartPoint));
-                    quadTo(path, offCurveStartPoint, startingPoint);
-                    endOfContour = true;
-                    i += 2;
-                    continue;
-                }
-                ++i;
-                continue;
-            }
-
-            if (point.onCurve && !nextPoint1.onCurve && !nextPoint2.onCurve)
-            {
-                // interpolate endPoint
-                quadTo(path, nextPoint1, midValue(nextPoint1, nextPoint2));
-                if (point.endOfContour || nextPoint1.endOfContour || nextPoint2.endOfContour)
-                {
-                    quadTo(path, nextPoint2, startingPoint);
-                    endOfContour = true;
-                    closePath(path);
-                }
-                i += 2;
-                continue;
-            }
-
-            // TH the control point is never interpolated
-            if (!point.onCurve && !nextPoint1.onCurve)
+        GeneralPath glyphPath = null;
+        if (glyphs.containsKey(glyphId))
+        {
+            glyphPath = glyphs.get(glyphId);
+        }
+        else
+        {
+            GlyphData[] glyphData = ttf.getGlyph().getGlyphs();
+            if (glyphId < glyphData.length && glyphData[glyphId] != null)
             {
-                quadTo(path, point, midValue(point, nextPoint1));
-                if (point.endOfContour || nextPoint1.endOfContour)
+                GlyphData glyph = glyphData[glyphId];
+                glyphPath = glyph.getPath();
+                if (hasScaling)
                 {
-                    endOfContour = true;
-                    quadTo(path, nextPoint1, startingPoint);
+                    AffineTransform atScale = AffineTransform.getScaleInstance(scale, scale);
+                    glyphPath.transform(atScale);
                 }
-                i++;
-                continue;
+                glyphs.put(glyphId, glyphPath);
             }
-
-            if (!point.onCurve && nextPoint1.onCurve)
+            else
             {
-                quadTo(path, point, nextPoint1);
-                if (point.endOfContour || nextPoint1.endOfContour)
+                if (LOG.isDebugEnabled())
                 {
-                    endOfContour = true;
-                    closePath(path);
+                    LOG.debug(name + ": Glyph not found:" + glyphId);
                 }
-                i++;
-                continue;
             }
-            LOG.error("Unknown glyph command!!");
-            break;
         }
-        return path;
-    }
-
-    private void closePath(GeneralPath path)
-    {
-        path.closePath();
-        if (LOG.isDebugEnabled())
-        {
-            LOG.debug("closePath");
-        }
-    }
-
-    private void moveTo(GeneralPath path, Point point)
-    {
-        path.moveTo(point.x, point.y);
-        if (LOG.isDebugEnabled())
-        {
-            LOG.debug("moveTo: " + String.format("%d,%d", point.x, point.y));
-        }
-    }
-
-    private void lineTo(GeneralPath path, Point point)
-    {
-        path.lineTo(point.x, point.y);
-        if (LOG.isDebugEnabled())
-        {
-            LOG.debug("lineTo: " + String.format("%d,%d", point.x, point.y));
-        }
-    }
-
-    private void quadTo(GeneralPath path, Point ctrlPoint, Point point)
-    {
-        path.quadTo(ctrlPoint.x, ctrlPoint.y, point.x, point.y);
-        if (LOG.isDebugEnabled())
-        {
-            LOG.debug("quadTo: " + String.format("%d,%d %d,%d", ctrlPoint.x, ctrlPoint.y,
-                    point.x, point.y));
-        }
-    }
-
-    private int midValue(int a, int b)
-    {
-        return a + (b - a) / 2;
-    }
-
-    private Point midValue(Point point1, Point point2)
-    {
-        return new Point(midValue(point1.x, point2.x), midValue(point1.y, point2.y));
-    }
-
-    /**
-     * This class represents one point of a glyph.
-     */
-    private class Point
-    {
-        private int x = 0;
-        private int y = 0;
-        private boolean onCurve = true;
-        private boolean endOfContour = false;
-
-        Point(int xValue, int yValue, boolean onCurveValue, boolean endOfContourValue)
-        {
-            x = xValue;
-            y = yValue;
-            onCurve = onCurveValue;
-            endOfContour = endOfContourValue;
-        }
-
-        Point(int xValue, int yValue)
-        {
-            this(xValue, yValue, false, false);
-        }
-
-        @Override
-        public String toString()
-        {
-            return String.format("Point(%d,%d,%s,%s)", x, y, onCurve ? "onCurve" : "",
-                    endOfContour ? "endOfContour" : "");
-        }
-    }
-
-    @Override
-    public int getNumberOfGlyphs()
-    {
-        return ttf != null ? ttf.getGlyph().getGlyphs().length : 0;
+        return glyphPath != null ? (GeneralPath) glyphPath.clone() : null;
     }
 
     @Override

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Type1Glyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Type1Glyph2D.java?rev=1607236&r1=1606966&r2=1607236&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Type1Glyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/font/Type1Glyph2D.java Wed
Jul  2 02:31:51 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.pdfbox.pdfviewer.font;
+package org.apache.pdfbox.rendering.font;
 
 import java.awt.geom.GeneralPath;
 import java.io.IOException;
@@ -34,9 +34,6 @@ import org.apache.pdfbox.encoding.Encodi
  */
 public class Type1Glyph2D implements Glyph2D
 {
-    /**
-     * Log instance.
-     */
     private static final Log LOG = LogFactory.getLog(Type1Glyph2D.class);
 
     private HashMap<String, GeneralPath> glyphs = new HashMap<String, GeneralPath>();
@@ -111,9 +108,6 @@ public class Type1Glyph2D implements Gly
         return glyphs.get(name);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public GeneralPath getPathForCharacterCode(int code)
     {
@@ -129,22 +123,6 @@ public class Type1Glyph2D implements Gly
         return null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getNumberOfGlyphs()
-    {
-        if (glyphs != null)
-        {
-            return glyphs.size();
-        }
-        return 0;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void dispose()
     {



Mime
View raw message