handle null name in tounicode cmap, handle indirect reference in widths array for cid font and handle empty data for private dictionary in compact font format

This commit is contained in:
Eliot Jones
2019-05-11 10:00:04 +01:00
parent 03af28ed6d
commit 7d9bd46437
3 changed files with 9 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Util;
/// <summary>
/// Provides access to the raw bytes of this Compact Font Format file with utility methods for reading data types from it.
@@ -112,6 +113,11 @@
public CompactFontFormatData SnapshotPortion(int startLocation, int length)
{
if (length == 0)
{
return new CompactFontFormatData(EmptyArray<byte>.Instance);
}
if (startLocation > dataBytes.Count - 1 || startLocation + length > dataBytes.Count)
{
throw new ArgumentException($"Attempted to create a snapshot of an invalid portion of the data. Length was {dataBytes.Count}, requested start: {startLocation} and requested length: {length}.");

View File

@@ -31,7 +31,7 @@
if (CanMapToUnicode)
{
IsUsingIdentityAsUnicodeMap =
cMap.Name.StartsWith("Identity-", StringComparison.InvariantCultureIgnoreCase);
cMap.Name?.StartsWith("Identity-", StringComparison.InvariantCultureIgnoreCase) == true;
}
}

View File

@@ -151,7 +151,7 @@
}
}
private static IReadOnlyDictionary<int, decimal> ReadWidths(DictionaryToken dict)
private IReadOnlyDictionary<int, decimal> ReadWidths(DictionaryToken dict)
{
var widths = new Dictionary<int, decimal>();
@@ -166,7 +166,7 @@
{
var firstCode = (NumericToken)widthArray.Data[counter++];
var next = widthArray.Data[counter++];
if (next is ArrayToken array)
if (DirectObjectFinder.TryGet(next, pdfScanner, out ArrayToken array))
{
int startRange = firstCode.Int;
int arraySize = array.Data.Count;