summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-01 16:48:48 +0100
committerSven Gothel <[email protected]>2014-03-01 16:48:48 +0100
commitd18df847b17a89fdc4b47fa9cfe010af1a61690b (patch)
tree4c7f1d11adef78ef290288d6383ff04ca635f0bd /src/jogl/classes
parent183e1bc1868699b99eb9f9c8bf18d646d1120a48 (diff)
Bug 801: TypecastRenderer: Don't use Cubic, but 'double quad' / GlyfCompositeDescript: Fix NPE
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java19
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java7
2 files changed, 14 insertions, 12 deletions
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<? extends Vertex> 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<? extends Vertex> 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<GlyfCompositeComp> _components =
+ private final ArrayList<GlyfCompositeComp> _components =
new ArrayList<GlyfCompositeComp>();
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) {