aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-01 11:57:47 +0200
committerSven Gothel <[email protected]>2023-09-01 11:57:47 +0200
commitf6dd8e9562d7e0bbf681c268f40ff4c819057915 (patch)
treef5f93b8ec249d42d3c8d0624e3d62f2058e6d058 /src/jogl/classes
parent5d83a6271495fe43141ee2c7f301f16ea0389134 (diff)
Graph Font + Glyph: Fix whitespace definition: Include 'no original underlying shape' and add API doc
Regression was introduced with commit 920e529516bb264f04138ed1caca80d4925e3773 'Robust detetection and API definition of non-contour/whitespace Glyphs'. Issue was mistaken a glyph as undefined if not having an underlying shape, which is true for some fonts (e.g. 'space'). +++ Also Use post table's name if no underlying shape exists.
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java30
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java16
2 files changed, 26 insertions, 20 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index ef1179153..c3c997135 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -176,22 +176,10 @@ public interface Font {
String getName();
/**
- * Return true if the glyph is a whitespace, otherwise false.
- * <p>
- * A whitespace glyph has no {@link #getShape()}, but a valid {@link #getBounds()} and {@link #getAdvance()}.
- * </p>
- * Being a whitespace glyph excludes {@link #isUndefined()}.
- * @see #isUndefined()
- * @see #isNonContour()
- */
- boolean isWhitespace();
-
- /**
- * Return true if the Glyph denotes an undefined {@link #getID()} symbol as follows
+ * Return true if the Glyph denotes an undefined {@link #getID()} symbol, determined as follows
* <ul>
* <li>it's glyph index is {@link #ID_UNKNOWN}, i.e. {@code 0x00}</li>
* <li>has the {@link #getName() name} `.notdef`, `NULL`, `null` or `.null`</li>
- * <li>has no original underlying shape</li>
* </ul>
* <p>
* An undefined glyph has no {@link #getShape()} if glyph index is not {@link #ID_UNKNOWN}.
@@ -206,6 +194,22 @@ public interface Font {
boolean isUndefined();
/**
+ * Return true if the Glyph denotes a whitespace, determined as follows
+ * <ul>
+ * <li>is not {@link #isUndefined()}</li>
+ * <li>has no original underlying shape</li>
+ * <li>has an underlying shape with a zero sized area</li>
+ * </ul>
+ * <p>
+ * A whitespace glyph has no {@link #getShape()}, but a valid {@link #getBounds()} and {@link #getAdvance()}.
+ * </p>
+ * Being a whitespace glyph excludes {@link #isUndefined()}.
+ * @see #isUndefined()
+ * @see #isNonContour()
+ */
+ boolean isWhitespace();
+
+ /**
* Returns true if {@link #isWhitespace()} or {@link #isUndefined()}.
* @see #isWhitespace()
* @see #isUndefined()
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 8bc832633..b153b813e 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -198,19 +198,18 @@ class TypecastFont implements Font {
if (null == result) {
final jogamp.graph.font.typecast.ot.Glyph glyph = font.getGlyph(glyph_id);
final String glyph_name;
- if( null != glyph ) {
+ {
final PostTable post = font.getPostTable();
glyph_name = null != post ? post.getGlyphName(glyph_id) : "";
- } else {
- glyph_name = "";
}
- final boolean isUndefined = Glyph.ID_UNKNOWN == glyph_id || null == glyph || TypecastGlyph.isUndefName(glyph_name);
+ final boolean isUndefined = Glyph.ID_UNKNOWN == glyph_id || TypecastGlyph.isUndefName(glyph_name);
final int glyph_height = metrics.getAscentFU() - metrics.getDescentFU();
final int glyph_advance;
final int glyph_leftsidebearings;
final boolean isWhitespace;
final AABBox glyph_bbox;
final OutlineShape shape;
+ final int mode;
if( null != glyph ) {
glyph_advance = glyph.getAdvanceWidth();
glyph_leftsidebearings = glyph.getLeftSideBearing();
@@ -221,19 +220,22 @@ class TypecastFont implements Font {
isWhitespace = isUndefined ? false : os.getBounds().hasZero2DArea();
glyph_bbox = sb;
shape = ( !isWhitespace && !isUndefined ) || Glyph.ID_UNKNOWN == glyph_id ? os : null;
+ mode = 1;
} else {
// Case 2: Non-contour glyph -> whitespace or undefined
isWhitespace = !isUndefined;
glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f);
shape = Glyph.ID_UNKNOWN == glyph_id ? TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox) : null;
+ mode = 2;
}
} else {
- // Case 3: Non-contour glyph -> undefined
+ // Case 3: Non-contour glyph -> whitespace or undefined
glyph_advance = getAdvanceWidthFU(glyph_id);
glyph_leftsidebearings = 0;
- isWhitespace = false;
+ isWhitespace = !isUndefined;
glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f);
shape = Glyph.ID_UNKNOWN == glyph_id ? TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox) : null;
+ mode = 3;
}
KernSubtable kernSub = null;
{
@@ -245,7 +247,7 @@ class TypecastFont implements Font {
result = new TypecastGlyph(this, glyph_id, glyph_name, glyph_bbox, glyph_advance, glyph_leftsidebearings, kernSub, shape,
isUndefined, isWhitespace);
if( DEBUG || TypecastRenderer.DEBUG ) {
- System.err.println("New glyph: " + glyph_id + "/'"+glyph_name+"', shape " + (null != shape));
+ System.err.println("New glyph: " + glyph_id + "/'"+glyph_name+"', shape " + (null != shape)+", mode "+mode);
System.err.println(" tc_glyph "+glyph);
System.err.println(" glyph "+result);
}