From 114cc7be0f43a6cf2540caa0ed47948d7cade54f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 28 Mar 2023 02:41:30 +0200 Subject: Graph Font.GlyphVisitor*: Pass 'char symbol' to visitor, passing full text-processing information --- src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java | 2 +- src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java | 3 ++- .../classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java | 4 ++-- src/jogl/classes/com/jogamp/graph/font/Font.java | 6 ++++-- src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java | 8 +++----- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java index 17ea3ad4e..5d45ffb9c 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java @@ -162,7 +162,7 @@ public class Label extends Shape { private final Font.GlyphVisitor glyphVisitor = new Font.GlyphVisitor() { @Override - public void visit(final Glyph glyph, final AffineTransform t) { + public void visit(final char symbol, final Glyph glyph, final AffineTransform t) { if( glyph.isWhiteSpace() ) { return; } 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 6797a266c..402a238c9 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -43,6 +43,7 @@ import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.texture.TextureSequence; import com.jogamp.graph.curve.Region; import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.Font.Glyph; import java.io.PrintStream; @@ -152,7 +153,7 @@ public abstract class GLRegion extends Region { final int[] vertIndexCount = { 0, 0 }; final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { @Override - public final void visit(final Font.Glyph glyph) { + public final void visit(final char symbol, final Font.Glyph glyph) { region.countOutlineShape(glyph.getShape(), vertIndexCount); } }; font.processString(visitor, str); 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 35b6d5028..237d93184 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -109,7 +109,7 @@ public class TextRegionUtil { final AffineTransform temp1, final AffineTransform temp2) { final Font.GlyphVisitor visitor = new Font.GlyphVisitor() { @Override - public void visit(final Glyph glyph, final AffineTransform t) { + public void visit(final char symbol, final Glyph glyph, final AffineTransform t) { if( glyph.isWhiteSpace() ) { return; } @@ -135,7 +135,7 @@ public class TextRegionUtil { public static void countStringRegion(final Region region, final Font font, final CharSequence str, final int[/*2*/] vertIndexCount) { final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { @Override - public final void visit(final Font.Glyph glyph) { + public final void visit(final char symbol, final Font.Glyph glyph) { region.countOutlineShape(glyph.getShape(), vertIndexCount); } }; font.processString(visitor, str); diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index 2fb9b94ab..4399bbad7 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -258,10 +258,11 @@ public interface Font { public static interface GlyphVisitor { /** * Visiting the given {@link Font.Glyph} having an {@link OutlineShape} with it's corresponding {@link AffineTransform}. + * @param symbol the character symbol matching the given glyph * @param glyph {@link Font.Glyph} which contains an {@link OutlineShape} via {@link Font.Glyph#getShape()}. * @param t may be used immediately as is, otherwise a copy shall be made if stored. */ - public void visit(final Glyph glyph, final AffineTransform t); + public void visit(final char symbol, final Glyph glyph, final AffineTransform t); } /** @@ -270,9 +271,10 @@ public interface Font { public static interface GlyphVisitor2 { /** * Visiting the given {@link Font.Glyph} having an {@link OutlineShape}. + * @param symbol the character symbol matching the given glyph * @param glyph {@link Font.Glyph} which contains an {@link OutlineShape} via {@link Font.Glyph#getShape()}. */ - public void visit(final Glyph glyph); + public void visit(final char symbol, final Glyph glyph); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index 7dc20e47f..dcf8ce56c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -31,8 +31,6 @@ import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; -import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; import com.jogamp.graph.geom.plane.AffineTransform; import com.jogamp.opengl.math.geom.AABBox; @@ -359,7 +357,7 @@ class TypecastFont implements Font { } final Font.GlyphVisitor visitor = new Font.GlyphVisitor() { @Override - public final void visit(final Font.Glyph shape, final AffineTransform t) { + public final void visit(final char symbol, final Font.Glyph shape, final AffineTransform t) { // nop } }; return processString(visitor, transform, string); @@ -419,7 +417,7 @@ class TypecastFont implements Font { } temp1.translate(advanceTotal, y, temp2); res.resize(temp1.transform(glyphShape.getBounds(), temp_box)); - visitor.visit(glyph, temp1); + visitor.visit(character, glyph, temp1); advanceTotal += glyph.getAdvance(); left_glyph = glyph; } @@ -439,7 +437,7 @@ class TypecastFont implements Font { if( '\n' != character ) { final Glyph glyph = getGlyph(getGlyphID(character)); if( null != glyph.getShape() ) { // also covers 'space' and all non-contour symbols - visitor.visit(glyph); + visitor.visit(character, glyph); } } } -- cgit v1.2.3