make byte array input bytes behave correctly when seeking rather than forcing the consumer to work around it.

This commit is contained in:
Eliot Jones
2018-01-03 19:17:12 +00:00
parent bfdca3079f
commit 72ffa1f308
7 changed files with 8 additions and 8 deletions

View File

@@ -25,7 +25,7 @@
public static GlyphDataTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table, HeaderTable headerTable, public static GlyphDataTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table, HeaderTable headerTable,
IndexToLocationTable indexToLocationTable) IndexToLocationTable indexToLocationTable)
{ {
data.Seek(table.Offset - 1); data.Seek(table.Offset);
var offsets = indexToLocationTable.GlyphOffsets; var offsets = indexToLocationTable.GlyphOffsets;
@@ -43,7 +43,7 @@
continue; continue;
} }
data.Seek(offsets[i] - 1 + table.Offset); data.Seek(offsets[i] + table.Offset);
var contourCount = data.ReadSignedShort(); var contourCount = data.ReadSignedShort();

View File

@@ -87,7 +87,7 @@
public static HeaderTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table) public static HeaderTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table)
{ {
data.Seek(table.Offset - 1); data.Seek(table.Offset);
var version = data.Read32Fixed(); var version = data.Read32Fixed();
var fontRevision = data.Read32Fixed(); var fontRevision = data.Read32Fixed();
var checkSumAdjustment = data.ReadUnsignedInt(); var checkSumAdjustment = data.ReadUnsignedInt();

View File

@@ -99,7 +99,7 @@
public static HorizontalHeaderTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table) public static HorizontalHeaderTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table)
{ {
data.Seek(table.Offset - 1); data.Seek(table.Offset);
var majorVersion = data.ReadUnsignedShort(); var majorVersion = data.ReadUnsignedShort();
var minorVersion = data.ReadUnsignedShort(); var minorVersion = data.ReadUnsignedShort();

View File

@@ -29,7 +29,7 @@
const short shortFormat = 0; const short shortFormat = 0;
const short longFormat = 1; const short longFormat = 1;
data.Seek(table.Offset - 1); data.Seek(table.Offset);
var format = headerTable.IndexToLocFormat; var format = headerTable.IndexToLocFormat;

View File

@@ -32,7 +32,7 @@
public static BasicMaximumProfileTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table) public static BasicMaximumProfileTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table)
{ {
data.Seek(table.Offset - 1); data.Seek(table.Offset);
var version = data.Read32Fixed(); var version = data.Read32Fixed();
var numberOfGlyphs = data.ReadUnsignedShort(); var numberOfGlyphs = data.ReadUnsignedShort();

View File

@@ -81,7 +81,7 @@
public static PostScriptTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table, BasicMaximumProfileTable maximumProfileTable) public static PostScriptTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table, BasicMaximumProfileTable maximumProfileTable)
{ {
data.Seek(table.Offset - 1); data.Seek(table.Offset);
var formatType = data.Read32Fixed(); var formatType = data.Read32Fixed();
var italicAngle = data.Read32Fixed(); var italicAngle = data.Read32Fixed();
var underlinePosition = data.ReadSignedShort(); var underlinePosition = data.ReadSignedShort();

View File

@@ -45,7 +45,7 @@
public void Seek(long position) public void Seek(long position)
{ {
CurrentOffset = (int)position; CurrentOffset = (int)position - 1;
CurrentByte = CurrentOffset < 0 ? (byte)0 : bytes[CurrentOffset]; CurrentByte = CurrentOffset < 0 ? (byte)0 : bytes[CurrentOffset];
} }
} }