mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 10:55:04 +08:00
support named tounicode cmaps rather than streams type 0 fonts
tounicode cmap may refer to a known cmap name rather than an embedded cmap stream.
This commit is contained in:
@@ -64,13 +64,22 @@
|
|||||||
{
|
{
|
||||||
var toUnicodeValue = dictionary.Data[NameToken.ToUnicode];
|
var toUnicodeValue = dictionary.Data[NameToken.ToUnicode];
|
||||||
|
|
||||||
var toUnicode = DirectObjectFinder.Get<StreamToken>(toUnicodeValue, scanner);
|
if (DirectObjectFinder.TryGet<StreamToken>(toUnicodeValue, scanner, out var toUnicodeStream))
|
||||||
|
|
||||||
var decodedUnicodeCMap = toUnicode?.Decode(filterProvider);
|
|
||||||
|
|
||||||
if (decodedUnicodeCMap != null)
|
|
||||||
{
|
{
|
||||||
toUnicodeCMap = CMapCache.Parse(new ByteArrayInputBytes(decodedUnicodeCMap), isLenientParsing);
|
var decodedUnicodeCMap = toUnicodeStream?.Decode(filterProvider);
|
||||||
|
|
||||||
|
if (decodedUnicodeCMap != null)
|
||||||
|
{
|
||||||
|
toUnicodeCMap = CMapCache.Parse(new ByteArrayInputBytes(decodedUnicodeCMap), isLenientParsing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DirectObjectFinder.TryGet<NameToken>(toUnicodeValue, scanner, out var toUnicodeName))
|
||||||
|
{
|
||||||
|
toUnicodeCMap = CMapCache.Get(toUnicodeName.Data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PdfDocumentFormatException($"Invalid type of toUnicode CMap encountered. Got: {toUnicodeValue}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user