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); }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(54); // populate the buffer newbuf.SetFixed(m_TableVersion, (uint)Table_head.FieldOffsets.TableVersionNumber); newbuf.SetFixed(m_fontRevision, (uint)Table_head.FieldOffsets.fontRevision); newbuf.SetUint(m_checkSumAdjustment, (uint)Table_head.FieldOffsets.checkSumAdjustment); newbuf.SetUint(m_magicNumber, (uint)Table_head.FieldOffsets.magicNumber); newbuf.SetUshort(m_flags, (uint)Table_head.FieldOffsets.flags); newbuf.SetUshort(m_unitsPerEm, (uint)Table_head.FieldOffsets.unitsPerEm); newbuf.SetLong(m_created, (uint)Table_head.FieldOffsets.created); newbuf.SetLong(m_modified, (uint)Table_head.FieldOffsets.modified); newbuf.SetShort(m_xMin, (uint)Table_head.FieldOffsets.xMin); newbuf.SetShort(m_yMin, (uint)Table_head.FieldOffsets.yMin); newbuf.SetShort(m_xMax, (uint)Table_head.FieldOffsets.xMax); newbuf.SetShort(m_yMax, (uint)Table_head.FieldOffsets.yMax); newbuf.SetUshort(m_macStyle, (uint)Table_head.FieldOffsets.macStyle); newbuf.SetUshort(m_lowestRecPPEM, (uint)Table_head.FieldOffsets.lowestRecPPEM); newbuf.SetShort(m_fontDirectionHint, (uint)Table_head.FieldOffsets.fontDirectionHint); newbuf.SetShort(m_indexToLocFormat, (uint)Table_head.FieldOffsets.indexToLocFormat); newbuf.SetShort(m_glyphDataFormat, (uint)Table_head.FieldOffsets.glyphDataFormat); // put the buffer into a Table_head object and return it Table_head headTable = new Table_head("head", newbuf); return(headTable); }
public override OTTable GenerateTable() { uint iSizeOfTables = 0; ushort nLeft = 0; ushort nRight = 0; short nValue = 0; // Find the sizeof all of the tables for (ushort i = 0; i < m_nTables; i++) { iSizeOfTables += (uint)((SubTableFormat0)m_SubTable[i]).CalculatedLength(); } // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer((uint)FieldOffsets.FirstSubTableHeader + iSizeOfTables); newbuf.SetUshort(m_version, (uint)FieldOffsets.version); newbuf.SetUshort(m_nTables, (uint)FieldOffsets.nTables); uint iOffset = (uint)FieldOffsets.FirstSubTableHeader; //Fill in the tables for (int i = 0; i < m_nTables; i++) { newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).version, (uint)iOffset); iOffset += 2; newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).length, (uint)iOffset); iOffset += 2; newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).coverage, (uint)iOffset); iOffset += 2; newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).nPairs, (uint)iOffset); iOffset += 2; newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).searchRange, (uint)iOffset); iOffset += 2; newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).entrySelector, (uint)iOffset); iOffset += 2; newbuf.SetUshort(((SubTableFormat0)m_SubTable[i]).rangeShift, (uint)iOffset); iOffset += 2; // Cycle through all of the kerning pairs for (int ii = 0; ii < ((SubTableFormat0)m_SubTable[i]).nPairs; ii++) { ((SubTableFormat0)m_SubTable[i]).GetKerningPairAndValue(ii, ref nLeft, ref nRight, ref nValue); newbuf.SetUshort(nLeft, (uint)iOffset); iOffset += 2; newbuf.SetUshort(nRight, (uint)iOffset); iOffset += 2; newbuf.SetShort(nValue, (uint)iOffset); iOffset += 2; } } // put the buffer into a Table_vhmtx object and return it Table_kern kernTable = new Table_kern("kern", newbuf); return(kernTable); }
public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(54); // populate the buffer newbuf.SetFixed(m_Version, (uint)Table_PCLT.FieldOffsets.Version); newbuf.SetUint(m_FontNumber, (uint)Table_PCLT.FieldOffsets.FontNumber); newbuf.SetUshort(m_Pitch, (uint)Table_PCLT.FieldOffsets.Pitch); newbuf.SetUshort(m_xHeight, (uint)Table_PCLT.FieldOffsets.xHeight); newbuf.SetUshort(m_Style, (uint)Table_PCLT.FieldOffsets.Style); newbuf.SetUshort(m_TypeFamily, (uint)Table_PCLT.FieldOffsets.TypeFamily); newbuf.SetUshort(m_CapHeight, (uint)Table_PCLT.FieldOffsets.CapHeight); newbuf.SetUshort(m_SymbolSet, (uint)Table_PCLT.FieldOffsets.SymbolSet); for (uint i = 0; i < 16; i++) { newbuf.SetByte(m_Typeface[i], (uint)Table_PCLT.FieldOffsets.Typeface + i); } for (uint i = 0; i < 8; i++) { newbuf.SetByte(m_CharacterComplement[i], (uint)Table_PCLT.FieldOffsets.CharacterComplement + i); } for (uint i = 0; i < 6; i++) { newbuf.SetByte(m_FileName[i], (uint)Table_PCLT.FieldOffsets.FileName + i); } newbuf.SetShort(m_StrokeWeight, (uint)Table_PCLT.FieldOffsets.StrokeWeight); newbuf.SetShort(m_WidthType, (uint)Table_PCLT.FieldOffsets.WidthType); newbuf.SetByte(m_SerifStyle, (uint)Table_PCLT.FieldOffsets.SerifStyle); newbuf.SetByte(m_Reserved, (uint)Table_PCLT.FieldOffsets.Reserved); // put the buffer into a Table_vhea object and return it Table_PCLT PCLTTable = new Table_PCLT("PCLT", newbuf); return(PCLTTable); }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer((uint)(m_nNumberOfHMetrics * 4) + (uint)((m_nGlyphsInTheFont - m_nNumberOfHMetrics) * 2)); for (ushort i = 0; i < m_nGlyphsInTheFont; i++) { if (i < m_nNumberOfHMetrics) { newbuf.SetUshort(((longHorMetric)m_longHorMetric[i]).advanceWidth, (uint)(i * 4)); newbuf.SetShort(((longHorMetric)m_longHorMetric[i]).lsb, (uint)((i * 4) + 2)); } else { newbuf.SetShort(((longHorMetric)m_longHorMetric[i]).lsb, (uint)(((m_nNumberOfHMetrics - 1) * 4) + (i * 2))); } } // put the buffer into a Table_vhmtx object and return it Table_hmtx hmtxTable = new Table_hmtx("hmtx", newbuf); return(hmtxTable); }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer((uint)(m_nLongVerMetrics * 4) + (uint)((m_nGlyphsInTheFont - m_nLongVerMetrics) * 2)); for (ushort i = 0; i < m_nGlyphsInTheFont; i++) { if (i < m_nLongVerMetrics) { newbuf.SetUshort(((vMetric)m_vMetric[i]).advanceHeight, (uint)(i * 4)); newbuf.SetShort(((vMetric)m_vMetric[i]).topSideBearing, (uint)((i * 4) + 2)); } else { newbuf.SetShort(((vMetric)m_vMetric[i]).topSideBearing, (uint)(((m_nLongVerMetrics - 1) * 4) + (i * 2))); } } // put the buffer into a Table_vhmtx object and return it Table_vmtx vmtxTable = new Table_vmtx("vmtx", newbuf); return(vmtxTable); }
protected byte[] GenerateFormat4Subtable(uint [] map) { bool bFound = false; uint CurChar = 0; ArrayList arrSegments = new ArrayList(); segment4 seg = new segment4(); while (CurChar < map.Length) { // find the startCode char in this segment bFound = false; for (uint i=CurChar; i<map.Length; i++) { if (map[i] != 0) { seg.startCode = (ushort)i; bFound = true; break; } } if (bFound) { // count number of chars available for delta // representation short delta = (short) (map[seg.startCode] - seg.startCode); uint nDelta = 1; for (int i=seg.startCode+1; i<map.Length; i++) { if ((ushort)(i+delta) == (ushort)(map[i])) { nDelta++; } else { break; } } // count number of chars available for rangeoffset // to glyph id representation uint nRangeGlyph=1; if (nDelta == 1) { for (int i=seg.startCode+1; i<map.Length; i++) { if (map[i] == 0) { // don't keep the zero if it's followed // by another zero if (i+1 < map.Length) { if (map[i+1] == 0) { break; } } // don't keep the zero if it's followed by // a delta segment if (i+3 < map.Length) { if ((ushort)(map[i+1]+1) == (ushort)(map[i+2]) && (ushort)(map[i+2]+1) == (ushort)(map[i+3])) { break; } } else { break; } } else if (i+2 < map.Length) { // stop if this is the start of a two // glyph delta segment if ((ushort)(map[i ]+1) == (ushort)(map[i+1]) && (ushort)(map[i+1]+1) == (ushort)(map[i+2])) { break; } } else if (i+1 < map.Length) { // stop if we're at the end of the map if ((ushort)(map[i]+1) == (ushort)(map[i+1])) { break; } } nRangeGlyph++; } } // choose delta or rangeOffset representation if (nDelta >= nRangeGlyph) { // set the endCode character for this segment CurChar = seg.startCode; if (CurChar < 65535) { seg.endCode = (ushort) (seg.startCode + nDelta - 1); CurChar = seg.endCode; } else if (CurChar == 65535) { seg.endCode = 65535; } else { Debug.Assert(false); } Debug.Assert(seg.startCode <= seg.endCode); // calculate the id delta seg.idDelta = (short)(map[seg.startCode] - seg.startCode); // add the segment to the array arrSegments.Add(seg); Debug.Assert(arrSegments.Count < 65536); CurChar = (uint)(seg.endCode + 1); seg = new segment4(); } else { // set the endCode character for this segment CurChar = seg.startCode; if (CurChar < 65535) { seg.endCode = (ushort)(seg.startCode + nRangeGlyph - 1); CurChar = seg.endCode; Debug.Assert(seg.startCode != seg.endCode); } else if (CurChar == 65535) { seg.endCode = 65535; } else { Debug.Assert(false); } // store each character's glyph value in the // glyphID array int nCount = seg.endCode-seg.startCode+1; seg.glyphIdArray = new ushort[nCount]; for (ushort i=0; i<nCount; i++) { seg.glyphIdArray[i] = (ushort)map[seg.startCode+i]; } // add the segment to the array arrSegments.Add(seg); Debug.Assert(arrSegments.Count < 65536); CurChar = (uint)(seg.endCode + 1); seg = new segment4(); } } else { break; } } // add a final segment if needed bool bNeedFinal = true; if (arrSegments.Count != 0) { segment4 lastseg = (segment4) arrSegments[arrSegments.Count-1]; if (lastseg.endCode == 0xffff) { bNeedFinal = false; } } if (bNeedFinal) { segment4 segFinal = new segment4(); segFinal.startCode = 0xffff; segFinal.endCode = 0xffff; segFinal.idDelta = 1; arrSegments.Add(segFinal); } // allocate a buffer for the subtable ushort nSize = (ushort)(16 + 8 * arrSegments.Count); for (int i=0; i<arrSegments.Count; i++) { segment4 s = (segment4)arrSegments[(int)i]; if (s.glyphIdArray != null) { nSize += (ushort)(s.glyphIdArray.Length*2); } } MBOBuffer buf = new MBOBuffer(nSize); // set the data ushort segCountX2 = (ushort)(arrSegments.Count*2); ushort searchRange = (ushort) (2 * util.MaxPower2LE((ushort)(arrSegments.Count))); ushort entrySelector = util.Log2((ushort)(searchRange/2)); ushort rangeShift = (ushort)(segCountX2 - searchRange); buf.SetUshort(4, (uint)Format4.FieldOffsets.format); buf.SetUshort(nSize, (uint)Format4.FieldOffsets.length); buf.SetUshort(0, (uint)Format4.FieldOffsets.language); buf.SetUshort(segCountX2, (uint)Format4.FieldOffsets.segCountX2); buf.SetUshort(searchRange, (uint)Format4.FieldOffsets.searchRange); buf.SetUshort(entrySelector, (uint)Format4.FieldOffsets.entrySelector); buf.SetUshort(rangeShift, (uint)Format4.FieldOffsets.rangeShift); uint endOffset = (uint)Format4.FieldOffsets.endCode; uint startOffset = (uint)Format4.FieldOffsets.endCode + 2*(uint)arrSegments.Count + 2; uint idDeltaOffset = startOffset + 2*(uint)arrSegments.Count; uint idRangeOffset = idDeltaOffset + 2*(uint)arrSegments.Count; int nGlyphIdCount = 0; for (uint i=0; i<arrSegments.Count; i++) { segment4 s = (segment4)arrSegments[(int)i]; if (s.glyphIdArray != null) { s.idRangeOffset = (ushort) ((arrSegments.Count - i + nGlyphIdCount)*2); nGlyphIdCount += s.glyphIdArray.Length; } buf.SetUshort(s.endCode, endOffset + i*2); buf.SetUshort(s.startCode, startOffset + i*2); buf.SetShort(s.idDelta, idDeltaOffset + i*2); buf.SetUshort(s.idRangeOffset, idRangeOffset + i*2); } uint glyphIdPos = idRangeOffset + 2*(uint)arrSegments.Count; for (uint i=0; i<arrSegments.Count; i++) { segment4 s = (segment4)arrSegments[(int)i]; if (s.glyphIdArray != null) { for (uint j=0; j<s.glyphIdArray.Length; j++) { buf.SetUshort(s.glyphIdArray[j], glyphIdPos); glyphIdPos += 2; } } } return buf.GetBuffer(); }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(36); // populate the buffer newbuf.SetFixed (m_version, (uint)Table_vhea.FieldOffsets.version); newbuf.SetShort (m_vertTypoAscender, (uint)Table_vhea.FieldOffsets.vertTypoAscender); newbuf.SetShort (m_vertTypoDescender, (uint)Table_vhea.FieldOffsets.vertTypoDescender); newbuf.SetShort (m_vertTypoLineGap, (uint)Table_vhea.FieldOffsets.vertTypoLineGap); newbuf.SetShort (m_advanceHeightMax, (uint)Table_vhea.FieldOffsets.advanceHeightMax); newbuf.SetShort (m_minTopSideBearing, (uint)Table_vhea.FieldOffsets.minTopSideBearing); newbuf.SetShort (m_minBottomSideBearing, (uint)Table_vhea.FieldOffsets.minBottomSideBearing); newbuf.SetShort (m_yMaxExtent, (uint)Table_vhea.FieldOffsets.yMaxExtent); newbuf.SetShort (m_caretSlopeRise, (uint)Table_vhea.FieldOffsets.caretSlopeRise); newbuf.SetShort (m_caretSlopeRun, (uint)Table_vhea.FieldOffsets.caretSlopeRun); newbuf.SetShort (m_caretOffset, (uint)Table_vhea.FieldOffsets.caretOffset); newbuf.SetShort (m_reserved1, (uint)Table_vhea.FieldOffsets.reserved1); newbuf.SetShort (m_reserved2, (uint)Table_vhea.FieldOffsets.reserved2); newbuf.SetShort (m_reserved3, (uint)Table_vhea.FieldOffsets.reserved3); newbuf.SetShort (m_reserved4, (uint)Table_vhea.FieldOffsets.reserved4); newbuf.SetShort (m_metricDataFormat, (uint)Table_vhea.FieldOffsets.metricDataFormat); newbuf.SetUshort (m_numOfLongVerMetrics, (uint)Table_vhea.FieldOffsets.numOfLongVerMetrics); // put the buffer into a Table_vhea object and return it Table_vhea vheaTable = new Table_vhea("vhea", newbuf); return vheaTable; }
public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf; uint nSizeOfIndexAndNames = 0; if( m_Version.GetUint() == 0x00020000 ) { uint nSizeOfByteArray = 0; // Get what the size of the byte array will be for(int i = 0; i < m_names.Count; i++ ) { nSizeOfByteArray += (uint)(((string)m_names[i]).Length + 1); } // Add 2 for the ushort numberOfGlyphs nSizeOfIndexAndNames = (uint)(2 + (m_numberOfGlyphs * 2) + nSizeOfByteArray); } newbuf = new MBOBuffer(32 + nSizeOfIndexAndNames); newbuf.SetFixed( m_Version, (uint)Table_post.FieldOffsets.Version ); newbuf.SetFixed( m_italicAngle, (uint)Table_post.FieldOffsets.italicAngle ); newbuf.SetShort( m_underlinePosition, (uint)Table_post.FieldOffsets.underlinePosition ); newbuf.SetShort( m_underlineThickness, (uint)Table_post.FieldOffsets.underlineThickness ); newbuf.SetUint( m_isFixedPitch, (uint)Table_post.FieldOffsets.isFixedPitch ); newbuf.SetUint( m_minMemType42, (uint)Table_post.FieldOffsets.minMemType42 ); newbuf.SetUint( m_maxMemType42, (uint)Table_post.FieldOffsets.maxMemType42 ); newbuf.SetUint( m_minMemType1, (uint)Table_post.FieldOffsets.minMemType1); newbuf.SetUint( m_maxMemType1, (uint)Table_post.FieldOffsets.maxMemType1); if( m_Version.GetUint() == 0x00020000 ) { newbuf.SetUshort( m_numberOfGlyphs, (uint)Table_post.FieldOffsetsVer2.numberOfGlyphs); uint nOffset = (uint)Table_post.FieldOffsetsVer2.glyphNameIndex; for( int i = 0; i < m_numberOfGlyphs; i++ ) { newbuf.SetUshort( (ushort)m_glyphNameIndex[i], nOffset ); nOffset += 2; } // write out the names to the buffer in length followed by character bytes for( int i = 0; i < m_names.Count; i++ ) { string sName = (string)m_names[i]; newbuf.SetByte( (byte)sName.Length, nOffset ); nOffset++; for( int ii = 0; ii < sName.Length; ii++ ) { newbuf.SetByte( (byte)sName[ii], nOffset ); nOffset++; } } } // put the buffer into a Table_maxp object and return it Table_post postTable = new Table_post("post", newbuf); return postTable; }
public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(54); // populate the buffer newbuf.SetFixed( m_Version, (uint)Table_PCLT.FieldOffsets.Version ); newbuf.SetUint( m_FontNumber, (uint)Table_PCLT.FieldOffsets.FontNumber ); newbuf.SetUshort( m_Pitch, (uint)Table_PCLT.FieldOffsets.Pitch ); newbuf.SetUshort( m_xHeight, (uint)Table_PCLT.FieldOffsets.xHeight ); newbuf.SetUshort( m_Style, (uint)Table_PCLT.FieldOffsets.Style ); newbuf.SetUshort( m_TypeFamily, (uint)Table_PCLT.FieldOffsets.TypeFamily ); newbuf.SetUshort( m_CapHeight, (uint)Table_PCLT.FieldOffsets.CapHeight ); newbuf.SetUshort( m_SymbolSet, (uint)Table_PCLT.FieldOffsets.SymbolSet ); for( uint i = 0; i < 16; i++ ) { newbuf.SetByte( m_Typeface[i], (uint)Table_PCLT.FieldOffsets.Typeface + i ); } for( uint i = 0; i < 8; i++ ) { newbuf.SetByte( m_CharacterComplement[i],(uint)Table_PCLT.FieldOffsets.CharacterComplement + i ); } for( uint i = 0; i < 6; i++ ) { newbuf.SetByte( m_FileName[i], (uint)Table_PCLT.FieldOffsets.FileName + i ); } newbuf.SetShort( m_StrokeWeight, (uint)Table_PCLT.FieldOffsets.StrokeWeight ); newbuf.SetShort( m_WidthType, (uint)Table_PCLT.FieldOffsets.WidthType ); newbuf.SetByte( m_SerifStyle, (uint)Table_PCLT.FieldOffsets.SerifStyle ); newbuf.SetByte( m_Reserved, (uint)Table_PCLT.FieldOffsets.Reserved ); // put the buffer into a Table_vhea object and return it Table_PCLT PCLTTable = new Table_PCLT("PCLT", newbuf); return PCLTTable; }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer((uint)(m_nLongVerMetrics * 4) + (uint)((m_nGlyphsInTheFont - m_nLongVerMetrics) * 2)); for( ushort i = 0; i < m_nGlyphsInTheFont; i++ ) { if( i < m_nLongVerMetrics ) { newbuf.SetUshort( ((vMetric)m_vMetric[i]).advanceHeight, (uint)(i * 4 )); newbuf.SetShort ( ((vMetric)m_vMetric[i]).topSideBearing, (uint)((i * 4) + 2)); } else { newbuf.SetShort ( ((vMetric)m_vMetric[i]).topSideBearing, (uint)(((m_nLongVerMetrics - 1)* 4) + (i * 2))); } } // put the buffer into a Table_vhmtx object and return it Table_vmtx vmtxTable = new Table_vmtx("vmtx", newbuf); return vmtxTable; }
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 override OTTable GenerateTable() { uint iSizeOfTables = 0; ushort nLeft = 0; ushort nRight = 0; short nValue = 0; // Find the sizeof all of the tables for( ushort i = 0; i < m_nTables; i++ ) { iSizeOfTables += (uint)((SubTableFormat0)m_SubTable[i]).CalculatedLength(); } // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer( (uint)FieldOffsets.FirstSubTableHeader + iSizeOfTables ); newbuf.SetUshort( m_version, (uint)FieldOffsets.version ); newbuf.SetUshort( m_nTables, (uint)FieldOffsets.nTables ); uint iOffset = (uint)FieldOffsets.FirstSubTableHeader; //Fill in the tables for( int i = 0; i < m_nTables; i++ ) { newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).version, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).length, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).coverage, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).nPairs, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).searchRange, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).entrySelector, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( ((SubTableFormat0)m_SubTable[i]).rangeShift, (uint)iOffset ); iOffset += 2; // Cycle through all of the kerning pairs for( int ii = 0; ii < ((SubTableFormat0)m_SubTable[i]).nPairs; ii++ ) { ((SubTableFormat0)m_SubTable[i]).GetKerningPairAndValue( ii, ref nLeft, ref nRight, ref nValue ); newbuf.SetUshort( nLeft, (uint)iOffset ); iOffset += 2; newbuf.SetUshort( nRight, (uint)iOffset ); iOffset += 2; newbuf.SetShort( nValue, (uint)iOffset ); iOffset += 2; } } // put the buffer into a Table_vhmtx object and return it Table_kern kernTable = new Table_kern("kern", newbuf); return kernTable; }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(36); // populate the buffer newbuf.SetFixed(m_version, (uint)Table_vhea.FieldOffsets.version); newbuf.SetShort(m_vertTypoAscender, (uint)Table_vhea.FieldOffsets.vertTypoAscender); newbuf.SetShort(m_vertTypoDescender, (uint)Table_vhea.FieldOffsets.vertTypoDescender); newbuf.SetShort(m_vertTypoLineGap, (uint)Table_vhea.FieldOffsets.vertTypoLineGap); newbuf.SetShort(m_advanceHeightMax, (uint)Table_vhea.FieldOffsets.advanceHeightMax); newbuf.SetShort(m_minTopSideBearing, (uint)Table_vhea.FieldOffsets.minTopSideBearing); newbuf.SetShort(m_minBottomSideBearing, (uint)Table_vhea.FieldOffsets.minBottomSideBearing); newbuf.SetShort(m_yMaxExtent, (uint)Table_vhea.FieldOffsets.yMaxExtent); newbuf.SetShort(m_caretSlopeRise, (uint)Table_vhea.FieldOffsets.caretSlopeRise); newbuf.SetShort(m_caretSlopeRun, (uint)Table_vhea.FieldOffsets.caretSlopeRun); newbuf.SetShort(m_caretOffset, (uint)Table_vhea.FieldOffsets.caretOffset); newbuf.SetShort(m_reserved1, (uint)Table_vhea.FieldOffsets.reserved1); newbuf.SetShort(m_reserved2, (uint)Table_vhea.FieldOffsets.reserved2); newbuf.SetShort(m_reserved3, (uint)Table_vhea.FieldOffsets.reserved3); newbuf.SetShort(m_reserved4, (uint)Table_vhea.FieldOffsets.reserved4); newbuf.SetShort(m_metricDataFormat, (uint)Table_vhea.FieldOffsets.metricDataFormat); newbuf.SetUshort(m_numOfLongVerMetrics, (uint)Table_vhea.FieldOffsets.numOfLongVerMetrics); // put the buffer into a Table_vhea object and return it Table_vhea vheaTable = new Table_vhea("vhea", newbuf); return(vheaTable); }
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 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 override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(36); // populate the buffer newbuf.SetFixed(m_TableVersionNumber, (uint)Table_hhea.FieldOffsets.TableVersionNumber); newbuf.SetShort(m_Ascender, (uint)Table_hhea.FieldOffsets.Ascender); newbuf.SetShort(m_Descender, (uint)Table_hhea.FieldOffsets.Descender); newbuf.SetShort(m_LineGap, (uint)Table_hhea.FieldOffsets.LineGap); newbuf.SetUshort(m_advanceWidthMax, (uint)Table_hhea.FieldOffsets.advanceWidthMax); newbuf.SetShort(m_minLeftSideBearing, (uint)Table_hhea.FieldOffsets.minLeftSideBearing); newbuf.SetShort(m_minRightSideBearing, (uint)Table_hhea.FieldOffsets.minRightSideBearing); newbuf.SetShort(m_xMaxExtent, (uint)Table_hhea.FieldOffsets.xMaxExtent); newbuf.SetShort(m_caretSlopeRise, (uint)Table_hhea.FieldOffsets.caretSlopeRise); newbuf.SetShort(m_caretSlopeRun, (uint)Table_hhea.FieldOffsets.caretSlopeRun); newbuf.SetShort(m_caretOffset, (uint)Table_hhea.FieldOffsets.caretOffset); newbuf.SetShort(m_reserved1, (uint)Table_hhea.FieldOffsets.reserved1); newbuf.SetShort(m_reserved2, (uint)Table_hhea.FieldOffsets.reserved2); newbuf.SetShort(m_reserved3, (uint)Table_hhea.FieldOffsets.reserved3); newbuf.SetShort(m_reserved4, (uint)Table_hhea.FieldOffsets.reserved4); newbuf.SetShort(m_metricDataFormat, (uint)Table_hhea.FieldOffsets.metricDataFormat); newbuf.SetUshort(m_numberOfHMetrics, (uint)Table_hhea.FieldOffsets.numberOfHMetrics); // put the buffer into a Table_vhea object and return it Table_hhea hheaTable = new Table_hhea("hhea", newbuf); return(hheaTable); }
public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(36); // populate the buffer newbuf.SetFixed( m_TableVersionNumber, (uint)Table_hhea.FieldOffsets.TableVersionNumber ); newbuf.SetShort( m_Ascender, (uint)Table_hhea.FieldOffsets.Ascender ); newbuf.SetShort( m_Descender, (uint)Table_hhea.FieldOffsets.Descender ); newbuf.SetShort( m_LineGap, (uint)Table_hhea.FieldOffsets.LineGap ); newbuf.SetUshort( m_advanceWidthMax, (uint)Table_hhea.FieldOffsets.advanceWidthMax ); newbuf.SetShort( m_minLeftSideBearing, (uint)Table_hhea.FieldOffsets.minLeftSideBearing ); newbuf.SetShort( m_minRightSideBearing, (uint)Table_hhea.FieldOffsets.minRightSideBearing ); newbuf.SetShort( m_xMaxExtent, (uint)Table_hhea.FieldOffsets.xMaxExtent ); newbuf.SetShort( m_caretSlopeRise, (uint)Table_hhea.FieldOffsets.caretSlopeRise ); newbuf.SetShort( m_caretSlopeRun, (uint)Table_hhea.FieldOffsets.caretSlopeRun ); newbuf.SetShort( m_caretOffset, (uint)Table_hhea.FieldOffsets.caretOffset ); newbuf.SetShort( m_reserved1, (uint)Table_hhea.FieldOffsets.reserved1 ); newbuf.SetShort( m_reserved2, (uint)Table_hhea.FieldOffsets.reserved2 ); newbuf.SetShort( m_reserved3, (uint)Table_hhea.FieldOffsets.reserved3 ); newbuf.SetShort( m_reserved4, (uint)Table_hhea.FieldOffsets.reserved4 ); newbuf.SetShort( m_metricDataFormat, (uint)Table_hhea.FieldOffsets.metricDataFormat ); newbuf.SetUshort( m_numberOfHMetrics, (uint)Table_hhea.FieldOffsets.numberOfHMetrics ); // put the buffer into a Table_vhea object and return it Table_hhea hheaTable = new Table_hhea("hhea", newbuf); return hheaTable; }
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; }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer((uint)(m_nNumberOfHMetrics * 4) + (uint)((m_nGlyphsInTheFont - m_nNumberOfHMetrics) * 2)); for( ushort i = 0; i < m_nGlyphsInTheFont; i++ ) { if( i < m_nNumberOfHMetrics ) { newbuf.SetUshort( ((longHorMetric)m_longHorMetric[i]).advanceWidth, (uint)(i * 4 )); newbuf.SetShort ( ((longHorMetric)m_longHorMetric[i]).lsb, (uint)((i * 4) + 2)); } else { newbuf.SetShort ( ((longHorMetric)m_longHorMetric[i]).lsb, (uint)(((m_nNumberOfHMetrics - 1)* 4) + (i * 2))); } } // put the buffer into a Table_vhmtx object and return it Table_hmtx hmtxTable = new Table_hmtx("hmtx", newbuf); return hmtxTable; }
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; }
// generate a new table from the cached data public override OTTable GenerateTable() { // create a Motorola Byte Order buffer for the new table MBOBuffer newbuf = new MBOBuffer(54); // populate the buffer newbuf.SetFixed (m_TableVersion, (uint)Table_head.FieldOffsets.TableVersionNumber); newbuf.SetFixed (m_fontRevision, (uint)Table_head.FieldOffsets.fontRevision); newbuf.SetUint (m_checkSumAdjustment, (uint)Table_head.FieldOffsets.checkSumAdjustment); newbuf.SetUint (m_magicNumber, (uint)Table_head.FieldOffsets.magicNumber); newbuf.SetUshort(m_flags, (uint)Table_head.FieldOffsets.flags); newbuf.SetUshort(m_unitsPerEm, (uint)Table_head.FieldOffsets.unitsPerEm); newbuf.SetLong (m_created, (uint)Table_head.FieldOffsets.created); newbuf.SetLong (m_modified, (uint)Table_head.FieldOffsets.modified); newbuf.SetShort (m_xMin, (uint)Table_head.FieldOffsets.xMin); newbuf.SetShort (m_yMin, (uint)Table_head.FieldOffsets.yMin); newbuf.SetShort (m_xMax, (uint)Table_head.FieldOffsets.xMax); newbuf.SetShort (m_yMax, (uint)Table_head.FieldOffsets.yMax); newbuf.SetUshort(m_macStyle, (uint)Table_head.FieldOffsets.macStyle); newbuf.SetUshort(m_lowestRecPPEM, (uint)Table_head.FieldOffsets.lowestRecPPEM); newbuf.SetShort (m_fontDirectionHint, (uint)Table_head.FieldOffsets.fontDirectionHint); newbuf.SetShort (m_indexToLocFormat, (uint)Table_head.FieldOffsets.indexToLocFormat); newbuf.SetShort (m_glyphDataFormat, (uint)Table_head.FieldOffsets.glyphDataFormat); // put the buffer into a Table_head object and return it Table_head headTable = new Table_head("head", newbuf); return headTable; }