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:
Eliot Jones
2020-02-05 10:46:39 +00:00
parent 10ca77a034
commit 40dc80c281

View File

@@ -48,16 +48,30 @@
var metrics = Standard14.GetAdobeFontMetrics(standard14Name.Data);
if (metrics != null)
{
var overrideEncoding = encodingReader.Read(dictionary, isLenientParsing);
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 _))
{
@@ -105,7 +119,7 @@
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);