aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/font/Font.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-22 16:55:04 +0100
committerSven Gothel <[email protected]>2023-03-22 16:55:04 +0100
commita5d593478afa2298282a0624b2490fde84c3a292 (patch)
tree9a995fe24f8617e42a75475d0755e5da1944ebdb /src/jogl/classes/com/jogamp/graph/font/Font.java
parent960af62429aef3ec573a7f6fa3ed6b0f5552376f (diff)
Graph Font Processing: Use Font.GlyphVisitor instead of OutlineShape.Visitor, allowing to use the Glyph (information).
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/font/Font.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 1b5452a45..2a75a203f 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -172,6 +172,9 @@ public interface Font {
/** Return the glyph's name, source from `post` table */
String getName();
+ /** Return true if the underlying {@link #getShape()} is a whitespace, otherwise false. */
+ boolean isWhiteSpace();
+
/**
* Return the AABBox in font-units, borrowing internal instance.
*/
@@ -246,6 +249,30 @@ public interface Font {
String fullString();
}
+ /**
+ * General purpose {@link Font.Glyph} visitor.
+ */
+ public static interface GlyphVisitor {
+ /**
+ * Visiting the given {@link Font.Glyph} having an {@link OutlineShape} with it's corresponding {@link AffineTransform}.
+ * @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);
+ }
+
+ /**
+ * Constrained {@link Font.Glyph} visitor w/o {@link AffineTransform}.
+ */
+ public static interface GlyphVisitor2 {
+ /**
+ * Visiting the given {@link Font.Glyph} having an {@link OutlineShape}.
+ * @param glyph {@link Font.Glyph} which contains an {@link OutlineShape} via {@link Font.Glyph#getShape()}.
+ */
+ public void visit(final Glyph glyph);
+ }
+
+
String getName(final int nameIndex);
/** Shall return the family and subfamily name, separated a dash.
@@ -417,39 +444,41 @@ public interface Font {
boolean isPrintableChar(final char c);
/**
- * Try using {@link #processString(com.jogamp.graph.curve.OutlineShape.Visitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)}
+ * Try using {@link #processString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)}
* to reuse {@link AffineTransform} instances.
+ * @see #processString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)
*/
- AABBox processString(final OutlineShape.Visitor visitor, final AffineTransform transform,
+ AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform,
final CharSequence string);
/**
- * Visit each {@link Glyph}'s {@link OutlineShape} of the string with the {@link OutlineShape.Visitor}
+ * Visit each {@link Glyph} and perhaps its {@link OutlineShape} of the string with the {@link Font.GlyphVisitor}
* while passing the progressed {@link AffineTransform}.
* <p>
* The processed shapes are in font em-size [0..1], but can be adjusted with the given transform, progressed and passed to the visitor.
* </p>
- * @param visitor handling each glyph's outline shape in font em-size [0..1] and the given {@link AffineTransform}
- * @param transform optional given transform
+ * @param visitor handling each {@link Font.Glyph} and perhaps its {@link OutlineShape} in font em-size [0..1] and the given {@link AffineTransform}
+ * @param transform optional given transform for size and position
* @param font the target {@link Font}
* @param string string text
* @param temp1 temporary AffineTransform storage, mandatory
* @param temp2 temporary AffineTransform storage, mandatory
* @return the bounding box of the given string by taking each glyph's font em-sized [0..1] {@link OutlineShape} into account.
+ * @see #processString(GlyphVisitor, AffineTransform, CharSequence)
*/
- AABBox processString(final OutlineShape.Visitor visitor, final AffineTransform transform,
+ AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform,
final CharSequence string,
final AffineTransform temp1, final AffineTransform temp2);
/**
- * Visit each {@link Glyph}'s {@link OutlineShape} of the string with the constrained {@link OutlineShape.Visitor2}.
+ * Visit each {@link Glyph} and perhaps its {@link OutlineShape} of the string with the constrained {@link Font.GlyphVisitor2}.
* <p>
* The processed shapes are in font em-size [0..1].
* </p>
- * @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