From d18df847b17a89fdc4b47fa9cfe010af1a61690b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 1 Mar 2014 16:48:48 +0100 Subject: Bug 801: TypecastRenderer: Don't use Cubic, but 'double quad' / GlyfCompositeDescript: Fix NPE --- .../jogamp/graph/font/typecast/TypecastRenderer.java | 19 ++++++++++--------- .../font/typecast/ot/table/GlyfCompositeDescript.java | 7 ++++--- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index b3a10700b..6768b18c3 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -38,7 +38,8 @@ import com.jogamp.graph.geom.Vertex.Factory; * Factory to build an {@link OutlineShape} from * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}s. * - * http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html + * http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html + * http://walon.org/pub/ttf/ttf_glyphs.htm */ public class TypecastRenderer { private static final boolean DEBUG = false; @@ -60,11 +61,12 @@ public class TypecastRenderer { shape.addVertex(0, vertexFactory.create(p1.x, p1.y, 0, p1.onCurve)); shape.addVertex(0, vertexFactory.create(p2x, p2y, 0, p2OnCurve)); } + /** private static void addShapeCubicTo(final OutlineShape shape, Factory vertexFactory, Point p1, Point p2, Point p3) { shape.addVertex(0, vertexFactory.create(p1.x, p1.y, 0, p1.onCurve)); shape.addVertex(0, vertexFactory.create(p2.x, p2.y, 0, p2.onCurve)); shape.addVertex(0, vertexFactory.create(p3.x, p3.y, 0, p3.onCurve)); - } + } */ public static OutlineShape buildShape(char symbol, OTGlyph glyph, Factory vertexFactory) { // @@ -161,8 +163,12 @@ public class TypecastRenderer { } else { if (null != p3 && p3.onCurve) { // Branch-3: point.onCurve && !p1.onCurve && !p2.onCurve && p3.onCurve - if( DEBUG ) { System.err.println("B3 .. cubic-to p0-p1-p2-p3 **** CUBIC"); } - addShapeCubicTo(shape, vertexFactory, p1, p2, p3); + if( DEBUG ) { System.err.println("B3 .. 2-quad p0-p1-p1_2, p1_2-p2-p3 **** 2QUAD"); } + // addShapeCubicTo(shape, vertexFactory, p1, p2, p3); + addShapeQuadTo(shape, vertexFactory, p1, + midValue(p1.x, p2.x), + midValue(p1.y, p2.y), true); + addShapeQuadTo(shape, vertexFactory, p2, p3); offset+=3; } else { // Branch-4: point.onCurve && !p1.onCurve && !p2.onCurve && !p3.onCurve @@ -174,7 +180,6 @@ public class TypecastRenderer { addShapeQuadTo(shape, vertexFactory, p1, midValue(p1.x, p2.x), midValue(p1.y, p2.y), true); - // offset++; // Don't skip p2, not completed yet FIXME ? offset+=2; // Skip p2 as done in Typecast } } @@ -210,8 +215,4 @@ public class TypecastRenderer { private static float midValue(float a, float b) { return a + (b - a)/2f; } - /** - private static Point midPoint(Point a, Point b, boolean onCurve) { - return new Point(midValue(a.x, b.x), midValue(a.y, b.y), onCurve, false); - } */ } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java index 50e0fa339..fabc71a77 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java @@ -65,7 +65,7 @@ import java.util.ArrayList; */ public class GlyfCompositeDescript extends GlyfDescript { - private ArrayList _components = + private final ArrayList _components = new ArrayList(); public GlyfCompositeDescript( @@ -167,8 +167,9 @@ public class GlyfCompositeDescript extends GlyfDescript { @Override public int getContourCount() { - GlyfCompositeComp c = _components.get(_components.size()-1); - return c.getFirstContour() + _parentTable.getDescription(c.getGlyphIndex()).getContourCount(); + final GlyfCompositeComp c = _components.get(_components.size()-1); + final GlyfDescript d = _parentTable.getDescription(c.getGlyphIndex()); + return c.getFirstContour() + ( null != d ? d.getContourCount() : 0 ); } public int getComponentIndex(int i) { -- cgit v1.2.3