diff options
author | Bernhard Haumacher <[email protected]> | 2020-05-10 12:41:31 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-03 01:59:52 +0100 |
commit | 5f2f0905a41d7f0477a1561243c61489066e9de4 (patch) | |
tree | bad16e259ff5ca155fa66ac36dcd6ea8d7d980ca /src | |
parent | 8f0c4a6b250a2afa4d5145bee39adbf443dfcbd8 (diff) |
Added offset table as member to the font.
* Include the offset table in the font's dump.
* Simplified reading since the offset table now does not be read twice.
# Conflicts:
# src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java
# src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java
Diffstat (limited to 'src')
5 files changed, 52 insertions, 17 deletions
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java index a2e9e7a19..dc1e459f0 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java @@ -54,11 +54,16 @@ public abstract class OTFont { private final GsubTable _gsub; /** - * * @param dis input stream marked at start with read-ahead set to known stream length - * @param tableDirectory - * @param tablesOrigin - * @throws IOException + * @param directoryOffset The Table Directory offset within the file. For a + * regular TTF/OTF file this will be zero, but for a TTC (Font Collection) + * the offset is retrieved from the TTC header. For a Mac font resource, + * offset is retrieved from the resource headers. + * @param tablesOrigin The point the table offsets are calculated from. + * Once again, in a regular TTF file, this will be zero. In a TTC is is + * also zero, but within a Mac resource, it is the beginning of the + * individual font resource data. + * @throws java.io.IOException */ OTFont(final DataInputStream dis, final TableDirectory tableDirectory, final int tablesOrigin) throws IOException { // Load some prerequisite tables @@ -99,6 +104,13 @@ public abstract class OTFont { _gsub = null; // FIXME: delete? } + + /** + * {@link TableDirectory} with all font tables. + */ + public TableDirectory getTableDirectory() { + return _tableDirectory; + } public Os2Table getOS2Table() { return _os2; @@ -200,6 +212,9 @@ public abstract class OTFont { * Dumps information of all tables to the given {@link Writer}. */ public void dumpTo(Writer out) throws IOException { + out.write(getTableDirectory().toString()); + out.write("\n"); + dump(out, getHeadTable()); dump(out, getOS2Table()); dump(out, getCmapTable()); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java index 5d091a3c8..90ddda48a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java @@ -33,7 +33,6 @@ import jogamp.graph.font.typecast.ot.table.HdmxTable; import jogamp.graph.font.typecast.ot.table.KernTable; import jogamp.graph.font.typecast.ot.table.LocaTable; import jogamp.graph.font.typecast.ot.table.Table; -import jogamp.graph.font.typecast.ot.table.TableDirectory; import jogamp.graph.font.typecast.ot.table.VdmxTable; public class TTFont extends OTFont { @@ -119,27 +118,31 @@ public class TTFont extends OTFont { int length = seekTable(tableDirectory, dis, tablesOrigin, Table.loca); final LocaTable loca = new LocaTable(dis, length, this.getHeadTable(), this.getMaxpTable()); + // 'loca' is required by 'glyf' + int length = seekTable(dis, tablesOrigin, Table.loca); + LocaTable loca = new LocaTable(dis, length, this.getHeadTable(), this.getMaxpTable()); + // If this is a TrueType outline, then we'll have at least the // 'glyf' table (along with the 'loca' table) - length = seekTable(tableDirectory, dis, tablesOrigin, Table.glyf); + length = seekTable(dis, tablesOrigin, Table.glyf); _glyf = new GlyfTable(dis, length, this.getMaxpTable(), loca); - length = seekTable(tableDirectory, dis, tablesOrigin, Table.gasp); + length = seekTable(dis, tablesOrigin, Table.gasp); if (length > 0) { _gasp = new GaspTable(dis); } - length = seekTable(tableDirectory, dis, tablesOrigin, Table.kern); + length = seekTable(dis, tablesOrigin, Table.kern); if (length > 0) { _kern = new KernTable(dis); } - length = seekTable(tableDirectory, dis, tablesOrigin, Table.hdmx); + length = seekTable(dis, tablesOrigin, Table.hdmx); if (length > 0) { _hdmx = new HdmxTable(dis, length, this.getMaxpTable()); } - length = seekTable(tableDirectory, dis, tablesOrigin, Table.VDMX); + length = seekTable(dis, tablesOrigin, Table.VDMX); if (length > 0) { _vdmx = new VdmxTable(dis); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java index 0eddb3633..317c48d2c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java @@ -182,8 +182,8 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { final int glyphIndex, final short numberOfContours, final DataInput di) throws IOException { - _parentTable = parentTable; _glyphIndex = glyphIndex; + _parentTable = parentTable; _numberOfContours = numberOfContours; _xMin = di.readShort(); _yMin = di.readShort(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java index d1c4fe7dd..5af1df289 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java @@ -152,6 +152,21 @@ public class GlyfTable implements Table { return glyf; } + + /** + * Number of glyphs. + * + * @see #getDescription(int) + */ + public int getNumGlyphs() { + return _descript.length; + } + + /** + * The glyph with the given index. + * + * @see #getNumGlyphs() + */ public GlyfDescript getDescription(final int i) { if (i < _descript.length) { return _descript[i]; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java index 63931286e..cd4b0f462 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java @@ -52,7 +52,9 @@ package jogamp.graph.font.typecast.ot.table; import java.io.DataInput; import java.io.IOException; + import jogamp.graph.font.typecast.ot.Fixed; +import jogamp.graph.font.typecast.ot.Fmt; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> @@ -161,14 +163,14 @@ public class TableDirectory { public String toString() { final StringBuilder sb = new StringBuilder() .append("Offset Table\n------ -----") - .append("\n sfnt version: ").append(Fixed.floatValue(_version)) - .append("\n numTables = ").append(_numTables) - .append("\n searchRange = ").append(_searchRange) - .append("\n entrySelector = ").append(_entrySelector) - .append("\n rangeShift = ").append(_rangeShift) + .append("\n sfnt version: ").append(Fixed.floatValue(_version)) + .append("\n numTables: ").append(_numTables) + .append("\n searchRange: ").append(_searchRange) + .append("\n entrySelector: ").append(_entrySelector) + .append("\n rangeShift: ").append(_rangeShift) .append("\n\n"); for (int i = 0; i < _numTables; i++) { - sb.append(i).append(". ").append(_entries[i].toString()).append("\n"); + sb.append(" ").append(Fmt.pad(2, i)).append(": ").append(_entries[i].toString()).append("\n"); } return sb.toString(); } |