aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/font
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/jogamp/graph/font
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/jogamp/graph/font')
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java16
1 files changed, 9 insertions, 7 deletions
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);
}