summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/font
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-02-19 17:35:53 +0100
committerSven Gothel <[email protected]>2023-02-19 17:35:53 +0100
commit2a6f255ff65bc499ae53da96f5b43a4e4c525861 (patch)
tree420cb154f4ad03430746116226b3077e0fc94a05 /src/jogl/classes/jogamp/graph/font
parent60827d6df7c99f77ab95e25a6e94da74ccb1e2b6 (diff)
Graph TypecastFont: Add hashCode() and equals(), feed TypecastGlyph w/ LeftSideBearings
Diffstat (limited to 'src/jogl/classes/jogamp/graph/font')
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 2cf9b2514..53eee2c3a 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -30,7 +30,6 @@ package jogamp.graph.font.typecast;
import jogamp.graph.font.typecast.ot.OTFontCollection;
import jogamp.graph.font.typecast.ot.TTFont;
import jogamp.graph.font.typecast.ot.table.CmapFormat;
-import jogamp.graph.font.typecast.ot.table.CmapIndexEntry;
import jogamp.graph.font.typecast.ot.table.CmapTable;
import jogamp.graph.font.typecast.ot.table.GlyfDescript;
import jogamp.graph.font.typecast.ot.table.GlyfTable;
@@ -134,7 +133,7 @@ class TypecastFont implements Font {
final Glyph g = getGlyph(i);
final GlyfDescript gd = glyfTable.getDescription(i);
System.err.println("Index "+i);
- System.err.println(" hmtx aw "+hmtx.getAdvanceWidth(i)+" / "+getAdvanceWidthFU(i)+" (glyph "+g.getAdvanceFU()+"), lsb "+hmtx.getLeftSideBearing(i)+")");
+ System.err.println(" hmtx aw "+hmtx.getAdvanceWidth(i)+", lsb "+hmtx.getLeftSideBearing(i));
System.err.println(" hhea aw-max "+hhea.getAdvanceWidthMax()+", x-max "+hhea.getXMaxExtent());
if( null != gd ) {
System.err.println(" gdesc idx "+gd.getGlyphIndex()+", isComp "+gd.isComposite()+", contours "+gd.getContourCount()+", points "+gd.getPointCount());
@@ -201,15 +200,18 @@ class TypecastFont implements Font {
final String glyph_name = null != post ? post.getGlyphName(glyph_id) : "";
final int glyph_advance;
+ final int glyph_leftsidebearings;
final AABBox glyph_bbox;
final OutlineShape shape;
if( null != glyph ) {
glyph_advance = glyph.getAdvanceWidth();
+ glyph_leftsidebearings = glyph.getLeftSideBearing();
glyph_bbox = glyph.getBBox();
shape = TypecastRenderer.buildShape(metrics.getUnitsPerEM(), glyph, vertexFactory);
} else {
final int glyph_height = metrics.getAscentFU() - metrics.getDescentFU();
glyph_advance = getAdvanceWidthFU(glyph_id);
+ glyph_leftsidebearings = 0;
glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f);
shape = null;
}
@@ -220,7 +222,7 @@ class TypecastFont implements Font {
kernSub = kern.getSubtable0();
}
}
- result = new TypecastGlyph(this, glyph_id, glyph_name, glyph_bbox, glyph_advance, kernSub, shape);
+ result = new TypecastGlyph(this, glyph_id, glyph_name, glyph_bbox, glyph_advance, glyph_leftsidebearings, kernSub, shape);
if(DEBUG) {
System.err.println("New glyph: " + glyph_id + "/'"+glyph_name+"', shape " + (null != shape));
System.err.println(" tc_glyph "+glyph);
@@ -422,6 +424,21 @@ class TypecastFont implements Font {
}
@Override
+ public final int hashCode() {
+ return font.getName(Font.NAME_UNIQUNAME).hashCode();
+ }
+
+ @Override
+ public final boolean equals(final Object o) {
+ if( this == o ) { return true; }
+ if( o instanceof TypecastFont ) {
+ final TypecastFont of = (TypecastFont)o;
+ return of.font.getName(Font.NAME_UNIQUNAME).equals(font.getName(Font.NAME_UNIQUNAME));
+ }
+ return false;
+ }
+
+ @Override
public String toString() {
return getFullFamilyName();
}