mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 11:44:51 +08:00
handle type 1 font with no descriptor information #132
though required by the spec an adobe type 1 font may be missing all width data. in this case we default to empty values and treat it like a normal adobe type 1 font.
This commit is contained in:
@@ -48,16 +48,30 @@
|
|||||||
|
|
||||||
var metrics = Standard14.GetAdobeFontMetrics(standard14Name.Data);
|
var metrics = Standard14.GetAdobeFontMetrics(standard14Name.Data);
|
||||||
|
|
||||||
|
if (metrics != null)
|
||||||
|
{
|
||||||
var overrideEncoding = encodingReader.Read(dictionary, isLenientParsing);
|
var overrideEncoding = encodingReader.Read(dictionary, isLenientParsing);
|
||||||
|
|
||||||
return new Type1Standard14Font(metrics, overrideEncoding);
|
return new Type1Standard14Font(metrics, overrideEncoding);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var firstCharacter = FontDictionaryAccessHelper.GetFirstCharacter(dictionary);
|
int firstCharacter, lastCharacter;
|
||||||
|
double[] widths;
|
||||||
|
if (!usingStandard14Only)
|
||||||
|
{
|
||||||
|
firstCharacter = FontDictionaryAccessHelper.GetFirstCharacter(dictionary);
|
||||||
|
|
||||||
var lastCharacter = FontDictionaryAccessHelper.GetLastCharacter(dictionary);
|
lastCharacter = FontDictionaryAccessHelper.GetLastCharacter(dictionary);
|
||||||
|
|
||||||
var widths = FontDictionaryAccessHelper.GetWidths(pdfScanner, dictionary, isLenientParsing);
|
widths = FontDictionaryAccessHelper.GetWidths(pdfScanner, dictionary, isLenientParsing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstCharacter = 0;
|
||||||
|
lastCharacter = 0;
|
||||||
|
widths = EmptyArray<double>.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dictionary.TryGet(NameToken.FontDescriptor, out var _))
|
if (!dictionary.TryGet(NameToken.FontDescriptor, out var _))
|
||||||
{
|
{
|
||||||
@@ -105,7 +119,7 @@
|
|||||||
|
|
||||||
if (encoding == null)
|
if (encoding == null)
|
||||||
{
|
{
|
||||||
font?.Match(x => encoding = new BuiltInEncoding(x.Encoding), _ => {});
|
font?.Match(x => encoding = new BuiltInEncoding(x.Encoding), _ => { });
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Type1FontSimple(name, firstCharacter, lastCharacter, widths, descriptor, encoding, toUnicodeCMap, font);
|
return new Type1FontSimple(name, firstCharacter, lastCharacter, widths, descriptor, encoding, toUnicodeCMap, font);
|
||||||
|
Reference in New Issue
Block a user