From a5d593478afa2298282a0624b2490fde84c3a292 Mon Sep 17 00:00:00 2001
From: Sven Gothel
* The processed shapes are in font em-size [0..1]. *
- * @param visitor handling each glyph's outline shape in font em-size [0..1] + * @param visitor handling each {@link Font.Glyph} and perhaps its {@link OutlineShape} in font em-size [0..1] * @param string string text */ - void processString(final OutlineShape.Visitor2 visitor, final CharSequence string); + void processString(final Font.GlyphVisitor2 visitor, final CharSequence string); /** Returns {@link #getFullFamilyName()} */ @Override diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java index 8b3b9dbf1..7aba7fa73 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java @@ -2129,6 +2129,16 @@ public final class FloatUtil { /** The value PI^2. */ public final static float SQUARED_PI = PI * PI; + /** Converts arc-degree to radians */ + public static float adegToRad(final float arc_degree) { + return arc_degree * PI / 180.0f; + } + + /** Converts radians to arc-degree */ + public static float radToADeg(final float rad) { + return rad * 180.0f / PI; + } + /** * Epsilon for floating point {@value}, as once computed via {@link #getMachineEpsilon()} on an AMD-64 CPU. *diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index ca27b9164..188d8d688 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -330,6 +330,10 @@ class TypecastFont implements Font { advanceTotal += glyph.getAdvanceFU(); left_glyph = null; // break kerning continue; + } else if( glyph.isWhiteSpace() ) { // covers 'space' and all non-contour symbols + advanceTotal += glyph.getAdvance(); + left_glyph = null; // break kerning + continue; } if( null != left_glyph ) { advanceTotal += left_glyph.getKerningFU(glyph_id); @@ -353,22 +357,22 @@ class TypecastFont implements Font { if (null == string || 0 == string.length() ) { return new AABBox(); } - final OutlineShape.Visitor visitor = new OutlineShape.Visitor() { + final Font.GlyphVisitor visitor = new Font.GlyphVisitor() { @Override - public final void visit(final OutlineShape shape, final AffineTransform t) { + public final void visit(final Font.Glyph shape, final AffineTransform t) { // nop } }; return processString(visitor, transform, string); } @Override - public AABBox processString(final OutlineShape.Visitor visitor, final AffineTransform transform, + public AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform, final CharSequence string) { return processString(visitor, transform, string, new AffineTransform(), new AffineTransform()); } @Override - public AABBox processString(final OutlineShape.Visitor visitor, final AffineTransform transform, + public AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform, final CharSequence string, final AffineTransform temp1, final AffineTransform temp2) { if (null == string || 0 == string.length() ) { @@ -407,13 +411,15 @@ class TypecastFont implements Font { advanceTotal += glyph.getAdvance(); left_glyph = null; // break kerning continue; + } else if( glyph.isWhiteSpace() ) { // covers 'space' and all non-contour symbols + left_glyph = null; // break kerning } if( null != left_glyph ) { advanceTotal += left_glyph.getKerning(glyph_id); } temp1.translate(advanceTotal, y, temp2); res.resize(temp1.transform(glyphShape.getBounds(), temp_box)); - visitor.visit(glyphShape, temp1); + visitor.visit(glyph, temp1); advanceTotal += glyph.getAdvance(); left_glyph = glyph; } @@ -422,7 +428,7 @@ class TypecastFont implements Font { } @Override - public void processString(final OutlineShape.Visitor2 visitor, final CharSequence string) { + public void processString(final Font.GlyphVisitor2 visitor, final CharSequence string) { if (null == string || 0 == string.length() ) { return; } @@ -431,9 +437,9 @@ class TypecastFont implements Font { for(int i=0; i< charCount; i++) { final char character = string.charAt(i); if( '\n' != character ) { - final OutlineShape glyphShape = getGlyph(getGlyphID(character)).getShape(); - if( null != glyphShape ) { // also covers 'space' and all non-contour symbols - visitor.visit(glyphShape); + final Glyph glyph = getGlyph(getGlyphID(character)); + if( null != glyph.getShape() ) { // also covers 'space' and all non-contour symbols + visitor.visit(glyph); } } } -- cgit v1.2.3