mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-06-28 15:30:17 +08:00
re-use truetype parser for opentype cid fonts
This commit is contained in:
parent
79dea8d314
commit
982c331935
@ -114,9 +114,11 @@
|
|||||||
switch (descriptor.FontFile.FileType)
|
switch (descriptor.FontFile.FileType)
|
||||||
{
|
{
|
||||||
case DescriptorFontFile.FontFileType.TrueType:
|
case DescriptorFontFile.FontFileType.TrueType:
|
||||||
|
{
|
||||||
var input = new TrueTypeDataBytes(new ByteArrayInputBytes(fontFile));
|
var input = new TrueTypeDataBytes(new ByteArrayInputBytes(fontFile));
|
||||||
var ttf = TrueTypeFontParser.Parse(input);
|
var ttf = TrueTypeFontParser.Parse(input);
|
||||||
return new PdfCidTrueTypeFont(ttf);
|
return new PdfCidTrueTypeFont(ttf);
|
||||||
|
}
|
||||||
case DescriptorFontFile.FontFileType.FromSubtype:
|
case DescriptorFontFile.FontFileType.FromSubtype:
|
||||||
{
|
{
|
||||||
if (!DirectObjectFinder.TryGet(descriptor.FontFile.ObjectKey, pdfScanner, out StreamToken str))
|
if (!DirectObjectFinder.TryGet(descriptor.FontFile.ObjectKey, pdfScanner, out StreamToken str))
|
||||||
@ -139,15 +141,13 @@
|
|||||||
|
|
||||||
if (subtypeName == NameToken.OpenType)
|
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 PdfDocumentFormatException($"Unexpected subtype for CID font: {subtypeName}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotSupportedException($"Cannot read CID font from subtype: {subtypeName}.");
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
throw new NotSupportedException("Currently only TrueType fonts are supported.");
|
throw new NotSupportedException("Currently only TrueType fonts are supported.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user