aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-26 04:53:06 +0200
committerSven Gothel <[email protected]>2023-09-26 04:53:06 +0200
commit949558bc0bcd10a24293b5880c90940008d0118a (patch)
tree9cf8ca77be2948062ff2232e58d206bdbdd5b3b7 /src/jogl/classes
parent5f876580500471531dc6973eda7eb4d9878b871d (diff)
Bug 1463 - Graph Font: Whitespace or undefined Glyphs shall not cover (any) height exceeding overall CharSequence
TypecastFont using `metrics.getAscentFU() - metrics.getDescentFU()` for ascent used for all undefined and whitespace Glyphs w/o a spatial outline, leads to a potential exceeding height compared to the actual used bounding box of the rendered text. This in turn leads to layout issues, e.g. button labels are placed too low. Solution: - Whitespace/Undefined: Drop full height 'metrics.getAscentFU() - metrics.getDescentFU()', b/c of non-existing shape height. - Otherwise, layout on AABBox or created empty shape would pick up such default hhea-table ascent which might exceed actual string height. Sideeffect would be if user relies on height of a whitespace. However, knowing this fact - a user may always pick the hhea-table's ascent metric values as exposed in Font and Font.Metric. This resolves remaining layout issues, including button labels.
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index e8c6a4ed8..c60629582 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -307,7 +307,9 @@ class TypecastFont implements Font {
}
final jogamp.graph.font.typecast.ot.Glyph glyph = font.getGlyph(key.id);
final boolean isUndefined = Glyph.ID_UNKNOWN == key.id || TypecastGlyph.isUndefName(key.name);
- final int glyph_height = metrics.getAscentFU() - metrics.getDescentFU();
+ // Whitespace/Undefined: Drop full height 'metrics.getAscentFU() - metrics.getDescentFU()', b/c of non-existing shape height.
+ // Otherwise, layout on AABBox or created empty shape would pick up such default hhea-table ascent which might exceed actual string height.
+ final int whitespace_ascent = 0;
final int glyph_advance;
final int glyph_leftsidebearings;
final boolean isWhitespace;
@@ -328,7 +330,7 @@ class TypecastFont implements Font {
} else {
// Case 2: Non-contour glyph -> whitespace or undefined
isWhitespace = !isUndefined;
- glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f);
+ glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, whitespace_ascent, 0f);
shape = Glyph.ID_UNKNOWN == key.id ? TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox) : null;
mode = 2;
}
@@ -337,7 +339,7 @@ class TypecastFont implements Font {
glyph_advance = getAdvanceWidthFU(key.id);
glyph_leftsidebearings = 0;
isWhitespace = !isUndefined;
- glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f);
+ glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, whitespace_ascent, 0f);
shape = Glyph.ID_UNKNOWN == key.id ? TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox) : null;
mode = 3;
}
@@ -513,6 +515,7 @@ class TypecastFont implements Font {
float advanceTotal = 0;
Font.Glyph left_glyph = null;
final AABBox temp_box = new AABBox();
+ final AABBox temp_box2 = new AABBox();
for(int i=0; i< charCount; i++) {
final char codepoint = string.charAt(i);
@@ -536,7 +539,7 @@ class TypecastFont implements Font {
// break kerning, but include its bounding box space and visit the visitor
left_glyph = null;
temp1.translate(advanceTotal, y, temp2);
- res.resize(temp1.transform(glyph.getBounds(), temp_box));
+ res.resize(temp1.transform(glyph.getBounds(temp_box2), temp_box));
visitor.visit(glyph, temp1);
advanceTotal += glyph.getAdvanceWidth();
} else {