mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 19:07:56 +08:00
improve performance of the truetype name table parsing
This commit is contained in:
@@ -4,26 +4,24 @@
|
||||
{
|
||||
public TrueTypePlatformIdentifier PlatformId { get; }
|
||||
|
||||
public int PlatformEncodingId { get; }
|
||||
public ushort PlatformEncodingId { get; }
|
||||
|
||||
public int LanguageId { get; }
|
||||
public ushort LanguageId { get; }
|
||||
|
||||
public int NameId { get; }
|
||||
|
||||
public int Length { get; }
|
||||
|
||||
public int Offset { get; }
|
||||
public ushort NameId { get; }
|
||||
|
||||
public string Value { get; }
|
||||
|
||||
public TrueTypeNameRecord(TrueTypePlatformIdentifier platformId, int platformEncodingId, int languageId, int nameId, int length, int offset, string value)
|
||||
public TrueTypeNameRecord(TrueTypePlatformIdentifier platformId,
|
||||
ushort platformEncodingId,
|
||||
ushort languageId,
|
||||
ushort nameId,
|
||||
string value)
|
||||
{
|
||||
PlatformId = platformId;
|
||||
PlatformEncodingId = platformEncodingId;
|
||||
LanguageId = languageId;
|
||||
NameId = nameId;
|
||||
Length = length;
|
||||
Offset = offset;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
|
@@ -111,17 +111,20 @@
|
||||
{
|
||||
public TrueTypePlatformIdentifier PlatformId { get; }
|
||||
|
||||
public int PlatformEncodingId { get; }
|
||||
public ushort PlatformEncodingId { get; }
|
||||
|
||||
private int LanguageId { get; }
|
||||
private ushort LanguageId { get; }
|
||||
|
||||
private int NameId { get; }
|
||||
private ushort NameId { get; }
|
||||
|
||||
public int Length { get; }
|
||||
public ushort Length { get; }
|
||||
|
||||
public int Offset { get; }
|
||||
public ushort Offset { get; }
|
||||
|
||||
private NameRecordBuilder(int platformId, int platformEncodingId, int languageId, int nameId, int length, int offset)
|
||||
private NameRecordBuilder(ushort platformId, ushort platformEncodingId, ushort languageId,
|
||||
ushort nameId,
|
||||
ushort length,
|
||||
ushort offset)
|
||||
{
|
||||
PlatformId = (TrueTypePlatformIdentifier)platformId;
|
||||
PlatformEncodingId = platformEncodingId;
|
||||
@@ -134,7 +137,7 @@
|
||||
public TrueTypeNameRecord ToNameRecord(string s)
|
||||
{
|
||||
return new TrueTypeNameRecord(PlatformId, PlatformEncodingId,
|
||||
LanguageId, NameId, Length, Offset, s);
|
||||
LanguageId, NameId, s);
|
||||
}
|
||||
|
||||
public static NameRecordBuilder Read(TrueTypeDataBytes data)
|
||||
|
@@ -41,17 +41,11 @@
|
||||
|
||||
private void ReadBuffered(byte[] buffer, int length)
|
||||
{
|
||||
var numberRead = 0;
|
||||
while (numberRead < length)
|
||||
{
|
||||
if (!inputBytes.MoveNext())
|
||||
var read = inputBytes.Read(buffer, length);
|
||||
if (read < length)
|
||||
{
|
||||
throw new EndOfStreamException($"Could not read a buffer of {length} bytes.");
|
||||
}
|
||||
|
||||
buffer[numberRead] = inputBytes.CurrentByte;
|
||||
numberRead++;
|
||||
}
|
||||
}
|
||||
|
||||
public byte ReadByte()
|
||||
|
Reference in New Issue
Block a user