re-use truetype parser for opentype cid fonts

This commit is contained in:
Eliot Jones 2020-06-20 12:46:41 +01:00
parent 79dea8d314
commit 982c331935

View File

@ -114,9 +114,11 @@
switch (descriptor.FontFile.FileType)
{
case DescriptorFontFile.FontFileType.TrueType:
{
var input = new TrueTypeDataBytes(new ByteArrayInputBytes(fontFile));
var ttf = TrueTypeFontParser.Parse(input);
return new PdfCidTrueTypeFont(ttf);
}
case DescriptorFontFile.FontFileType.FromSubtype:
{
if (!DirectObjectFinder.TryGet(descriptor.FontFile.ObjectKey, pdfScanner, out StreamToken str))
@ -139,14 +141,12 @@
if (subtypeName == NameToken.OpenType)
{
var bytes = str.Decode(filterProvider);
var ttf = TrueTypeFontParser.Parse(new TrueTypeDataBytes(new ByteArrayInputBytes(bytes)));
return new PdfCidTrueTypeFont(ttf);
}
else
{
throw new PdfDocumentFormatException($"Unexpected subtype for CID font: {subtypeName}.");
}
throw new NotSupportedException($"Cannot read CID font from subtype: {subtypeName}.");
throw new PdfDocumentFormatException($"Unexpected subtype for CID font: {subtypeName}.");
}
default:
throw new NotSupportedException("Currently only TrueType fonts are supported.");