예제 #1
0
        private static IReadOnlyList <(int, string)> ProcessDifferences(ArrayToken differenceArray)
        {
            var differences = new List <(int, string)>();

            if (differenceArray.Length == 0)
            {
                return(differences);
            }

            var activeCode = differenceArray.GetNumeric(0).Int;

            for (int i = 1; i < differenceArray.Data.Count; i++)
            {
                var entry = differenceArray.Data[i];

                if (entry is NumericToken numeric)
                {
                    activeCode = numeric.Int;
                }
                else if (entry is NameToken name)
                {
                    differences.Add((activeCode, name.Data));
                    activeCode++;
                }
                else
                {
                    throw new InvalidFontFormatException($"Unexpected entry in the differences array: {differenceArray}.");
                }
            }

            return(differences);
        }
예제 #2
0
        public static PdfRectangle ToIntRectangle(this ArrayToken array)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            if (array.Data.Count != 4)
            {
                throw new PdfDocumentFormatException($"Cannot convert array to rectangle, expected 4 values instead got: {array}.");
            }

            return(new PdfRectangle(array.GetNumeric(0).Int,
                                    array.GetNumeric(1).Int,
                                    array.GetNumeric(2).Int,
                                    array.GetNumeric(3).Int));
        }