/// <summary>Called when all glyphs in this font face have been loaded up. /// Note that this may occur very late or, more likely never, when glyphs are loaded on demand.</summary> public void AllGlyphsLoaded() { CffParser = null; Parser = null; UnloadedGlyphs = 0; ParserGlyphs = null; }
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); }
public static Glyph[] Load(FontParser parser, int offset, FontFace font) { // Create the parser: CffGlyphParser cffParser = new CffGlyphParser(parser, font); cffParser.FullLoad = Fonts.Preload; font.CffParser = cffParser; // Seek, skipping the 4 byte header: parser.Position = offset + 4; // Skip the name index: SkipIndex(parser); // Top dict index next (one entry only): Dictionary <int, List <int> > topDict = LoadDict(parser); // String index: SkipIndex(parser); // GSubr index: cffParser.GSubrs = LoadSubIndex(parser); // Figure out the bias: cffParser.GsubrsBias = GetBias(cffParser.GSubrs); // Read the private dict next - grab the info about where it is: List <int> privateDictInfo = topDict[18]; // Get it's offset: int privateDictOffset = offset + privateDictInfo[1]; // Seek there: parser.Position = privateDictOffset; // Load: Dictionary <int, List <int> > privateDict = ParseCFFDict(parser, privateDictInfo[0]); // Grab the default values: cffParser.DefaultWidthX = (float)ReadDict(privateDict, 20); cffParser.NominalWidthX = (float)ReadDict(privateDict, 21); // Grab the subrs offset. May be zero (or non-existant): int privateSubrs = ReadDict(privateDict, 19); if (privateSubrs != 0) { // We have a "subroutine" set. Get it's full offset and hop there: parser.Position = privateDictOffset + privateSubrs; // Load the set: cffParser.Subrs = LoadSubIndex(parser); // Figure out the bias/offset: cffParser.SubrsBias = GetBias(cffParser.Subrs); } // Seek to the char string table: parser.Position = offset + ReadDict(topDict, 17); // Time to actually load the actual glyphs, wohoo! O.O return(LoadIndex(parser, cffParser)); }
public static Glyph[] Load(FontParser parser,int offset,FontFace font){ // Create the parser: CffGlyphParser cffParser=new CffGlyphParser(parser,font); cffParser.FullLoad=Fonts.Preload; font.CffParser=cffParser; // Seek, skipping the 4 byte header: parser.Position=offset+4; // Skip the name index: SkipIndex(parser); // Top dict index next (one entry only): Dictionary<int,List<int>> topDict=LoadDict(parser); // String index: SkipIndex(parser); // GSubr index: cffParser.GSubrs=LoadSubIndex(parser); // Figure out the bias: cffParser.GsubrsBias=GetBias(cffParser.GSubrs); // Read the private dict next - grab the info about where it is: List<int> privateDictInfo=topDict[18]; // Get it's offset: int privateDictOffset=offset+privateDictInfo[1]; // Seek there: parser.Position=privateDictOffset; // Load: Dictionary<int,List<int>> privateDict=ParseCFFDict(parser,privateDictInfo[0]); // Grab the default values: cffParser.DefaultWidthX=(float)ReadDict(privateDict,20); cffParser.NominalWidthX=(float)ReadDict(privateDict,21); // Grab the subrs offset. May be zero (or non-existant): int privateSubrs=ReadDict(privateDict,19); if(privateSubrs!=0){ // We have a "subroutine" set. Get it's full offset and hop there: parser.Position=privateDictOffset+privateSubrs; // Load the set: cffParser.Subrs=LoadSubIndex(parser); // Figure out the bias/offset: cffParser.SubrsBias=GetBias(cffParser.Subrs); } // Seek to the char string table: parser.Position=offset+ReadDict(topDict,17); // Time to actually load the actual glyphs, wohoo! O.O return LoadIndex(parser,cffParser); }
//--------------------------------------