public Table_hmtx(OTTag tag, MBOBuffer buf, Table_hhea hheaTable, ushort nGlyphsInTheFont) : base(tag, buf) { m_hheaTable = hheaTable; m_nGlyphsInTheFont = nGlyphsInTheFont; Debug.Assert(m_hheaTable != null); m_nNumberOfHMetrics = m_hheaTable.numberOfHMetrics; }
public Table_vmtx(OTTag tag, MBOBuffer buf, Table_vhea vheaTable, ushort nGlyphsInTheFont) : base(tag, buf) { m_vheaTable = vheaTable; m_nGlyphsInTheFont = nGlyphsInTheFont; Debug.Assert(m_vheaTable != null); m_nLongVerMetrics = m_vheaTable.numOfLongVerMetrics; }
public ValueRecord(uint offset, MBOBuffer bufTable, uint offsetPosTable, ushort ValueFormat) { m_offsetValueRecord = offset; m_bufTable = bufTable; m_offsetPosTable = offsetPosTable; m_ValueFormat = ValueFormat; // calculate the offsets to each field ushort FieldOffset = 0; if (XPlacementPresent) { XPlacementFieldOffset = FieldOffset; FieldOffset += 2; } if (YPlacementPresent) { YPlacementFieldOffset = FieldOffset; FieldOffset += 2; } if (XAdvancePresent) { XAdvanceFieldOffset = FieldOffset; FieldOffset += 2; } if (YAdvancePresent) { YAdvanceFieldOffset = FieldOffset; FieldOffset += 2; } if (XPlaDevicePresent) { XPlaDeviceFieldOffset = FieldOffset; FieldOffset += 2; } if (YPlaDevicePresent) { YPlaDeviceFieldOffset = FieldOffset; FieldOffset += 2; } if (XAdvDevicePresent) { XAdvDeviceFieldOffset = FieldOffset; FieldOffset += 2; } if (YAdvDevicePresent) { YAdvDeviceFieldOffset = FieldOffset; FieldOffset += 2; } }
/************************ * public methods */ public override OTTable CreateTableObject(OTTag tag, MBOBuffer buf) { OTTable table = null; string sName = GetUnaliasedTableName(tag); switch (sName) { case "BASE": table = new val_BASE(tag, buf); break; case "CFF ": table = new val_CFF(tag, buf); break; case "cmap": table = new val_cmap(tag, buf); break; case "cvt ": table = new val_cvt(tag, buf); break; case "DSIG": table = new val_DSIG(tag, buf); break; case "EBDT": table = new val_EBDT(tag, buf); break; case "EBLC": table = new val_EBLC(tag, buf); break; case "EBSC": table = new val_EBSC(tag, buf); break; case "fpgm": table = new val_fpgm(tag, buf); break; case "gasp": table = new val_gasp(tag, buf); break; case "GDEF": table = new val_GDEF(tag, buf); break; case "glyf": table = new val_glyf(tag, buf); break; case "GPOS": table = new val_GPOS(tag, buf); break; case "GSUB": table = new val_GSUB(tag, buf); break; case "hdmx": table = new val_hdmx(tag, buf); break; case "head": table = new val_head(tag, buf); break; case "hhea": table = new val_hhea(tag, buf); break; case "hmtx": table = new val_hmtx(tag, buf); break; case "JSTF": table = new val_JSTF(tag, buf); break; case "kern": table = new val_kern(tag, buf); break; case "loca": table = new val_loca(tag, buf); break; case "LTSH": table = new val_LTSH(tag, buf); break; case "maxp": table = new val_maxp(tag, buf); break; case "name": table = new val_name(tag, buf); break; case "OS/2": table = new val_OS2(tag, buf); break; case "PCLT": table = new val_PCLT(tag, buf); break; case "post": table = new val_post(tag, buf); break; case "prep": table = new val_prep(tag, buf); break; case "SVG ": table = new val_SVG(tag, buf); break; case "VDMX": table = new val_VDMX(tag, buf); break; case "vhea": table = new val_vhea(tag, buf); break; case "vmtx": table = new val_vmtx(tag, buf); break; case "VORG": table = new val_VORG(tag, buf); break; //case "Zapf": table = new val_Zapf(tag, buf); break; default: table = new val__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 "meta": table = new Table_meta(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 "SVG ": table = new Table_SVG(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 override OTTable GenerateTable() { MBOBuffer newbuf; switch (m_version) { case 0x0000: newbuf = new MBOBuffer(78); break; case 0x0001: newbuf = new MBOBuffer(86); break; case 0x0002: newbuf = new MBOBuffer(96); break; case 0x0003: goto case 0x0002; default: goto case 0x0002; // version 3 is default } newbuf.SetUshort(m_version, (uint)Table_OS2.FieldOffsets.version); newbuf.SetShort(m_xAvgCharWidth, (uint)Table_OS2.FieldOffsets.xAvgCharWidth); newbuf.SetUshort(m_usWeightClass, (uint)Table_OS2.FieldOffsets.usWeightClass); newbuf.SetUshort(m_usWidthClass, (uint)Table_OS2.FieldOffsets.usWidthClass); newbuf.SetUshort(m_fsType, (uint)Table_OS2.FieldOffsets.fsType); newbuf.SetShort(m_ySubscriptXSize, (uint)Table_OS2.FieldOffsets.ySubscriptXSize); newbuf.SetShort(m_ySubscriptYSize, (uint)Table_OS2.FieldOffsets.ySubscriptYSize); newbuf.SetShort(m_ySubscriptXOffset, (uint)Table_OS2.FieldOffsets.ySubscriptXOffset); newbuf.SetShort(m_ySubscriptYOffset, (uint)Table_OS2.FieldOffsets.ySubscriptYOffset); newbuf.SetShort(m_ySuperscriptXSize, (uint)Table_OS2.FieldOffsets.ySuperscriptXSize); newbuf.SetShort(m_ySuperscriptYSize, (uint)Table_OS2.FieldOffsets.ySuperscriptYSize); newbuf.SetShort(m_ySuperscriptXOffset, (uint)Table_OS2.FieldOffsets.ySuperscriptXOffset); newbuf.SetShort(m_ySuperscriptYOffset, (uint)Table_OS2.FieldOffsets.ySuperscriptYOffset); newbuf.SetShort(m_yStrikeoutSize, (uint)Table_OS2.FieldOffsets.yStrikeoutSize); newbuf.SetShort(m_yStrikeoutPosition, (uint)Table_OS2.FieldOffsets.yStrikeoutPosition); newbuf.SetShort(m_sFamilyClass, (uint)Table_OS2.FieldOffsets.sFamilyClass); newbuf.SetByte(m_panose_byte1, (uint)Table_OS2.FieldOffsets.panose_byte1); newbuf.SetByte(m_panose_byte2, (uint)Table_OS2.FieldOffsets.panose_byte2); newbuf.SetByte(m_panose_byte3, (uint)Table_OS2.FieldOffsets.panose_byte3); newbuf.SetByte(m_panose_byte4, (uint)Table_OS2.FieldOffsets.panose_byte4); newbuf.SetByte(m_panose_byte5, (uint)Table_OS2.FieldOffsets.panose_byte5); newbuf.SetByte(m_panose_byte6, (uint)Table_OS2.FieldOffsets.panose_byte6); newbuf.SetByte(m_panose_byte7, (uint)Table_OS2.FieldOffsets.panose_byte7); newbuf.SetByte(m_panose_byte8, (uint)Table_OS2.FieldOffsets.panose_byte8); newbuf.SetByte(m_panose_byte9, (uint)Table_OS2.FieldOffsets.panose_byte9); newbuf.SetByte(m_panose_byte10, (uint)Table_OS2.FieldOffsets.panose_byte10); newbuf.SetUint(m_ulUnicodeRange1, (uint)Table_OS2.FieldOffsets.ulUnicodeRange1); newbuf.SetUint(m_ulUnicodeRange2, (uint)Table_OS2.FieldOffsets.ulUnicodeRange2); newbuf.SetUint(m_ulUnicodeRange3, (uint)Table_OS2.FieldOffsets.ulUnicodeRange3); newbuf.SetUint(m_ulUnicodeRange4, (uint)Table_OS2.FieldOffsets.ulUnicodeRange4); for (int i = 0; i < 4; i++) { newbuf.SetByte(m_achVendID[i], (uint)(Table_OS2.FieldOffsets.achVendID + i)); } newbuf.SetUshort(m_fsSelection, (uint)Table_OS2.FieldOffsets.fsSelection); newbuf.SetUshort(m_usFirstCharIndex, (uint)Table_OS2.FieldOffsets.usFirstCharIndex); newbuf.SetUshort(m_usLastCharIndex, (uint)Table_OS2.FieldOffsets.usLastCharIndex); newbuf.SetShort(m_sTypoAscender, (uint)Table_OS2.FieldOffsets.sTypoAscender); newbuf.SetShort(m_sTypoDescender, (uint)Table_OS2.FieldOffsets.sTypoDescender); newbuf.SetShort(m_sTypoLineGap, (uint)Table_OS2.FieldOffsets.sTypoLineGap); newbuf.SetUshort(m_usWinAscent, (uint)Table_OS2.FieldOffsets.usWinAscent); newbuf.SetUshort(m_usWinDescent, (uint)Table_OS2.FieldOffsets.usWinDescent); // version 1.0 if (version > 0x000) { newbuf.SetUint(m_ulCodePageRange1, (uint)Table_OS2.FieldOffsets.ulCodePageRange1); newbuf.SetUint(m_ulCodePageRange2, (uint)Table_OS2.FieldOffsets.ulCodePageRange2); // vewrsion 2 & 3 if (version > 0x001) { newbuf.SetShort(m_sxHeight, (uint)Table_OS2.FieldOffsets.sxHeight); newbuf.SetShort(m_sCapHeight, (uint)Table_OS2.FieldOffsets.sCapHeight); newbuf.SetUshort(m_usDefaultChar, (uint)Table_OS2.FieldOffsets.usDefaultChar); newbuf.SetUshort(m_usBreakChar, (uint)Table_OS2.FieldOffsets.usBreakChar); newbuf.SetUshort(m_usMaxContext, (uint)Table_OS2.FieldOffsets.usMaxContext); } } // put the buffer into a Table_maxp object and return it Table_OS2 OS2Table = new Table_OS2("OS/2", newbuf); return(OS2Table); }
/************************ * constructors */ public Table_OS2(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public val_cmap(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public Ratios(ushort offset, MBOBuffer bufTable) { m_offsetRatios = offset; m_bufTable = bufTable; }
public DeviceRecord(uint offset, MBOBuffer bufTable, ushort numGlyphs) { m_offsetDeviceRecord = offset; m_bufTable = bufTable; m_numGlyphs = numGlyphs; }
/************************ * constructors */ public Table_name(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public override OTTable GenerateTable() { ushort iSizeOfVDMXGroups = 0; // Used to detrmine which vdmx goes with which ratio ushort[] VDMXOffsets = new ushort[m_numRecs]; for (ushort i = 0; i < m_numRecs; i++) { iSizeOfVDMXGroups += (ushort)(4 + (((VDMXGroupCache)m_groups[i]).recs * 6)); } // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer((uint)(6 + (m_numRatios * 4) + (2 * m_numRatios) + iSizeOfVDMXGroups)); // populate the buffer newbuf.SetUshort(m_version, (uint)Table_VDMX.FieldOffsets.version); newbuf.SetUshort(m_numRecs, (uint)Table_VDMX.FieldOffsets.numRecs); newbuf.SetUshort(m_numRatios, (uint)Table_VDMX.FieldOffsets.numRatios); // populate buffer with Ratio Records for (ushort i = 0; i < m_numRatios; i++) { newbuf.SetByte(((RatioCache)m_ratRange[i]).bCharSet, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4))); newbuf.SetByte(((RatioCache)m_ratRange[i]).xRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1)); newbuf.SetByte(((RatioCache)m_ratRange[i]).yStartRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2)); newbuf.SetByte(((RatioCache)m_ratRange[i]).yEndRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3)); } // Set up the strting offset for the VDMX Groups ushort iOffset = (ushort)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (m_numRatios * 2)); // NOTE: we may want to check these VDMX Groups to see if they are orphans and remove them if they are? // populate buffer with VDMX Groups for (ushort i = 0; i < m_numRecs; i++) { // Save the offset for this group VDMXOffsets[i] = iOffset; newbuf.SetUshort(((VDMXGroupCache)m_groups[i]).recs, iOffset); iOffset += 2; newbuf.SetByte(((VDMXGroupCache)m_groups[i]).startsz, iOffset); iOffset += 1; newbuf.SetByte(((VDMXGroupCache)m_groups[i]).endsz, iOffset); iOffset += 1; for (ushort ii = 0; ii < ((VDMXGroupCache)m_groups[i]).recs; ii++) { newbuf.SetUshort(((VDMXGroupCache)m_groups[i]).getVTableRecordCache(ii).yPelHeight, iOffset); iOffset += 2; newbuf.SetShort(((VDMXGroupCache)m_groups[i]).getVTableRecordCache(ii).yMax, iOffset); iOffset += 2; newbuf.SetShort(((VDMXGroupCache)m_groups[i]).getVTableRecordCache(ii).yMin, iOffset); iOffset += 2; } } // populate buffer with Ratio Records for (ushort i = 0; i < m_numRatios; i++) { newbuf.SetByte(((RatioCache)m_ratRange[i]).bCharSet, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4))); newbuf.SetByte(((RatioCache)m_ratRange[i]).xRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1)); newbuf.SetByte(((RatioCache)m_ratRange[i]).yStartRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2)); newbuf.SetByte(((RatioCache)m_ratRange[i]).yEndRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3)); // Write out the offsets for the VDMX Groups to the buffer newbuf.SetUshort(VDMXOffsets[((RatioCache)m_ratRange[i]).VDMXGroupThisRatio], (uint)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (i * 2))); } // put the buffer into a Table_VDMX object and return it Table_VDMX VDMXTable = new Table_VDMX("VDMX", newbuf); return(VDMXTable); }
public Vdmx(ushort offset, MBOBuffer bufTable) { m_offsetVdmx = offset; m_bufTable = bufTable; }
/************************ * constructors */ public Table_VDMX(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public vTable(ushort offset, MBOBuffer bufTable) { m_offsetvTable = offset; m_bufTable = bufTable; }
/// <summary>Write a TTC (TT Collection) to a disk file.</summary> public static bool WriteTTCFile(FileStream fs, OTFont[] fonts) { bool bRet = true; // build the TTC header OTTag TTCtag = (OTTag)"ttcf"; uint version = 0x00020000; uint DirectoryCount = (uint)fonts.Length; uint [] TableDirectory = new uint[fonts.Length]; uint ulDsigTag = 0; uint ulDsigLength = 0; uint ulDsigOffset = 0; uint TTCHeaderLen = 12 + DirectoryCount * 4 + 12; // length of version 2.0 header // build an array of offset tables OffsetTable[] otArr = new OffsetTable[fonts.Length]; for (int iFont = 0; iFont < fonts.Length; iFont++) { otArr[iFont] = new OffsetTable(new OTFixed(1, 0), fonts[iFont].GetNumTables()); } // build an array of head tables that will contain the updated modified field and font checksum Table_head[] arrHeadTables = new Table_head[fonts.Length]; for (int i = 0; i < fonts.Length; i++) { // get the cache Table_head headTable = (Table_head)fonts[i].GetTable("head"); Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache(); // set the 'modified' field to the current date DateTime dt = DateTime.Now; headCache.modified = headTable.DateTimeToSecondsSince1904(dt); // generate a new table and add it to the array Table_head newHead = (Table_head)headCache.GenerateTable(); arrHeadTables[i] = newHead; } // build a list of directory entries for each font long FilePos = TTCHeaderLen; for (int iFont = 0; iFont < fonts.Length; iFont++) { ushort numTables = fonts[iFont].GetNumTables(); TableDirectory[iFont] = (uint)FilePos; FilePos += 12 + numTables * 16; uint PrevFilePos = 0; for (ushort i = 0; i < numTables; i++) { OTTable table = fonts[iFont].GetTable(i); OTTag tag = table.m_tag; if ((string)tag == "head") { table = arrHeadTables[iFont]; } // check if this table is a duplicate of a table in a previous font PrevFilePos = 0; if (iFont > 0) { for (int iPrevFont = 0; iPrevFont < iFont; iPrevFont++) { for (int iTable = 0; iTable < fonts[iPrevFont].GetNumTables(); iTable++) { OTTable PrevTable = fonts[iPrevFont].GetTable(table.m_tag); if (PrevTable != null) { if (MBOBuffer.BinaryEqual(table.m_bufTable, PrevTable.m_bufTable)) { // get the file position for the previous table for (int iDe = 0; iDe < otArr[iPrevFont].DirectoryEntries.Count; iDe++) { DirectoryEntry dePrev = (DirectoryEntry)otArr[iPrevFont].DirectoryEntries[iDe]; if (dePrev.tag == table.m_tag) { PrevFilePos = dePrev.offset; break; } } } } } } } // build a new directory entry DirectoryEntry de = new DirectoryEntry(); de.tag = new OTTag(tag.GetBytes()); de.checkSum = table.CalcChecksum(); de.length = table.GetLength(); if (PrevFilePos != 0) { de.offset = (uint)PrevFilePos; } else { de.offset = (uint)FilePos; FilePos += table.GetBuffer().GetPaddedLength(); } otArr[iFont].DirectoryEntries.Add(de); } // sort the directory entries if (numTables > 1) { for (int i = 0; i < numTables - 1; i++) { for (int j = i + 1; j < numTables; j++) { if (((DirectoryEntry)otArr[iFont].DirectoryEntries[i]).tag > ((DirectoryEntry)otArr[iFont].DirectoryEntries[j]).tag) { DirectoryEntry temp = (DirectoryEntry)otArr[iFont].DirectoryEntries[i]; otArr[iFont].DirectoryEntries[i] = (DirectoryEntry)otArr[iFont].DirectoryEntries[j]; otArr[iFont].DirectoryEntries[j] = temp; } } } } } // update each font's checksum in the head table for (int iFont = 0; iFont < fonts.Length; iFont++) { ushort numTables = fonts[iFont].GetNumTables(); // calculate the checksum uint sum = 0; sum += otArr[iFont].CalcOffsetTableChecksum(); sum += otArr[iFont].CalcDirectoryEntriesChecksum(); for (ushort i = 0; i < numTables; i++) { DirectoryEntry de = (DirectoryEntry)otArr[iFont].DirectoryEntries[i]; OTTable table = fonts[iFont].GetTable(de.tag); if ((string)de.tag == "head") { table = arrHeadTables[iFont]; } sum += table.CalcChecksum(); } // get the cache Table_head headTable = arrHeadTables[iFont]; Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache(); // set the checkSumAdujustment field headCache.checkSumAdjustment = 0xb1b0afba - sum; // generate a new table and replace the head table in the array of head tables Table_head newHead = (Table_head)headCache.GenerateTable(); arrHeadTables[iFont] = newHead; } // write the TTC header WriteUint32MBO(fs, (uint)TTCtag); WriteUint32MBO(fs, version); WriteUint32MBO(fs, DirectoryCount); for (int i = 0; i < fonts.Length; i++) { WriteUint32MBO(fs, TableDirectory[i]); } WriteUint32MBO(fs, ulDsigTag); WriteUint32MBO(fs, ulDsigLength); WriteUint32MBO(fs, ulDsigOffset); // write out each font for (int iFont = 0; iFont < fonts.Length; iFont++) { ushort numTables = fonts[iFont].GetNumTables(); // write the offset table fs.Write(otArr[iFont].m_buf.GetBuffer(), 0, (int)otArr[iFont].m_buf.GetLength()); // write the directory entries for (int i = 0; i < numTables; i++) { DirectoryEntry de = (DirectoryEntry)otArr[iFont].DirectoryEntries[i]; fs.Write(de.m_buf.GetBuffer(), 0, (int)de.m_buf.GetLength()); } // write out each table unless a shared version has been written for (ushort i = 0; i < numTables; i++) { DirectoryEntry de = (DirectoryEntry)otArr[iFont].DirectoryEntries[i]; if (fs.Position == de.offset) { OTTable table = fonts[iFont].GetTable(de.tag); if ((string)table.m_tag == "head") { table = arrHeadTables[iFont]; } fs.Write(table.m_bufTable.GetBuffer(), 0, (int)table.GetBuffer().GetPaddedLength()); } } } return(bRet); }
/************************ * constructors */ public Table_gasp(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
/************************ * constructors */ public val_head(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
/************************ * constructors */ public Table_DSIG(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public Table_hdmx(OTTag tag, MBOBuffer buf, ushort nNumGlyphs ) : base(tag, buf) { m_numGlyphs = nNumGlyphs; }
/************************ * constructors */ public Table_JSTF(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public Table_SVG(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public ExtenderGlyph(ushort offset, MBOBuffer bufTable) { m_offsetExtenderGlyph = offset; m_bufTable = bufTable; }
public override OTTable GenerateTable() { ArrayList bytesNameString = new ArrayList(); ushort nLengthOfStrings = 0; ushort nStartOfStringStorage = (ushort)(6 + (m_nameRecords.Count * 12)); for( ushort i = 0; i < m_nameRecords.Count; i++ ) { NameRecordCache nrc = (NameRecordCache)m_nameRecords[i]; byte[] byteString = EncodeString(nrc.sNameString, nrc.platformID, nrc.encodingID); bytesNameString.Add( byteString ); nLengthOfStrings += (ushort)byteString.Length; } // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer( (uint)(Table_name.FieldOffsets.NameRecords + (m_nameRecords.Count * 12) + nLengthOfStrings)); // populate the buffer newbuf.SetUshort( m_format, (uint)Table_name.FieldOffsets.FormatSelector ); newbuf.SetUshort( (ushort)m_nameRecords.Count, (uint)Table_name.FieldOffsets.NumberNameRecords ); newbuf.SetUshort( nStartOfStringStorage, (uint)Table_name.FieldOffsets.OffsetToStrings ); ushort nOffset = 0; // Write the NameRecords and Strings for( ushort i = 0; i < m_nameRecords.Count; i++ ) { byte[] bString = (byte[])bytesNameString[i]; newbuf.SetUshort( ((NameRecordCache)m_nameRecords[i]).platformID, (uint)(Table_name.FieldOffsets.NameRecords + (i * 12))); newbuf.SetUshort( ((NameRecordCache)m_nameRecords[i]).encodingID, (uint)(Table_name.FieldOffsets.NameRecords + (i * 12) + 2)); newbuf.SetUshort( ((NameRecordCache)m_nameRecords[i]).languageID, (uint)(Table_name.FieldOffsets.NameRecords + (i * 12) + 4)); newbuf.SetUshort( ((NameRecordCache)m_nameRecords[i]).nameID, (uint)(Table_name.FieldOffsets.NameRecords + (i * 12) + 6)); newbuf.SetUshort( (ushort)bString.Length, (uint)(Table_name.FieldOffsets.NameRecords + (i * 12) + 8)); newbuf.SetUshort( nOffset, (uint)(Table_name.FieldOffsets.NameRecords + (i * 12) + 10)); //Write the string to the buffer for( int ii = 0; ii < bString.Length; ii++ ) { newbuf.SetByte( bString[ii], (uint)(nStartOfStringStorage + nOffset + ii)); } nOffset += (ushort)bString.Length; } // put the buffer into a Table_name object and return it Table_name nameTable = new Table_name("name", newbuf); return nameTable; }
public JstfLangSys(ushort offset, MBOBuffer bufTable) { m_offsetJstfLangSys = offset; m_bufTable = bufTable; }
public LookupTable_val(ushort offset, MBOBuffer bufTable, OTTag tag) : base(offset, bufTable, tag) { }
public ClassDefFormat2_val(uint offset, MBOBuffer bufTable) : base(offset, bufTable) { }
/************************ * constructors */ public Table_head(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public ScriptTable_val(ushort offset, MBOBuffer bufTable) : base(offset, bufTable) { }
public JstfPriority(ushort offset, MBOBuffer bufTable) { m_offsetJstfPriority = offset; m_bufTable = bufTable; }
/************************ * constructors */ /// <summary>Construct abstract base class tag and buffer</summary> public OTTable(OTTag tag, MBOBuffer buf) { m_tag = new OTTag(tag); m_bufTable = buf; }
public CoverageTable_val(uint offset, MBOBuffer bufTable) : base(offset, bufTable) { }
public JstfGPOSModList(ushort offset, MBOBuffer bufTable) { m_offsetJstfGPOSModList = offset; m_bufTable = bufTable; }
public DeviceTable_val(uint offset, MBOBuffer bufTable) : base (offset, bufTable) { }
public JstfMax(ushort offset, MBOBuffer bufTable) { m_offsetJstfMax = offset; m_bufTable = bufTable; }
public override OTTable GenerateTable() { MBOBuffer newbuf; switch( m_version ) { case 0x0000: newbuf = new MBOBuffer( 78 ); break; case 0x0001: newbuf = new MBOBuffer( 86 ); break; case 0x0002: newbuf = new MBOBuffer( 96 ); break; case 0x0003: goto case 0x0002; default: goto case 0x0002; // version 3 is default } newbuf.SetUshort( m_version, (uint)Table_OS2.FieldOffsets.version ); newbuf.SetShort( m_xAvgCharWidth, (uint)Table_OS2.FieldOffsets.xAvgCharWidth ); newbuf.SetUshort( m_usWeightClass, (uint)Table_OS2.FieldOffsets.usWeightClass ); newbuf.SetUshort( m_usWidthClass, (uint)Table_OS2.FieldOffsets.usWidthClass ); newbuf.SetUshort( m_fsType, (uint)Table_OS2.FieldOffsets.fsType ); newbuf.SetShort( m_ySubscriptXSize, (uint)Table_OS2.FieldOffsets.ySubscriptXSize ); newbuf.SetShort( m_ySubscriptYSize, (uint)Table_OS2.FieldOffsets.ySubscriptYSize ); newbuf.SetShort( m_ySubscriptXOffset, (uint)Table_OS2.FieldOffsets.ySubscriptXOffset ); newbuf.SetShort( m_ySubscriptYOffset, (uint)Table_OS2.FieldOffsets.ySubscriptYOffset ); newbuf.SetShort( m_ySuperscriptXSize, (uint)Table_OS2.FieldOffsets.ySuperscriptXSize ); newbuf.SetShort( m_ySuperscriptYSize, (uint)Table_OS2.FieldOffsets.ySuperscriptYSize ); newbuf.SetShort( m_ySuperscriptXOffset, (uint)Table_OS2.FieldOffsets.ySuperscriptXOffset ); newbuf.SetShort( m_ySuperscriptYOffset, (uint)Table_OS2.FieldOffsets.ySuperscriptYOffset ); newbuf.SetShort( m_yStrikeoutSize, (uint)Table_OS2.FieldOffsets.yStrikeoutSize ); newbuf.SetShort( m_yStrikeoutPosition, (uint)Table_OS2.FieldOffsets.yStrikeoutPosition ); newbuf.SetShort( m_sFamilyClass, (uint)Table_OS2.FieldOffsets.sFamilyClass ); newbuf.SetByte( m_panose_byte1, (uint)Table_OS2.FieldOffsets.panose_byte1 ); newbuf.SetByte( m_panose_byte2, (uint)Table_OS2.FieldOffsets.panose_byte2 ); newbuf.SetByte( m_panose_byte3, (uint)Table_OS2.FieldOffsets.panose_byte3 ); newbuf.SetByte( m_panose_byte4, (uint)Table_OS2.FieldOffsets.panose_byte4 ); newbuf.SetByte( m_panose_byte5, (uint)Table_OS2.FieldOffsets.panose_byte5 ); newbuf.SetByte( m_panose_byte6, (uint)Table_OS2.FieldOffsets.panose_byte6 ); newbuf.SetByte( m_panose_byte7, (uint)Table_OS2.FieldOffsets.panose_byte7 ); newbuf.SetByte( m_panose_byte8, (uint)Table_OS2.FieldOffsets.panose_byte8 ); newbuf.SetByte( m_panose_byte9, (uint)Table_OS2.FieldOffsets.panose_byte9 ); newbuf.SetByte( m_panose_byte10, (uint)Table_OS2.FieldOffsets.panose_byte10 ); newbuf.SetUint( m_ulUnicodeRange1, (uint)Table_OS2.FieldOffsets.ulUnicodeRange1 ); newbuf.SetUint( m_ulUnicodeRange2, (uint)Table_OS2.FieldOffsets.ulUnicodeRange2 ); newbuf.SetUint( m_ulUnicodeRange3, (uint)Table_OS2.FieldOffsets.ulUnicodeRange3 ); newbuf.SetUint( m_ulUnicodeRange4, (uint)Table_OS2.FieldOffsets.ulUnicodeRange4 ); for( int i = 0; i < 4; i++ ) { newbuf.SetByte( m_achVendID[i], (uint)(Table_OS2.FieldOffsets.achVendID + i)); } newbuf.SetUshort( m_fsSelection, (uint)Table_OS2.FieldOffsets.fsSelection ); newbuf.SetUshort( m_usFirstCharIndex, (uint)Table_OS2.FieldOffsets.usFirstCharIndex ); newbuf.SetUshort( m_usLastCharIndex, (uint)Table_OS2.FieldOffsets.usLastCharIndex ); newbuf.SetShort( m_sTypoAscender, (uint)Table_OS2.FieldOffsets.sTypoAscender ); newbuf.SetShort( m_sTypoDescender, (uint)Table_OS2.FieldOffsets.sTypoDescender ); newbuf.SetShort( m_sTypoLineGap, (uint)Table_OS2.FieldOffsets.sTypoLineGap ); newbuf.SetUshort( m_usWinAscent, (uint)Table_OS2.FieldOffsets.usWinAscent ); newbuf.SetUshort( m_usWinDescent, (uint)Table_OS2.FieldOffsets.usWinDescent ); // version 1.0 if( version > 0x000 ) { newbuf.SetUint( m_ulCodePageRange1, (uint)Table_OS2.FieldOffsets.ulCodePageRange1 ); newbuf.SetUint( m_ulCodePageRange2, (uint)Table_OS2.FieldOffsets.ulCodePageRange2 ); // vewrsion 2 & 3 if( version > 0x001 ) { newbuf.SetShort( m_sxHeight, (uint)Table_OS2.FieldOffsets.sxHeight ); newbuf.SetShort( m_sCapHeight, (uint)Table_OS2.FieldOffsets.sCapHeight ); newbuf.SetUshort( m_usDefaultChar, (uint)Table_OS2.FieldOffsets.usDefaultChar ); newbuf.SetUshort( m_usBreakChar, (uint)Table_OS2.FieldOffsets.usBreakChar ); newbuf.SetUshort( m_usMaxContext, (uint)Table_OS2.FieldOffsets.usMaxContext ); } } // put the buffer into a Table_maxp object and return it Table_OS2 OS2Table = new Table_OS2("OS/2", newbuf); return OS2Table; }
public JstfScript(ushort offset, MBOBuffer bufTable) { m_offsetJstfScript = offset; m_bufTable = bufTable; }
/************************ * constructors */ public Table_hdmx(OTTag tag, MBOBuffer buf) : base(tag, buf) { m_numGlyphs = 0; }
/************************ * constructors */ public Table_fpgm(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer( 8 + (uint)(SizeofDeviceRecord * m_NumberDeviceRecords)); // populate the buffer newbuf.SetUshort( m_TableVersionNumber, (uint)Table_hdmx.FieldOffsets.TableVersionNumber ); newbuf.SetShort( m_NumberDeviceRecords, (uint)Table_hdmx.FieldOffsets.NumberDeviceRecords ); newbuf.SetInt( SizeofDeviceRecord, (uint)Table_hdmx.FieldOffsets.SizeofDeviceRecord ); for( short i = 0; i < m_NumberDeviceRecords; i++ ) { newbuf.SetByte(((DeviceRecordCache)m_DeviceRecords[i]).PixelSize, (uint)Table_hdmx.FieldOffsets.DeviceRecord + (uint)(i * SizeofDeviceRecord ) + (uint)DeviceRecord.FieldOffsets.PixelSize ); newbuf.SetByte(((DeviceRecordCache)m_DeviceRecords[i]).MaxWidth, (uint)Table_hdmx.FieldOffsets.DeviceRecord + (uint)(i * SizeofDeviceRecord ) + (uint)DeviceRecord.FieldOffsets.MaxWidth ); for( ushort ii = 0; ii < m_NumGlyphs; ii++ ) { newbuf.SetByte(((DeviceRecordCache)m_DeviceRecords[i]).getWidth( ii ), (uint)Table_hdmx.FieldOffsets.DeviceRecord + (uint)(i * SizeofDeviceRecord ) + (uint)(DeviceRecord.FieldOffsets.Widths + ii )); } // Pad the end with zeros for( uint ii = 0; ii < getNumPadBytes(); ii++ ) { newbuf.SetByte( 0, (uint)Table_hdmx.FieldOffsets.DeviceRecord + (uint)(i * SizeofDeviceRecord ) + (uint)DeviceRecord.FieldOffsets.Widths + m_NumGlyphs + ii ); } } // put the buffer into a Table_hdmx object and return it Table_hdmx hdmxTable = new Table_hdmx("hdmx", newbuf); return hdmxTable; }
/************************ * constructors */ public Table_Zapf(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
/************************ * constructors */ public val_fpgm(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public NamedGroup(uint offset, MBOBuffer bufTable) { m_offsetNamedGroup = offset; m_bufTable = bufTable; }
public SVGDocumentIndexEntry(uint offset, MBOBuffer bufTable) { m_offsetIndex = offset; m_bufTable = bufTable; }
public GroupInfoGroup(uint offset, MBOBuffer bufTable) { m_offsetGroupInfoGroup = offset; m_bufTable = bufTable; }
public NameRecord(ushort offset, MBOBuffer bufTable) { m_offsetNameRecord = offset; m_bufTable = bufTable; }
public GlyphInfo(uint offset, MBOBuffer bufTable) { m_offsetGlyphInfo = offset; m_bufTable = bufTable; }
/************************ * constructors */ public val_PCLT(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public FeatureInfo(uint offset, MBOBuffer bufTable) { m_offsetFeatureInfo = offset; m_bufTable = bufTable; }
public Format4_val(EncodingTableEntry ete, MBOBuffer bufTable) : base(ete, bufTable) { }
public KindName(uint offset, MBOBuffer bufTable) { m_offsetKindName = offset; m_bufTable = bufTable; }
/************************ * constructors */ public Table_EBDT(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
public override OTTable GenerateTable() { ushort iSizeOfVDMXGroups = 0; // Used to detrmine which vdmx goes with which ratio ushort[] VDMXOffsets = new ushort[m_numRecs]; for( ushort i = 0; i < m_numRecs; i++ ) { iSizeOfVDMXGroups += (ushort)(4 + (((VDMXGroupCache)m_groups[i]).recs * 6)); } // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer( (uint)(6 + (m_numRatios * 4) + (2* m_numRatios) + iSizeOfVDMXGroups)); // populate the buffer newbuf.SetUshort( m_version, (uint)Table_VDMX.FieldOffsets.version ); newbuf.SetUshort( m_numRecs, (uint)Table_VDMX.FieldOffsets.numRecs ); newbuf.SetUshort( m_numRatios, (uint)Table_VDMX.FieldOffsets.numRatios ); // populate buffer with Ratio Records for( ushort i = 0; i < m_numRatios; i++ ) { newbuf.SetByte( ((RatioCache)m_ratRange[i]).bCharSet, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4))); newbuf.SetByte( ((RatioCache)m_ratRange[i]).xRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1)); newbuf.SetByte( ((RatioCache)m_ratRange[i]).yStartRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2)); newbuf.SetByte( ((RatioCache)m_ratRange[i]).yEndRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3)); } // Set up the strting offset for the VDMX Groups ushort iOffset = (ushort)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (m_numRatios * 2)); // NOTE: we may want to check these VDMX Groups to see if they are orphans and remove them if they are? // populate buffer with VDMX Groups for( ushort i = 0; i < m_numRecs; i++ ) { // Save the offset for this group VDMXOffsets[i] = iOffset; newbuf.SetUshort( ((VDMXGroupCache)m_groups[i]).recs, iOffset ); iOffset += 2; newbuf.SetByte( ((VDMXGroupCache)m_groups[i]).startsz, iOffset ); iOffset += 1; newbuf.SetByte( ((VDMXGroupCache)m_groups[i]).endsz, iOffset ); iOffset += 1; for( ushort ii = 0; ii < ((VDMXGroupCache)m_groups[i]).recs; ii++ ) { newbuf.SetUshort( ((VDMXGroupCache)m_groups[i]).getVTableRecordCache( ii ).yPelHeight, iOffset ); iOffset += 2; newbuf.SetShort( ((VDMXGroupCache)m_groups[i]).getVTableRecordCache( ii ).yMax, iOffset ); iOffset += 2; newbuf.SetShort( ((VDMXGroupCache)m_groups[i]).getVTableRecordCache( ii ).yMin, iOffset ); iOffset += 2; } } // populate buffer with Ratio Records for( ushort i = 0; i < m_numRatios; i++ ) { newbuf.SetByte( ((RatioCache)m_ratRange[i]).bCharSet, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4))); newbuf.SetByte( ((RatioCache)m_ratRange[i]).xRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1)); newbuf.SetByte( ((RatioCache)m_ratRange[i]).yStartRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2)); newbuf.SetByte( ((RatioCache)m_ratRange[i]).yEndRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3)); // Write out the offsets for the VDMX Groups to the buffer newbuf.SetUshort( VDMXOffsets[((RatioCache)m_ratRange[i]).VDMXGroupThisRatio], (uint)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (i * 2))); } // put the buffer into a Table_VDMX object and return it Table_VDMX VDMXTable = new Table_VDMX("VDMX", newbuf); return VDMXTable; }
public void setCache(MBOBuffer newbuf) { m_newbuf = newbuf; }
/************************ * constructors */ public val_VDMX(OTTag tag, MBOBuffer buf) : base(tag, buf) { }
/************************ * constructors */ public Table_vmtx(OTTag tag, MBOBuffer buf) : base(tag, buf) { m_nLongVerMetrics = 0; m_nGlyphsInTheFont = 0; }