diff options
author | Sven Göthel <[email protected]> | 2024-02-02 23:56:12 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-02 23:56:12 +0100 |
commit | fd088fbb47f1d08b5cb4c2cec4d66d87c52b6b9c (patch) | |
tree | 6bbcc54c768482fc3ad4fa69d358bced32afe534 | |
parent | f584e1dcc200b9ca59490227c7280fbd0b40039e (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.
5 files changed, 34 insertions, 32 deletions
diff --git a/src/main/java/net/java/dev/typecast/ot/OTFont.java b/src/main/java/net/java/dev/typecast/ot/OTFont.java index 970a336..241bf55 100644 --- a/src/main/java/net/java/dev/typecast/ot/OTFont.java +++ b/src/main/java/net/java/dev/typecast/ot/OTFont.java @@ -56,6 +56,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 @@ -70,6 +71,8 @@ public abstract class OTFont { * @throws java.io.IOException */ OTFont(final DataInputStream dis, 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/main/java/net/java/dev/typecast/ot/TTFont.java b/src/main/java/net/java/dev/typecast/ot/TTFont.java index 56f102b..a0793e1 100644 --- a/src/main/java/net/java/dev/typecast/ot/TTFont.java +++ b/src/main/java/net/java/dev/typecast/ot/TTFont.java @@ -34,16 +34,17 @@ import net.java.dev.typecast.ot.table.KernTable; import net.java.dev.typecast.ot.table.LocaTable; import net.java.dev.typecast.ot.table.SVGTable; import net.java.dev.typecast.ot.table.Table; +import net.java.dev.typecast.ot.table.TableDirectory; import net.java.dev.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/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java b/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java index c8eca9e..8658334 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java @@ -182,7 +182,6 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { int glyphIndex, short numberOfContours, DataInput di) throws IOException { - _glyphIndex = glyphIndex; _parentTable = parentTable; _glyphIndex = glyphIndex; _numberOfContours = numberOfContours; diff --git a/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java b/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java index 9ebf489..e0a1a12 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java +++ b/src/main/java/net/java/dev/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; } diff --git a/src/test/java/net/java/dev/typecast/ot/TTFontTest.java b/src/test/java/net/java/dev/typecast/ot/TTFontTest.java index f878690..c703b3f 100644 --- a/src/test/java/net/java/dev/typecast/ot/TTFontTest.java +++ b/src/test/java/net/java/dev/typecast/ot/TTFontTest.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.net.URISyntaxException; @@ -78,9 +79,7 @@ public class TTFontTest extends TestCase { private TTFont loadFontResource(String name) throws URISyntaxException, IOException { - URL url = ClassLoader.getSystemResource(name); - TTFont font = loadFont(url); - return font; + return loadFont( ClassLoader.getSystemResource(name) ); } private TTFont loadFont(URL url) throws URISyntaxException, IOException { |