protected void ReadPrivate(BinaryReaderFont reader) { long start = reader.Position; //Console.WriteLine("private dict: {0}", topDict.Private); privateDict = CFFPrivateDict.Read(reader, (int)topDict.Private.values[0]); //Console.WriteLine("private dict: {0}", privateDict); //reader.Position = position + (int)topDict.Private.values[1]; //CFFIndex index = CFFIndex.Read(reader); //int[] offset = index.offset; //Console.WriteLine("local subr index: {0}", index); if (privateDict.Subrs > 0) { reader.Position = start + (int)privateDict.Subrs; CFFIndex index = CFFIndex.Read(reader); int[] offset = index.ReadAllOffsets(reader); //Console.WriteLine("local subr index: {0}", index); localSubr = new byte[index.count][]; for (int i = 0; i < offset.Length - 1; i++) { int length = offset[i + 1] - offset[i]; localSubr[i] = reader.ReadBytes(length); } } charString.localSubr = localSubr; }
public static CFFPrivateDict Read(BinaryReaderFont reader, int length) { CFFPrivateDict value = new CFFPrivateDict(); long start = reader.Position; List <double> list = new List <double>(); byte key0 = 0; byte key1 = 0; while ((reader.Position - start) < length) { byte n = reader.PeekByte(); if (n <= 21) { key0 = reader.ReadByte(); if (key0 == 12) { key1 = reader.ReadByte(); } value.SetValue(list, key0, key1); key1 = 0; list.Clear(); } else { list.Add(reader.ReadCFFNumber()); } } return(value); }