Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
            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);
            }
Exemplo n.º 4
0
            public override OTTable GenerateTable()
            {
                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer((uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(Table_EBSC.bitmapScaleTable.length * m_numSizes));

                // populate the buffer
                newbuf.SetFixed(m_version, (uint)Table_EBSC.FieldOffsets.version);
                newbuf.SetUint(m_numSizes, (uint)Table_EBSC.FieldOffsets.numSizes);

                for (uint i = 0; i < m_numSizes; i++)
                {
                    bitmapScaleTable bst = (bitmapScaleTable)m_bitmapScaleTables[(int)i];

                    newbuf.SetSbyte(bst.hori.ascender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length));
                    newbuf.SetSbyte(bst.hori.descender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 1);
                    newbuf.SetByte(bst.hori.widthMax, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 2);
                    newbuf.SetSbyte(bst.hori.caretSlopeNumerator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 3);
                    newbuf.SetSbyte(bst.hori.caretSlopeDenominator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 4);
                    newbuf.SetSbyte(bst.hori.caretOffset, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 5);
                    newbuf.SetSbyte(bst.hori.minOriginSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 6);
                    newbuf.SetSbyte(bst.hori.minAdvanceSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 7);
                    newbuf.SetSbyte(bst.hori.maxBeforeBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 8);
                    newbuf.SetSbyte(bst.hori.minAfterBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 9);
                    newbuf.SetSbyte(bst.hori.pad1, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 10);
                    newbuf.SetSbyte(bst.hori.pad2, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 11);


                    newbuf.SetSbyte(bst.vert.ascender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 12);
                    newbuf.SetSbyte(bst.vert.descender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 13);
                    newbuf.SetByte(bst.vert.widthMax, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 14);
                    newbuf.SetSbyte(bst.vert.caretSlopeNumerator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 15);
                    newbuf.SetSbyte(bst.vert.caretSlopeDenominator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 16);
                    newbuf.SetSbyte(bst.vert.caretOffset, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 17);
                    newbuf.SetSbyte(bst.vert.minOriginSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 18);
                    newbuf.SetSbyte(bst.vert.minAdvanceSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 19);
                    newbuf.SetSbyte(bst.vert.maxBeforeBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 20);
                    newbuf.SetSbyte(bst.vert.minAfterBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 21);
                    newbuf.SetSbyte(bst.vert.pad1, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 22);
                    newbuf.SetSbyte(bst.vert.pad2, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 23);

                    newbuf.SetByte(bst.ppemX, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 24);
                    newbuf.SetByte(bst.ppemY, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 25);
                    newbuf.SetByte(bst.substitutePpemX, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 26);
                    newbuf.SetByte(bst.substitutePpemY, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 27);
                }

                // put the buffer into a Table_EBSC object and return it
                Table_EBSC EBSCTable = new Table_EBSC("EBSC", newbuf);

                return(EBSCTable);
            }
Exemplo n.º 5
0
            public override OTTable GenerateTable()
            {
                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer((uint)(Table_LTSH.FieldOffsets.yPels + m_numGlyphs));

                newbuf.SetUshort(m_version, (uint)Table_LTSH.FieldOffsets.version);
                newbuf.SetUshort(m_numGlyphs, (uint)Table_LTSH.FieldOffsets.numGlyphs);

                // Fill the buffer with the yPels
                for (int i = 0; i < m_numGlyphs; i++)
                {
                    newbuf.SetByte(m_yPels[i], (uint)(Table_LTSH.FieldOffsets.yPels + i));
                }

                // put the buffer into a Table_maxp object and return it
                Table_LTSH LTSHTable = new Table_LTSH("LTSH", newbuf);

                return(LTSHTable);
            }
Exemplo n.º 6
0
            private void writeEBDTBuffer( MBOBuffer bufEBDT, uint imageDataOffset, imageCache ic, ushort imageFormat )
            {                
                switch( imageFormat )
                {
                    case 1:
                    {
                        imageCache1 ic1 = (imageCache1)ic;

                        bufEBDT.SetByte( ic1.smallMetrics.height,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.height );
                        bufEBDT.SetByte( ic1.smallMetrics.width,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.width );
                        bufEBDT.SetSbyte( ic1.smallMetrics.BearingX,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingX );
                        bufEBDT.SetSbyte( ic1.smallMetrics.BearingY,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingY );
                        bufEBDT.SetByte( ic1.smallMetrics.Advance,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.Advance );
                        
                        System.Buffer.BlockCopy( ic1.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.smallGlyphMetrics.bufSize), ic1.imageData.Length );
                        break;                    
                    }
                    case 2:
                    {
                        imageCache2 ic2 = (imageCache2)ic;

                        bufEBDT.SetByte( ic2.smallMetrics.height,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.height );
                        bufEBDT.SetByte( ic2.smallMetrics.width,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.width );
                        bufEBDT.SetSbyte( ic2.smallMetrics.BearingX,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingX );
                        bufEBDT.SetSbyte( ic2.smallMetrics.BearingY,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingY );
                        bufEBDT.SetByte( ic2.smallMetrics.Advance,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.Advance );
                        
                        System.Buffer.BlockCopy( ic2.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.smallGlyphMetrics.bufSize), ic2.imageData.Length );
                        break;
                    }
                    case 5:
                    {
                        imageCache5 ic5 = (imageCache5)ic;
                    
                        System.Buffer.BlockCopy( ic5.imageData, 0, bufEBDT.GetBuffer(), (int)imageDataOffset, ic5.imageData.Length );
                        break;
                    }
                    case 6:
                    {
                        imageCache6 ic6 = (imageCache6)ic;

                        bufEBDT.SetByte( ic6.bigMetrics.height,            imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
                        bufEBDT.SetByte( ic6.bigMetrics.width,            imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
                        bufEBDT.SetSbyte( ic6.bigMetrics.horiBearingX,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
                        bufEBDT.SetSbyte( ic6.bigMetrics.horiBearingY,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
                        bufEBDT.SetByte( ic6.bigMetrics.horiAdvance,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
                        bufEBDT.SetSbyte( ic6.bigMetrics.vertBearingX,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
                        bufEBDT.SetSbyte( ic6.bigMetrics.vertBearingY,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
                        bufEBDT.SetByte( ic6.bigMetrics.vertAdvance,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );                        
                        
                        System.Buffer.BlockCopy( ic6.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.bigGlyphMetrics.bufSize), ic6.imageData.Length );
                        break;
                    }
                    case 7:
                    {
                        imageCache7 ic7 = (imageCache7)ic;

                        bufEBDT.SetByte( ic7.bigMetrics.height,            imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
                        bufEBDT.SetByte( ic7.bigMetrics.width,            imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
                        bufEBDT.SetSbyte( ic7.bigMetrics.horiBearingX,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
                        bufEBDT.SetSbyte( ic7.bigMetrics.horiBearingY,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
                        bufEBDT.SetByte( ic7.bigMetrics.horiAdvance,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
                        bufEBDT.SetSbyte( ic7.bigMetrics.vertBearingX,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
                        bufEBDT.SetSbyte( ic7.bigMetrics.vertBearingY,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
                        bufEBDT.SetByte( ic7.bigMetrics.vertAdvance,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );                        
                        
                        System.Buffer.BlockCopy( ic7.imageData, 0, bufEBDT.GetBuffer(), (int)(imageDataOffset + Table_EBDT.bigGlyphMetrics.bufSize), ic7.imageData.Length );
                        break;
                    }
                    case 8:
                    {
                        imageCache8 ic8 = (imageCache8)ic;

                        bufEBDT.SetByte( ic8.smallMetrics.height,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.height );
                        bufEBDT.SetByte( ic8.smallMetrics.width,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.width );
                        bufEBDT.SetSbyte( ic8.smallMetrics.BearingX,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingX );
                        bufEBDT.SetSbyte( ic8.smallMetrics.BearingY,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.BearingY );
                        bufEBDT.SetByte( ic8.smallMetrics.Advance,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.FieldOffsets.Advance );                    
                        //pad
                        bufEBDT.SetByte( 0,                        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize );    
                        bufEBDT.SetUshort( ic8.numComponents,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 1 );    
                        
                        for( ushort i = 0; i < ic8.numComponents; i++ )
                        {
                            Table_EBDT.ebdtComponent ec = ic8.getComponent( i );
                            bufEBDT.SetUshort( ec.glyphCode,    imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 3 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ));
                            bufEBDT.SetSbyte( ec.xOffset,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 3 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ) + 2 );
                            bufEBDT.SetSbyte( ec.yOffset,        imageDataOffset + (uint)Table_EBDT.smallGlyphMetrics.bufSize + 3 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ) + 3 );    
                        }
                        break;
                    }
                    case 9:
                    {
                        imageCache9 ic9 = (imageCache9)ic;

                        bufEBDT.SetByte( ic9.bigMetrics.height,            imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
                        bufEBDT.SetByte( ic9.bigMetrics.width,            imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
                        bufEBDT.SetSbyte( ic9.bigMetrics.horiBearingX,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
                        bufEBDT.SetSbyte( ic9.bigMetrics.horiBearingY,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
                        bufEBDT.SetByte( ic9.bigMetrics.horiAdvance,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
                        bufEBDT.SetSbyte( ic9.bigMetrics.vertBearingX,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
                        bufEBDT.SetSbyte( ic9.bigMetrics.vertBearingY,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
                        bufEBDT.SetByte( ic9.bigMetrics.vertAdvance,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );                            
                        
                        bufEBDT.SetUshort( ic9.numComponents,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.bufSize );    
                        
                        for( ushort i = 0; i < ic9.numComponents; i++ )
                        {
                            Table_EBDT.ebdtComponent ec = ic9.getComponent( i );
                            bufEBDT.SetUshort( ec.glyphCode,    imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.bufSize + 2 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ));
                            bufEBDT.SetSbyte( ec.xOffset,        imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.bufSize + 2 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ) + 2 );
                            bufEBDT.SetSbyte( ec.yOffset,        imageDataOffset + (uint)Table_EBDT.bigGlyphMetrics.bufSize + 2 + (uint)(Table_EBDT.ebdtComponent.bufSize * i ) + 3 );    
                        }
                        break;
                    }
                }                
            }
Exemplo n.º 7
0
            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;
            }
Exemplo n.º 8
0
            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;
            }
Exemplo n.º 9
0
            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;
            }
Exemplo n.º 10
0
            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;    
            }
Exemplo n.º 11
0
            protected byte[] GenerateFormat0Subtable( uint [] map, 
                                                      ushort language )
            {
                // allocate the buffer
                MBOBuffer buf = new MBOBuffer(262);

                // set the data

                buf.SetUshort(0, (uint)Format0.FieldOffsets.format);
                buf.SetUshort(262, (uint)Format0.FieldOffsets.length);
                buf.SetUshort(language, (uint)Format0.FieldOffsets.language);
                for (int i=0; i<256; i++)
                {
                    buf.SetByte((byte)map[i], 
                                (uint)Format0.FieldOffsets.glyphIDArray + 
                                (uint)i);
                }

                // return the buffer

                return buf.GetBuffer();
            }
Exemplo n.º 12
0
            public override OTTable GenerateTable()
            {
                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer( (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(Table_EBSC.bitmapScaleTable.length * m_numSizes));

                // populate the buffer                
                newbuf.SetFixed( m_version,                (uint)Table_EBSC.FieldOffsets.version );
                newbuf.SetUint( m_numSizes,                (uint)Table_EBSC.FieldOffsets.numSizes );                

                for( uint i = 0; i < m_numSizes; i++ )
                {
                    bitmapScaleTable bst = (bitmapScaleTable)m_bitmapScaleTables[(int)i];

                    newbuf.SetSbyte( bst.hori.ascender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length)); 
                    newbuf.SetSbyte( bst.hori.descender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 1 );
                    newbuf.SetByte( bst.hori.widthMax, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 2 );
                    newbuf.SetSbyte( bst.hori.caretSlopeNumerator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 3 );
                    newbuf.SetSbyte( bst.hori.caretSlopeDenominator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 4 );
                    newbuf.SetSbyte( bst.hori.caretOffset, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 5 );
                    newbuf.SetSbyte( bst.hori.minOriginSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 6 );
                    newbuf.SetSbyte( bst.hori.minAdvanceSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 7 );
                    newbuf.SetSbyte( bst.hori.maxBeforeBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 8 );
                    newbuf.SetSbyte( bst.hori.minAfterBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 9 );
                    newbuf.SetSbyte( bst.hori.pad1, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 10 );
                    newbuf.SetSbyte( bst.hori.pad2, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 11 );

                    
                    newbuf.SetSbyte( bst.vert.ascender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 12 ); 
                    newbuf.SetSbyte( bst.vert.descender, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 13 );
                    newbuf.SetByte( bst.vert.widthMax, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 14 );
                    newbuf.SetSbyte( bst.vert.caretSlopeNumerator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 15 );
                    newbuf.SetSbyte( bst.vert.caretSlopeDenominator, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 16 );
                    newbuf.SetSbyte( bst.vert.caretOffset, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 17 );
                    newbuf.SetSbyte( bst.vert.minOriginSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 18 );
                    newbuf.SetSbyte( bst.vert.minAdvanceSB, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 19 );
                    newbuf.SetSbyte( bst.vert.maxBeforeBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 20 );
                    newbuf.SetSbyte( bst.vert.minAfterBL, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 21 );
                    newbuf.SetSbyte( bst.vert.pad1, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 22 );
                    newbuf.SetSbyte( bst.vert.pad2, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 23 );

                    newbuf.SetByte( bst.ppemX, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 24 );
                    newbuf.SetByte( bst.ppemY, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 25 );
                    newbuf.SetByte( bst.substitutePpemX, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 26 );
                    newbuf.SetByte( bst.substitutePpemY, (uint)Table_EBSC.FieldOffsets.FirstBitmapScaleTable + (uint)(i * Table_EBSC.bitmapScaleTable.length) + 27 );                    
                }

                // put the buffer into a Table_EBSC object and return it
                Table_EBSC EBSCTable = new Table_EBSC("EBSC", newbuf);

                return EBSCTable;
            }
Exemplo n.º 13
0
            public override OTTable GenerateTable()
            {
                uint nBufSize = (uint)Table_EBLC.FieldOffsets.FirstbitmapSizeTable;
        
                for( ushort i = 0; i < m_numSizes; i++ )
                {
                    bitmapSizeTableCache bstc = (bitmapSizeTableCache)m_bitmapSizeTables[i];
                    nBufSize += bitmapSizeTable.bufSize;
                    nBufSize += bstc.indexSubTablesSize;
                }

                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer( nBufSize );

                // Determine the size of the EBDTTable and create its buffer
                uint nEBDTBufSize = (uint)Table_EBDT.FieldOffsets.StartOfData;
                for( ushort i = 0; i < m_numSizes; i++ )
                {
                    bitmapSizeTableCache bstc = (bitmapSizeTableCache)m_bitmapSizeTables[i];
                    for( int ii = 0; ii < bstc.numberOfIndexSubTables; ii++ )
                    {
                        indexSubTableArrayCache istac = bstc.getIndexSubTableArrayCache( ii );
                        nEBDTBufSize += istac.indexSubTable.imageDataSize();
                    }
                }            

                // create a Motorola Byte Order buffer for the EBDT table
                MBOBuffer bufEBDT = new MBOBuffer( nEBDTBufSize );
                
                newbuf.SetFixed( m_version,        (uint)Table_EBLC.FieldOffsets.version );
                newbuf.SetUint( m_numSizes,        (uint)Table_EBLC.FieldOffsets.numSizes );

                //Set up initial offsets
                uint idxArrOffset = (uint)Table_EBLC.FieldOffsets.FirstbitmapSizeTable + (bitmapSizeTable.bufSize * m_numSizes);                
                uint imageDataOffset = (uint)Table_EBDT.FieldOffsets.StartOfData; //EBDTTable        

                for( ushort i = 0; i < m_numSizes; i++ )
                {
                    bitmapSizeTableCache bstc = (bitmapSizeTableCache)m_bitmapSizeTables[i];
                    //Set the offset to the bitmapSizeTable
                    uint bstOffset = (uint)(Table_EBLC.FieldOffsets.FirstbitmapSizeTable + (i * bitmapSizeTable.bufSize));

                    newbuf.SetUint( idxArrOffset, bstOffset );
                    newbuf.SetUint( bstc.indexSubTablesSize,        bstOffset +  (uint)bitmapSizeTable.FieldOffsets.indexTablesSize ); 
                    newbuf.SetUint( bstc.numberOfIndexSubTables,    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.numberOfIndexSubTables );
                    newbuf.SetUint( bstc.colorRef,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.colorRef );
                    // hori
                    newbuf.SetSbyte( bstc.hori.ascender,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.ascender );
                    newbuf.SetSbyte( bstc.hori.descender,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.descender );
                    newbuf.SetByte( bstc.hori.widthMax,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.widthMax );
                    newbuf.SetSbyte( bstc.hori.caretSlopeNumerator,        bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.caretSlopeNumerator );
                    newbuf.SetSbyte( bstc.hori.caretSlopeDenominator,    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.caretSlopeDenominator );
                    newbuf.SetSbyte( bstc.hori.caretOffset,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.caretOffset );
                    newbuf.SetSbyte( bstc.hori.minOriginSB,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.minOriginSB );
                    newbuf.SetSbyte( bstc.hori.minAdvanceSB,            bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.minAdvanceSB );
                    newbuf.SetSbyte( bstc.hori.maxBeforeBL,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.maxBeforeBL );
                    newbuf.SetSbyte( bstc.hori.minAfterBL,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.minAfterBL );
                    newbuf.SetSbyte( bstc.hori.pad1,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.pad1 );
                    newbuf.SetSbyte( bstc.hori.pad2,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.pad2 );
                    //vert
                    newbuf.SetSbyte( bstc.vert.ascender,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.ascender );
                    newbuf.SetSbyte( bstc.vert.descender,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.descender );
                    newbuf.SetByte( bstc.vert.widthMax,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.widthMax );
                    newbuf.SetSbyte( bstc.vert.caretSlopeNumerator,        bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.caretSlopeNumerator );
                    newbuf.SetSbyte( bstc.vert.caretSlopeDenominator,    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.caretSlopeDenominator );
                    newbuf.SetSbyte( bstc.vert.caretOffset,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.caretOffset );
                    newbuf.SetSbyte( bstc.vert.minOriginSB,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.minOriginSB );
                    newbuf.SetSbyte( bstc.vert.minAdvanceSB,            bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.minAdvanceSB );
                    newbuf.SetSbyte( bstc.vert.maxBeforeBL,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.maxBeforeBL );
                    newbuf.SetSbyte( bstc.vert.minAfterBL,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.minAfterBL );
                    newbuf.SetSbyte( bstc.vert.pad1,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.pad1 );
                    newbuf.SetSbyte( bstc.vert.pad2,                    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.hori + (uint)sbitLineMetrics.FieldOffsets.pad2 );
                    
                    newbuf.SetUshort( bstc.startGlyphIndex,    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.startGlyphIndex );
                    newbuf.SetUshort( bstc.endGlyphIndex,    bstOffset +  (uint)bitmapSizeTable.FieldOffsets.endGlyphIndex );
                    newbuf.SetByte( bstc.ppemX,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.ppemX );
                    newbuf.SetByte( bstc.ppemY,                bstOffset +  (uint)bitmapSizeTable.FieldOffsets.ppemY );
                    newbuf.SetByte( bstc.bitDepth,            bstOffset +  (uint)bitmapSizeTable.FieldOffsets.bitDepth );
                    newbuf.SetSbyte( bstc.flags,            bstOffset +  (uint)bitmapSizeTable.FieldOffsets.flags );                    

                    uint idxSubTableOffset = idxArrOffset + (bstc.numberOfIndexSubTables * indexSubTableArray.bufSize);
                    

                    // Write this bitmapSizeTable indexSubTableArray and indexSubTable                    
                    for( int ii = 0; ii < bstc.numberOfIndexSubTables; ii++ )
                    {
                        
                        // Write out the indexSubTableArray
                        indexSubTableArrayCache istac = bstc.getIndexSubTableArrayCache( ii );
                        newbuf.SetUshort( istac.firstGlyphIndex,            idxArrOffset + (uint)indexSubTableArray.FieldOffsets.firstGlyphIndex + (uint)(ii * indexSubTableArray.bufSize));
                        newbuf.SetUshort( istac.lastGlyphIndex,                idxArrOffset + (uint)indexSubTableArray.FieldOffsets.lastGlyphIndex + (uint)(ii * indexSubTableArray.bufSize));                        
                        newbuf.SetUint( (idxSubTableOffset - idxArrOffset),    idxArrOffset + (uint)indexSubTableArray.FieldOffsets.additionalOffsetToIndexSubtable + (uint)(ii * indexSubTableArray.bufSize));
                        
                        // Write out the indexSubTable, The header is the same for all indexFormats
                        newbuf.SetUshort( istac.indexSubTable.indexFormat,    idxSubTableOffset + (uint)indexSubHeader.FieldOffsets.indexFormat );
                        newbuf.SetUshort( istac.indexSubTable.imageFormat,    idxSubTableOffset + (uint)indexSubHeader.FieldOffsets.imageFormat );
                        newbuf.SetUint( imageDataOffset,                    idxSubTableOffset + (uint)indexSubHeader.FieldOffsets.imageDataOffset );                        
                        
                        uint imageOffset = 0;
                        switch( istac.indexSubTable.indexFormat )
                        {
                            case 1:
                            {                                
                                indexSubTableCache1 istc = (indexSubTableCache1)istac.indexSubTable;                                
                                for( ushort iii = istac.firstGlyphIndex; iii <= istac.lastGlyphIndex; iii++ )
                                {
                                    ushort nIndex = (ushort)(iii - istac.firstGlyphIndex);
                                    // offset + header length + (uint)offsetArray[iii]
                                    newbuf.SetUint( imageOffset, idxSubTableOffset + indexSubTable.headerLength + (uint)(nIndex * 4));                                
                                    
                                    // Write image data for this indexSubTable to EBDT buffer
                                    imageCache ic = istc.getImageCache( iii, istac.firstGlyphIndex );
                                    writeEBDTBuffer( bufEBDT, (imageDataOffset + imageOffset), ic, istac.indexSubTable.imageFormat );
                                    imageOffset += ic.imageDataSize();
                                }
                                // Add the last one so size can be determined
                                newbuf.SetUint( imageOffset, idxSubTableOffset + indexSubTable.headerLength + ((uint)(istac.lastGlyphIndex - istac.firstGlyphIndex + 1) * 4));
                                
                                break;
                            }
                            case 2:
                            {
                                indexSubTableCache2 istc = (indexSubTableCache2)istac.indexSubTable;                                
                                
                                // offset + header length 
                                newbuf.SetUint( istc.imageSize, idxSubTableOffset + indexSubTable.headerLength );
                                //BigMetrics, + 12 = indexSubTable.headerLength + (uint)imageSize
                                newbuf.SetByte( istc.bigMetrics.height,            idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
                                newbuf.SetByte( istc.bigMetrics.width,            idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
                                newbuf.SetSbyte( istc.bigMetrics.horiBearingX,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
                                newbuf.SetSbyte( istc.bigMetrics.horiBearingY,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
                                newbuf.SetByte( istc.bigMetrics.horiAdvance,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
                                newbuf.SetSbyte( istc.bigMetrics.vertBearingX,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
                                newbuf.SetSbyte( istc.bigMetrics.vertBearingY,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
                                newbuf.SetByte( istc.bigMetrics.vertAdvance,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );

                                for( ushort iii = istac.firstGlyphIndex; iii <= istac.lastGlyphIndex; iii++ )
                                {                                
                                    // Write image data for this indexSubTable to EBDT buffer
                                    imageCache ic = istc.getImageCache( iii, istac.firstGlyphIndex );
                                    writeEBDTBuffer( bufEBDT, (imageDataOffset + imageOffset), ic, istac.indexSubTable.imageFormat );
                                    imageOffset += ic.imageDataSize();
                                }
                                break;
                            }
                            case 3:
                            {
                                indexSubTableCache3 istc = (indexSubTableCache3)istac.indexSubTable;                                
                                
                                for( ushort iii = istac.firstGlyphIndex; iii <= istac.lastGlyphIndex; iii++ )
                                {
                                    ushort nIndex = (ushort)(iii - istac.firstGlyphIndex);

                                    // offset + header length + ushort offsetArray[iii]
                                    newbuf.SetUshort( (ushort)imageOffset, idxSubTableOffset + indexSubTable.headerLength + (uint)(nIndex * 2 ));
                                    // Write image data for this indexSubTable to EBDT buffer
                                    imageCache ic = istc.getImageCache( iii, istac.firstGlyphIndex );
                                    writeEBDTBuffer( bufEBDT, (imageDataOffset + imageOffset), ic, istac.indexSubTable.imageFormat );
                                    imageOffset += ic.imageDataSize();
                                }
                                // Add the last one so size can be determined
                                newbuf.SetUshort( (ushort)imageOffset, idxSubTableOffset + indexSubTable.headerLength + ((uint)(istac.lastGlyphIndex - istac.firstGlyphIndex + 1) * 2 ));
                                break;
                            }
                            case 4:
                            {
                                indexSubTableCache4 istc = (indexSubTableCache4)istac.indexSubTable;                                
                                // offset + header length 
                                newbuf.SetUint( istc.numGlyphs, idxSubTableOffset + indexSubTable.headerLength );
                                for( ushort iii = 0; iii < istc.numGlyphs; iii++ )
                                {
                                    // offset + header length + (uint)numGlyphs + (4)codeOffsetPair[iii]
                                    newbuf.SetUshort( istc.getGlyphCode(iii), idxSubTableOffset + 12 + (uint)(iii * 4));
                                    newbuf.SetUshort( (ushort)imageOffset, idxSubTableOffset + 12 + (uint)(iii * 4) + 2 );
                                    // Write image data for this indexSubTable to EBDT buffer
                                    imageCache ic = istc.getImageCache( istc.getGlyphCode(iii));
                                    writeEBDTBuffer( bufEBDT, (imageDataOffset + imageOffset), ic, istac.indexSubTable.imageFormat );
                                    imageOffset += ic.imageDataSize();
                                }
                                // Add the last codeOffsetPair so size can be determined
                                newbuf.SetUshort( 0, idxSubTableOffset + 12 + (uint)(istc.numGlyphs * 4 ));
                                newbuf.SetUshort( (ushort)imageOffset, idxSubTableOffset + 12 + (uint)(istc.numGlyphs * 4 ) + 2 );                                
                                break;
                            }
                            case 5:
                            {
                                indexSubTableCache5 istc = (indexSubTableCache5)istac.indexSubTable;                                
                                // offset + header length 
                                newbuf.SetUint( istc.imageSize, idxSubTableOffset + indexSubTable.headerLength );

                                //BigMetrics, + 12 = indexSubTable.headerLength + (uint)imageSize
                                newbuf.SetByte( istc.bigMetrics.height,            idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.height );
                                newbuf.SetByte( istc.bigMetrics.width,            idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.width );
                                newbuf.SetSbyte( istc.bigMetrics.horiBearingX,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingX );
                                newbuf.SetSbyte( istc.bigMetrics.horiBearingY,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiBearingY );
                                newbuf.SetByte( istc.bigMetrics.horiAdvance,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.horiAdvance );
                                newbuf.SetSbyte( istc.bigMetrics.vertBearingX,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingX );
                                newbuf.SetSbyte( istc.bigMetrics.vertBearingY,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertBearingY );
                                newbuf.SetByte( istc.bigMetrics.vertAdvance,    idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.FieldOffsets.vertAdvance );

                                newbuf.SetUint( istc.numGlyphs, idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.bufSize );

                                for( ushort iii = 0; iii < istc.numGlyphs; iii++ )
                                {
                                    // offset + header length + (uint)imageSize + bigGlyphMetrics.bufSize + big(uint)numGlyphs + (ushort)glyphCodeArray[iii}
                                    newbuf.SetUshort( istc.getGlyphCode(iii), idxSubTableOffset + 12 + (uint)Table_EBDT.bigGlyphMetrics.bufSize + 4 + (uint)(iii * 2 ));
                                    
                                    // Write image data for this indexSubTable to EBDT buffer
                                    imageCache ic = istc.getImageCache( istc.getGlyphCode(iii));
                                    writeEBDTBuffer( bufEBDT, (imageDataOffset + imageOffset), ic, istac.indexSubTable.imageFormat );
                                    imageOffset += ic.imageDataSize();
                                }                            
                                break;
                            }
                        }

                        // update imageDataOffset for the next SubTable
                        imageDataOffset += imageOffset;

                        // This will take care of any byte boundaries pads required by some indexSubTables
                        idxSubTableOffset += istac.indexSubTable.indexSubTableSize();            
                    }

                    idxArrOffset += bstc.indexSubTablesSize;                    
                }    
                
                // Put the EBDT buf to that table
                Table_EBDT.EBDT_cache EBDTCache = (Table_EBDT.EBDT_cache)m_tableEBDT.GetCache();
                EBDTCache.setCache( bufEBDT );

                // put the buffer into a Table_EBLC object and return it
                Table_EBLC EBLCTable = new Table_EBLC( "EBLC", newbuf );
            
                return EBLCTable;
            }
Exemplo n.º 14
0
            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);
            }
Exemplo n.º 15
0
            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);
            }
Exemplo n.º 16
0
            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;            
            }
Exemplo n.º 17
0
            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;
            }
Exemplo n.º 18
0
            public override OTTable GenerateTable()
            {
                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer((uint)(Table_LTSH.FieldOffsets.yPels + m_numGlyphs));

                newbuf.SetUshort( m_version,        (uint)Table_LTSH.FieldOffsets.version);
                newbuf.SetUshort( m_numGlyphs,        (uint)Table_LTSH.FieldOffsets.numGlyphs);
                
                // Fill the buffer with the yPels
                for( int i = 0; i < m_numGlyphs; i++ )
                {
                    newbuf.SetByte( m_yPels[i],        (uint)(Table_LTSH.FieldOffsets.yPels + i));
                }
                
                // put the buffer into a Table_maxp object and return it
                Table_LTSH LTSHTable = new Table_LTSH("LTSH", newbuf);

                return LTSHTable;        
            }