add index to location table and remove old version of opencover from the tools folder

This commit is contained in:
Eliot Jones
2017-12-05 23:59:41 +00:00
parent 2dc7e78d2e
commit 7a0c4aaf9f
23 changed files with 36 additions and 594 deletions

View File

@@ -86,6 +86,9 @@
{
throw new InvalidOperationException("The location to index table is required for non-PostScript fonts.");
}
var indexToLocationTable =
IndexToLocationTable.Load(data, indexToLocationHeaderTable, header, maximumProfile);
}
return new TrueTypeFont(version, header);

View File

@@ -1,5 +1,7 @@
namespace UglyToad.Pdf.Fonts.TrueType.Tables
{
using System;
/// <summary>
/// Stores the offset to the glyph locations relative to the start of the glyph data table.
/// Index zero points to the "missing character" which is used for characters not provided by the font.
@@ -11,6 +13,9 @@
public TrueTypeHeaderTable DirectoryTable { get; }
/// <summary>
/// The glyph offsets relative to the start of the glyph data table.
/// </summary>
public long[] GlyphOffsets { get; }
public IndexToLocationTable(TrueTypeHeaderTable directoryTable, long[] glyphOffsets)
@@ -19,11 +24,37 @@
GlyphOffsets = glyphOffsets;
}
public static IndexToLocationTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table)
public static IndexToLocationTable Load(TrueTypeDataBytes data, TrueTypeHeaderTable table, HeaderTable headerTable, BasicMaximumProfileTable maximumProfileTable)
{
const short shortFormat = 0;
const short longFormat = 1;
data.Seek(table.Offset);
return null;
var format = headerTable.IndexToLocFormat;
var glyphCount = maximumProfileTable.NumberOfGlyphs;
var offsets = new long[glyphCount];
for (int i = 0; i < glyphCount; i++)
{
switch (format)
{
case shortFormat:
// The local offset divided by 2 is stored.
offsets[i] = data.ReadUnsignedShort() * 2;
break;
case longFormat:
// The actual offset is stored.
offsets[i] = data.ReadLong();
break;
default:
throw new InvalidOperationException($"The format {format} was invalid for the index to location (loca) table.");
}
}
return new IndexToLocationTable(table, offsets);
}
}
}