// constructor public glyf_cache(Table_glyf OwnerTable, OTFont OwnerFont) { m_arrGlyphs = new ArrayList(); // get each glyph from the glyf table for (uint iGlyph = 0; iGlyph < OwnerFont.GetMaxpNumGlyphs(); iGlyph++) { header h = OwnerTable.GetGlyphHeader(iGlyph, OwnerFont); if (h == null) { m_arrGlyphs.Add(null); } else { glyph_base gb = GetGlyphLogicalData(h); m_arrGlyphs.Add(gb); } } }
public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf) { OTTable table = null; string sName = GetUnaliasedTableName(tag); switch (sName) { case "BASE": table = new Table_BASE(tag, buf); break; case "CFF ": table = new Table_CFF(tag, buf); break; case "cmap": table = new Table_cmap(tag, buf); break; case "cvt ": table = new Table_cvt(tag, buf); break; case "DSIG": table = new Table_DSIG(tag, buf); break; case "EBDT": table = new Table_EBDT(tag, buf); break; case "EBLC": table = new Table_EBLC(tag, buf); break; case "EBSC": table = new Table_EBSC(tag, buf); break; case "fpgm": table = new Table_fpgm(tag, buf); break; case "gasp": table = new Table_gasp(tag, buf); break; case "GDEF": table = new Table_GDEF(tag, buf); break; case "glyf": table = new Table_glyf(tag, buf); break; case "GPOS": table = new Table_GPOS(tag, buf); break; case "GSUB": table = new Table_GSUB(tag, buf); break; case "hdmx": table = new Table_hdmx(tag, buf); break; case "head": table = new Table_head(tag, buf); break; case "hhea": table = new Table_hhea(tag, buf); break; case "hmtx": table = new Table_hmtx(tag, buf); break; case "JSTF": table = new Table_JSTF(tag, buf); break; case "kern": table = new Table_kern(tag, buf); break; case "loca": table = new Table_loca(tag, buf); break; case "LTSH": table = new Table_LTSH(tag, buf); break; case "maxp": table = new Table_maxp(tag, buf); break; case "name": table = new Table_name(tag, buf); break; case "OS/2": table = new Table_OS2(tag, buf); break; case "PCLT": table = new Table_PCLT(tag, buf); break; case "post": table = new Table_post(tag, buf); break; case "prep": table = new Table_prep(tag, buf); break; case "VDMX": table = new Table_VDMX(tag, buf); break; case "vhea": table = new Table_vhea(tag, buf); break; case "vmtx": table = new Table_vmtx(tag, buf); break; case "VORG": table = new Table_VORG(tag, buf); break; //case "Zapf": table = new Table_Zapf(tag, buf); break; default: table = new Table__Unknown(tag, buf); break; } return(table); }
public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf) { OTTable table = null; string sName = GetUnaliasedTableName(tag); switch (sName) { case "BASE": table = new Table_BASE(tag, buf); break; case "CFF ": table = new Table_CFF(tag, buf); break; case "cmap": table = new Table_cmap(tag, buf); break; case "cvt ": table = new Table_cvt(tag, buf); break; case "DSIG": table = new Table_DSIG(tag, buf); break; case "EBDT": table = new Table_EBDT(tag, buf); break; case "EBLC": table = new Table_EBLC(tag, buf); break; case "EBSC": table = new Table_EBSC(tag, buf); break; case "fpgm": table = new Table_fpgm(tag, buf); break; case "gasp": table = new Table_gasp(tag, buf); break; case "GDEF": table = new Table_GDEF(tag, buf); break; case "glyf": table = new Table_glyf(tag, buf); break; case "GPOS": table = new Table_GPOS(tag, buf); break; case "GSUB": table = new Table_GSUB(tag, buf); break; case "hdmx": table = new Table_hdmx(tag, buf); break; case "head": table = new Table_head(tag, buf); break; case "hhea": table = new Table_hhea(tag, buf); break; case "hmtx": table = new Table_hmtx(tag, buf); break; case "JSTF": table = new Table_JSTF(tag, buf); break; case "kern": table = new Table_kern(tag, buf); break; case "loca": table = new Table_loca(tag, buf); break; case "LTSH": table = new Table_LTSH(tag, buf); break; case "maxp": table = new Table_maxp(tag, buf); break; case "name": table = new Table_name(tag, buf); break; case "OS/2": table = new Table_OS2(tag, buf); break; case "PCLT": table = new Table_PCLT(tag, buf); break; case "post": table = new Table_post(tag, buf); break; case "prep": table = new Table_prep(tag, buf); break; case "VDMX": table = new Table_VDMX(tag, buf); break; case "vhea": table = new Table_vhea(tag, buf); break; case "vmtx": table = new Table_vmtx(tag, buf); break; case "VORG": table = new Table_VORG(tag, buf); break; //case "Zapf": table = new Table_Zapf(tag, buf); break; default: table = new Table__Unknown(tag, buf); break; } return table; }
static public glyph_base GetGlyphLogicalData(Table_glyf.header h) { glyph_base gb = null; SimpleGlyph sg = h.GetSimpleGlyph(); if (sg != null) { // glyph is a simple glyph gb = GetSimpleGlyphLogicalData(h); } else { CompositeGlyph cg = h.GetCompositeGlyph(); if (cg != null) { // glyph is a composite glyph gb = GetCompositeGlyphLogicalData(h); } } return gb; }
// constructor public glyf_cache(Table_glyf OwnerTable, OTFont OwnerFont) { m_arrGlyphs = new ArrayList(); // get each glyph from the glyf table for (uint iGlyph=0; iGlyph<OwnerFont.GetMaxpNumGlyphs(); iGlyph++) { header h = OwnerTable.GetGlyphHeader(iGlyph, OwnerFont); if (h == null) { m_arrGlyphs.Add(null); } else { glyph_base gb = GetGlyphLogicalData(h); m_arrGlyphs.Add(gb); } } }
private void GetCompositeGlyphStats(Table_glyf.CompositeGlyph cg, ref short nContours, ref ushort nPoints, ref ushort nInstructions, ref ushort nComponentElements, ref ushort nComponentDepth, OTFont fontOwner, Table_glyf glyfTable) { ushort nPointsTemp = 0; short nContoursTemp = 0; ushort nInstructionsTemp = 0; short TotalContours = 0; ushort TotalPoints = 0; ushort maxInstructions = 0; nComponentDepth++; int nCompositeGlyphs = 0; while (cg != null) { nCompositeGlyphs++; nInstructions = Math.Max(nInstructions, cg.GetNumInstructions()); Table_glyf.header glyfHeader = glyfTable.GetGlyphHeader(cg.glyphIndex, fontOwner); if (glyfHeader != null) { if (glyfHeader.numberOfContours >= 0) { nContoursTemp = glyfHeader.numberOfContours; Table_glyf.SimpleGlyph sg = glyfHeader.GetSimpleGlyph(); nPointsTemp = (ushort)(sg.GetEndPtOfContour((uint)glyfHeader.numberOfContours-1)+1); nInstructionsTemp = sg.instructionLength; } else { Table_glyf.CompositeGlyph EmbeddedCG = glyfHeader.GetCompositeGlyph(); GetCompositeGlyphStats(EmbeddedCG, ref nContoursTemp, ref nPointsTemp, ref nInstructionsTemp, ref nComponentElements, ref nComponentDepth, fontOwner, glyfTable); } TotalContours += nContoursTemp; TotalPoints += nPointsTemp; maxInstructions = Math.Max(maxInstructions, nInstructionsTemp); } cg = cg.GetNextCompositeGlyph(); } nComponentElements = (ushort)Math.Max(nComponentElements, nCompositeGlyphs); nContours = TotalContours; nPoints = TotalPoints; nInstructions = maxInstructions; }
private bool ComputeMaxpStats(Table_glyf glyfTable, OTFont fontOwner) { bool bRet = true; try { maxPointsCalc = 0; maxContoursCalc = 0; maxCompositePointsCalc = 0; maxCompositeContoursCalc = 0; maxSizeOfInstructionsCalc = 0; maxComponentElementsCalc = 0; maxComponentDepthCalc = 0; for (uint iGlyph = 0; iGlyph<NumGlyphs; iGlyph++) { Table_glyf.header glyfHeader = glyfTable.GetGlyphHeader(iGlyph, fontOwner); if (glyfHeader != null) { if (glyfHeader.numberOfContours >= 0) { Table_glyf.SimpleGlyph sg = glyfHeader.GetSimpleGlyph(); maxPointsCalc = (ushort)Math.Max(maxPointsCalc, sg.GetEndPtOfContour((uint)glyfHeader.numberOfContours-1)+1); maxContoursCalc = (ushort)Math.Max(maxContoursCalc, glyfHeader.numberOfContours); maxSizeOfInstructionsCalc = Math.Max(maxSizeOfInstructionsCalc, sg.instructionLength); } else { ushort nPointsTemp = 0; short nContoursTemp = 0; ushort nInstructionsTemp = 0; ushort nCompElementsTemp = 0; ushort nCompDepthTemp = 0; Table_glyf.CompositeGlyph cg = glyfHeader.GetCompositeGlyph(); GetCompositeGlyphStats(cg, ref nContoursTemp, ref nPointsTemp, ref nInstructionsTemp, ref nCompElementsTemp, ref nCompDepthTemp, fontOwner, glyfTable); maxCompositePointsCalc = Math.Max(maxCompositePointsCalc, nPointsTemp); maxCompositeContoursCalc = Math.Max(maxCompositeContoursCalc, nContoursTemp); maxSizeOfInstructionsCalc = Math.Max(maxSizeOfInstructionsCalc, nInstructionsTemp); maxComponentElementsCalc = Math.Max(maxComponentElementsCalc, nCompElementsTemp); maxComponentDepthCalc = Math.Max(maxComponentDepthCalc, nCompDepthTemp); } } } } catch { maxPointsCalc = 0; maxContoursCalc = 0; maxCompositePointsCalc = 0; maxCompositeContoursCalc = 0; maxSizeOfInstructionsCalc = 0; maxComponentElementsCalc = 0; maxComponentDepthCalc = 0; bRet = false; } return bRet; }