mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 02:37:56 +08:00
make compact font format parser thread safe
the individual cff parser uses a cff dictionary reader inside it which has a per-instance operands list, for this reason it is not thread-safe and cannot be shared. this change creates a new individual font parser for each call to the top-level cff parser.
This commit is contained in:
@@ -13,9 +13,6 @@
|
||||
private const string TagOtto = "OTTO";
|
||||
private const string TagTtcf = "ttcf";
|
||||
private const string TagTtfonly = "\u0000\u0001\u0000\u0000";
|
||||
|
||||
private static readonly CompactFontFormatIndividualFontParser IndividualFontParser = new CompactFontFormatIndividualFontParser(
|
||||
new CompactFontFormatTopLevelDictionaryReader(), new CompactFontFormatPrivateDictionaryReader());
|
||||
|
||||
/// <summary>
|
||||
/// Read the Compact Font Format font from the input data.
|
||||
@@ -50,11 +47,13 @@
|
||||
|
||||
var fonts = new Dictionary<string, CompactFontFormatFont>();
|
||||
|
||||
var individualFontParser = new CompactFontFormatIndividualFontParser(new CompactFontFormatTopLevelDictionaryReader(), new CompactFontFormatPrivateDictionaryReader());
|
||||
|
||||
for (var i = 0; i < fontNames.Length; i++)
|
||||
{
|
||||
var fontName = fontNames[i];
|
||||
|
||||
fonts[fontName] = IndividualFontParser.Parse(data, fontName, topLevelDictionaryIndex[i], stringIndex, globalSubroutineIndex);
|
||||
fonts[fontName] = individualFontParser.Parse(data, fontName, topLevelDictionaryIndex[i], stringIndex, globalSubroutineIndex);
|
||||
}
|
||||
|
||||
return new CompactFontFormatFontCollection(header, fonts);
|
||||
|
Reference in New Issue
Block a user