private static Dictionary <int, List <int> > LoadDict(FontParser parser) { // How many are in here? int count = parser.ReadUInt16(); if (count == 0) { return(null); } // Read the offset size: int offsetSize = parser.ReadByte(); // Grab the position: int position = parser.Position; // Find where the data starts: int objectOffset = position + ((count + 1) * offsetSize) - 1; // Read two only: int firstOffset = parser.ReadOffset(offsetSize); int secondOffset = parser.ReadOffset(offsetSize); // Seek to the location: parser.Position = firstOffset + objectOffset; // Parse the dictionary now: Dictionary <int, List <int> > set = ParseCFFDict(parser, secondOffset - firstOffset); // Return: parser.Position = position; // Skip the rest: parser.Position += offsetSize * count; // Read the last offset: secondOffset = parser.ReadOffset(offsetSize); // Seek there, minus one as their not zero based: parser.Position += secondOffset - 1; return(set); }
private static Glyph[] LoadIndex(FontParser parser,CffGlyphParser cffParser){ // Read the index which contains a bunch of char strings. // Each charstring is a postscript glyph definition. // How many are in here? int count=parser.ReadUInt16(); if(count==0){ return null; } // Create the offset set: int[] offsets=new int[count+1]; // Read the offset size: int offsetSize=parser.ReadByte(); // Read each offset: for(int i=0;i<=count;i++){ // Read the current offset: offsets[i]=parser.ReadOffset(offsetSize); } // Grab the object offset, minus one as their not zero based: int objectOffset=parser.Position-1; // Create the glyph set: Glyph[] glyphs=new Glyph[offsets.Length-1]; // For each one.. for(int i=0;i<glyphs.Length;i++){ // Get the (relative) indices: int startIndex=offsets[i]; int length=offsets[i+1]-startIndex; // Load the glyph now, which starts at startIndex+objectOffset: Glyph glyph=cffParser.LoadGlyph(startIndex+objectOffset,length); // Add to the set: glyphs[i]=glyph; } // Seek over the table: parser.Position=objectOffset+offsets[count]; return glyphs; }
private static Glyph[] LoadIndex(FontParser parser, CffGlyphParser cffParser) { // Read the index which contains a bunch of char strings. // Each charstring is a postscript glyph definition. // How many are in here? int count = parser.ReadUInt16(); if (count == 0) { return(null); } // Create the offset set: int[] offsets = new int[count + 1]; // Read the offset size: int offsetSize = parser.ReadByte(); // Read each offset: for (int i = 0; i <= count; i++) { // Read the current offset: offsets[i] = parser.ReadOffset(offsetSize); } // Grab the object offset, minus one as their not zero based: int objectOffset = parser.Position - 1; // Create the glyph set: Glyph[] glyphs = new Glyph[offsets.Length - 1]; // For each one.. for (int i = 0; i < glyphs.Length; i++) { // Get the (relative) indices: int startIndex = offsets[i]; int length = offsets[i + 1] - startIndex; // Load the glyph now, which starts at startIndex+objectOffset: Glyph glyph = cffParser.LoadGlyph(startIndex + objectOffset, length); // Add to the set: glyphs[i] = glyph; } // Seek over the table: parser.Position = objectOffset + offsets[count]; return(glyphs); }
private static CffSubPosition[] LoadSubIndex(FontParser parser) { // How many are in here? int count = parser.ReadUInt16(); if (count == 0) { return(null); } // Create the offset set: int[] offsets = new int[count + 1]; // Read the offset size: int offsetSize = parser.ReadByte(); // Read each offset: for (int i = 0; i <= count; i++) { // Read the current offset: offsets[i] = parser.ReadOffset(offsetSize); } // Minus one as their not zero based: int objectOffset = parser.Position - 1; // Seek over the table: parser.Position = objectOffset + offsets[count]; // Create the result set: CffSubPosition[] results = new CffSubPosition[offsets.Length - 1]; // For each one.. for (int i = 0; i < results.Length; i++) { // Get the (relative) indices: int startIndex = offsets[i]; int length = offsets[i + 1] - startIndex; // Load the glyph now, which starts at startIndex+objectOffset: results[i] = new CffSubPosition(startIndex + objectOffset, length); } return(results); }
private static void SkipIndex(FontParser parser) { // How many are in here? int count = parser.ReadUInt16(); if (count > 0) { // Read the offset size: int offsetSize = parser.ReadByte(); // Skip count offsets: parser.Position += offsetSize * count; // Read the last offset: int lastOffset = parser.ReadOffset(offsetSize); // Seek there, minus one as their not zero based: parser.Position += lastOffset - 1; } }
private static CffSubPosition[] LoadSubIndex(FontParser parser){ // How many are in here? int count=parser.ReadUInt16(); if(count==0){ return null; } // Create the offset set: int[] offsets=new int[count+1]; // Read the offset size: int offsetSize=parser.ReadByte(); // Read each offset: for(int i=0;i<=count;i++){ // Read the current offset: offsets[i]=parser.ReadOffset(offsetSize); } // Minus one as their not zero based: int objectOffset=parser.Position-1; // Seek over the table: parser.Position=objectOffset+offsets[count]; // Create the result set: CffSubPosition[] results=new CffSubPosition[offsets.Length-1]; // For each one.. for(int i=0;i<results.Length;i++){ // Get the (relative) indices: int startIndex=offsets[i]; int length=offsets[i+1]-startIndex; // Load the glyph now, which starts at startIndex+objectOffset: results[i]=new CffSubPosition(startIndex+objectOffset,length); } return results; }
private static Dictionary<int,List<int>> LoadDict(FontParser parser){ // How many are in here? int count=parser.ReadUInt16(); if(count==0){ return null; } // Read the offset size: int offsetSize=parser.ReadByte(); // Grab the position: int position=parser.Position; // Find where the data starts: int objectOffset=position+((count+1)*offsetSize)-1; // Read two only: int firstOffset=parser.ReadOffset(offsetSize); int secondOffset=parser.ReadOffset(offsetSize); // Seek to the location: parser.Position=firstOffset+objectOffset; // Parse the dictionary now: Dictionary<int,List<int>> set=ParseCFFDict(parser,secondOffset-firstOffset); // Return: parser.Position=position; // Skip the rest: parser.Position+=offsetSize*count; // Read the last offset: secondOffset=parser.ReadOffset(offsetSize); // Seek there, minus one as their not zero based: parser.Position+=secondOffset-1; return set; }
private static void SkipIndex(FontParser parser){ // How many are in here? int count=parser.ReadUInt16(); if(count>0){ // Read the offset size: int offsetSize=parser.ReadByte(); // Skip count offsets: parser.Position+=offsetSize*count; // Read the last offset: int lastOffset=parser.ReadOffset(offsetSize); // Seek there, minus one as their not zero based: parser.Position+=lastOffset-1; } }