mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
add support for fonts which use the standard 14 fonts but also provide an encoding
This commit is contained in:
@@ -65,6 +65,19 @@
|
||||
|
||||
var widths = FontDictionaryAccessHelper.GetWidths(pdfScanner, dictionary, isLenientParsing);
|
||||
|
||||
if (!dictionary.TryGet(NameToken.FontDescriptor, out var _))
|
||||
{
|
||||
if (dictionary.TryGet(NameToken.BaseFont, out var baseFontToken) &&
|
||||
DirectObjectFinder.TryGet(baseFontToken, pdfScanner, out NameToken baseFontName))
|
||||
{
|
||||
var metrics = Standard14.GetAdobeFontMetrics(baseFontName.Data);
|
||||
|
||||
var overrideEncoding = encodingReader.Read(dictionary, isLenientParsing);
|
||||
|
||||
return new Type1Standard14Font(metrics, overrideEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
var descriptor = FontDictionaryAccessHelper.GetFontDescriptor(pdfScanner, fontDescriptorFactory, dictionary, isLenientParsing);
|
||||
|
||||
var font = ParseFontProgram(descriptor, isLenientParsing);
|
||||
|
@@ -7,6 +7,9 @@
|
||||
using IO;
|
||||
using Tokens;
|
||||
|
||||
/// <summary>
|
||||
/// A font using one of the Adobe Standard 14 fonts. Can use a custom encoding.
|
||||
/// </summary>
|
||||
internal class Type1Standard14Font: IFont
|
||||
{
|
||||
private readonly FontMetrics standardFontMetrics;
|
||||
@@ -17,10 +20,10 @@
|
||||
|
||||
private readonly TransformationMatrix fontMatrix = TransformationMatrix.FromValues(0.001m, 0, 0, 0.001m, 0, 0);
|
||||
|
||||
public Type1Standard14Font(FontMetrics standardFontMetrics)
|
||||
public Type1Standard14Font(FontMetrics standardFontMetrics, Encoding overrideEncoding = null)
|
||||
{
|
||||
this.standardFontMetrics = standardFontMetrics ?? throw new ArgumentNullException(nameof(standardFontMetrics));
|
||||
encoding = new AdobeFontMetricsEncoding(standardFontMetrics);
|
||||
encoding = overrideEncoding ?? new AdobeFontMetricsEncoding(standardFontMetrics);
|
||||
|
||||
Name = NameToken.Create(standardFontMetrics.FontName);
|
||||
|
||||
|
Reference in New Issue
Block a user