From a5d593478afa2298282a0624b2490fde84c3a292 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 22 Mar 2023 16:55:04 +0100 Subject: Graph Font Processing: Use Font.GlyphVisitor instead of OutlineShape.Visitor, allowing to use the Glyph (information). --- .../com/jogamp/graph/curve/opengl/GLRegion.java | 6 +++--- .../com/jogamp/graph/curve/opengl/TextRegionUtil.java | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl') diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java index aca5fca52..aa756582a 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -150,10 +150,10 @@ public abstract class GLRegion extends Region { region = new VBORegionSPES2(glp, renderModes, colorTexSeq, 0, 0); } final int[] vertIndexCount = { 0, 0 }; - final OutlineShape.Visitor2 visitor = new OutlineShape.Visitor2() { + final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { @Override - public final void visit(final OutlineShape shape) { - region.countOutlineShape(shape, vertIndexCount); + public final void visit(final Font.Glyph glyph) { + region.countOutlineShape(glyph.getShape(), vertIndexCount); } }; font.processString(visitor, str); region.setBufferCapacity(vertIndexCount[0], vertIndexCount[1]); diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java index de9ff5636..35b6d5028 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -37,6 +37,7 @@ import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.Font.Glyph; import com.jogamp.graph.geom.plane.AffineTransform; /** @@ -106,11 +107,15 @@ public class TextRegionUtil { public static AABBox addStringToRegion(final Region region, final Font font, final AffineTransform transform, final CharSequence str, final float[] rgbaColor, final AffineTransform temp1, final AffineTransform temp2) { - 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) { - region.addOutlineShape(shape, t, region.hasColorChannel() ? rgbaColor : null); - } }; + public void visit(final Glyph glyph, final AffineTransform t) { + if( glyph.isWhiteSpace() ) { + return; + } + region.addOutlineShape(glyph.getShape(), t, region.hasColorChannel() ? rgbaColor : null); + } + }; return font.processString(visitor, transform, str, temp1, temp2); } @@ -128,10 +133,10 @@ public class TextRegionUtil { * @see #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform) */ public static void countStringRegion(final Region region, final Font font, final CharSequence str, final int[/*2*/] vertIndexCount) { - final OutlineShape.Visitor2 visitor = new OutlineShape.Visitor2() { + final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { @Override - public final void visit(final OutlineShape shape) { - region.countOutlineShape(shape, vertIndexCount); + public final void visit(final Font.Glyph glyph) { + region.countOutlineShape(glyph.getShape(), vertIndexCount); } }; font.processString(visitor, str); } -- cgit v1.2.3