diff options
author | Sven Göthel <[email protected]> | 2024-02-02 23:56:12 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-03 02:28:12 +0100 |
commit | 6c84171b109fb2de8400e20cab191e5801f3e6c6 (patch) | |
tree | 037e8ab92eba2b45b1a0638bff505b65ce2c8478 | |
parent | 237de4e4c7e403c4bf0b014399e28b2f16d06df7 (diff) |
Hausmacher Merge: Complete merge part-1: Compile and test clean (pre-write-feature)
Bernhard Haumacher provided changes in May 2020 to the typecast project within his public branch https://github.com/haumacher/typecast
This merges the pre-write-feature work, which probably is incomplete.
3 files changed, 32 insertions, 28 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 dc1e459f0..fa98ccae7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java @@ -52,6 +52,7 @@ public abstract class OTFont { private final PostTable _post; private final VheaTable _vhea; private final GsubTable _gsub; + private final TableDirectory _tableDirectory; /** * @param dis input stream marked at start with read-ahead set to known stream length @@ -66,6 +67,8 @@ public abstract class OTFont { * @throws java.io.IOException */ OTFont(final DataInputStream dis, final TableDirectory tableDirectory, final int tablesOrigin) throws IOException { + _tableDirectory = tableDirectory; + // Load some prerequisite tables // (These are tables that are referenced by other tables, so we need to load // them first) 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 ee3e46000..2650ab308 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/TTFont.java @@ -34,16 +34,17 @@ import jogamp.graph.font.typecast.ot.table.KernTable; import jogamp.graph.font.typecast.ot.table.LocaTable; import jogamp.graph.font.typecast.ot.table.SVGTable; 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 { private final GlyfTable _glyf; - private GaspTable _gasp; - private KernTable _kern; - private HdmxTable _hdmx; - private VdmxTable _vdmx; - private SVGTable _svg; + private final GaspTable _gasp; + private final KernTable _kern; + private final HdmxTable _hdmx; + private final VdmxTable _vdmx; + private final SVGTable _svg; private static TableDirectory readTableDir(final DataInputStream dis, final int directoryOffset) throws IOException { // Load the table directory @@ -118,42 +119,50 @@ public class TTFont extends OTFont { // 'loca' is required by 'glyf' 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); if (length > 0) { 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(dis, tablesOrigin, Table.glyf); + length = seekTable(tableDirectory, dis, tablesOrigin, Table.glyf); _glyf = new GlyfTable(dis, length, this.getMaxpTable(), loca); + } else { + _glyf = null; } - length = seekTable(dis, tablesOrigin, Table.svg); + length = seekTable(tableDirectory, dis, tablesOrigin, Table.svg); if (length > 0) { _svg = new SVGTable(dis); + } else { + _svg = null; } - length = seekTable(dis, tablesOrigin, Table.gasp); + length = seekTable(tableDirectory, dis, tablesOrigin, Table.gasp); if (length > 0) { _gasp = new GaspTable(dis); + } else { + _gasp = null; } - length = seekTable(dis, tablesOrigin, Table.kern); + length = seekTable(tableDirectory, dis, tablesOrigin, Table.kern); if (length > 0) { _kern = new KernTable(dis); + } else { + _kern = null; } - length = seekTable(dis, tablesOrigin, Table.hdmx); + length = seekTable(tableDirectory, dis, tablesOrigin, Table.hdmx); if (length > 0) { _hdmx = new HdmxTable(dis, length, this.getMaxpTable()); + } else { + _hdmx = null; } - length = seekTable(dis, tablesOrigin, Table.VDMX); + length = seekTable(tableDirectory, dis, tablesOrigin, Table.VDMX); if (length > 0) { _vdmx = new VdmxTable(dis); + } else { + _vdmx = null; } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java index a03c9204c..4398a6cbe 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java @@ -150,12 +150,12 @@ public class HeadTable implements Table { /** * @see #getFlags() */ - private short _flags; + private int _flags; /** * @see #getUnitsPerEm() */ - private short _unitsPerEm; + private int _unitsPerEm; /** * @see #getCreated() @@ -221,7 +221,7 @@ public class HeadTable implements Table { _fontRevision = di.readInt(); _checkSumAdjustment = di.readInt(); _magicNumber = di.readInt(); - _flags = di.readShort(); + _flags = di.readUnsignedShort(); _unitsPerEm = di.readUnsignedShort(); _created = di.readLong(); _modified = di.readLong(); @@ -272,14 +272,6 @@ public class HeadTable implements Table { return _majorVersion + "." + _minorVersion; } - public long getCreated() { - return _created; - } - - public short getFlags() { - return _flags; - } - /** * Fixed Set by font manufacturer. * @@ -369,7 +361,7 @@ public class HeadTable implements Table { * general information on OpenType Font Variations, see the chapter, * OpenType Font Variations Overview. */ - public short getFlags() { + public int getFlags() { return _flags; } @@ -396,7 +388,7 @@ public class HeadTable implements Table { * fonts that have TrueType outlines, a power of 2 is recommended as this * allows performance optimizations in some rasterizers. */ - public short getUnitsPerEm() { + public int getUnitsPerEm() { return _unitsPerEm; } |