Example #1
0
            protected ArrayList m_bitmapScaleTables; // bitmapScaleTableCache[]


            // constructor
            public EBSC_cache(Table_EBSC OwnerTable)
            {
                // copy the data from the owner table's MBOBuffer
                // and store it in the cache variables
                m_version  = OwnerTable.version;
                m_numSizes = OwnerTable.numSizes;

                m_bitmapScaleTables = new ArrayList((int)m_numSizes);

                for (uint i = 0; i < m_numSizes; i++)
                {
                    m_bitmapScaleTables.Add(OwnerTable.GetBitmapScaleTable(i));
                }
            }
Example #2
0
        public OffsetTable(OTFixed version, ushort nTables)
        {
            m_buf = new MBOBuffer(12);

            sfntVersion = version;
            numTables   = nTables;

            if (nTables != 0)
            {
                // these values are truly undefined when numTables is zero
                // since there is no power of 2 that is less that or equal to zero
                searchRange   = (ushort)(util.MaxPower2LE(nTables) * 16);
                entrySelector = util.Log2(util.MaxPower2LE(nTables));
                rangeShift    = (ushort)(nTables * 16 - searchRange);
            }

            DirectoryEntries = new System.Collections.ArrayList();
        }
Example #3
0
 // constructor
 public PCLT_cache(Table_PCLT OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_Version             = OwnerTable.Version;
     m_FontNumber          = OwnerTable.FontNumber;
     m_Pitch               = OwnerTable.Pitch;
     m_xHeight             = OwnerTable.xHeight;
     m_Style               = OwnerTable.Style;
     m_TypeFamily          = OwnerTable.TypeFamily;
     m_CapHeight           = OwnerTable.CapHeight;
     m_SymbolSet           = OwnerTable.SymbolSet;
     m_Typeface            = OwnerTable.Typeface;
     m_CharacterComplement = OwnerTable.CharacterComplement;
     m_FileName            = OwnerTable.FileName;
     m_StrokeWeight        = OwnerTable.StrokeWeight;
     m_WidthType           = OwnerTable.WidthType;
     m_SerifStyle          = OwnerTable.SerifStyle;
     m_Reserved            = OwnerTable.Reserved;
 }
Example #4
0
            // constructor

            public head_cache(Table_head OwnerTable)
            {
                // copy the data from the owner table's MBOBuffer
                // and store it in the cache variables
                m_TableVersion       = OwnerTable.TableVersionNumber;
                m_fontRevision       = OwnerTable.fontRevision;
                m_checkSumAdjustment = OwnerTable.checkSumAdjustment;
                m_magicNumber        = OwnerTable.magicNumber;
                m_flags             = OwnerTable.flags;
                m_unitsPerEm        = OwnerTable.unitsPerEm;
                m_created           = OwnerTable.created;
                m_modified          = OwnerTable.modified;
                m_xMin              = OwnerTable.xMin;
                m_yMin              = OwnerTable.yMin;
                m_xMax              = OwnerTable.xMax;
                m_yMax              = OwnerTable.yMax;
                m_macStyle          = OwnerTable.macStyle;
                m_lowestRecPPEM     = OwnerTable.lowestRecPPEM;
                m_fontDirectionHint = OwnerTable.fontDirectionHint;
                m_indexToLocFormat  = OwnerTable.indexToLocFormat;
                m_glyphDataFormat   = OwnerTable.glyphDataFormat;
            }
Example #5
0
 // constructor
 public vhea_cache(Table_vhea OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_version              = OwnerTable.version;
     m_vertTypoAscender     = OwnerTable.vertTypoAscender;
     m_vertTypoDescender    = OwnerTable.vertTypoDescender;
     m_vertTypoLineGap      = OwnerTable.vertTypoLineGap;
     m_advanceHeightMax     = OwnerTable.advanceHeightMax;
     m_minTopSideBearing    = OwnerTable.minTopSideBearing;
     m_minBottomSideBearing = OwnerTable.minBottomSideBearing;
     m_yMaxExtent           = OwnerTable.yMaxExtent;
     m_caretSlopeRise       = OwnerTable.caretSlopeRise;
     m_caretSlopeRun        = OwnerTable.caretSlopeRun;
     m_caretOffset          = OwnerTable.caretOffset;
     m_reserved1            = OwnerTable.reserved1;
     m_reserved2            = OwnerTable.reserved2;
     m_reserved3            = OwnerTable.reserved3;
     m_reserved4            = OwnerTable.reserved4;
     m_metricDataFormat     = OwnerTable.metricDataFormat;
     m_numOfLongVerMetrics  = OwnerTable.numOfLongVerMetrics;
 }
Example #6
0
 // constructor
 public hhea_cache(Table_hhea OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_TableVersionNumber  = OwnerTable.TableVersionNumber;
     m_Ascender            = OwnerTable.Ascender;
     m_Descender           = OwnerTable.Descender;
     m_LineGap             = OwnerTable.LineGap;
     m_advanceWidthMax     = OwnerTable.advanceWidthMax;
     m_minLeftSideBearing  = OwnerTable.minLeftSideBearing;
     m_minRightSideBearing = OwnerTable.minRightSideBearing;
     m_xMaxExtent          = OwnerTable.xMaxExtent;
     m_caretSlopeRise      = OwnerTable.caretSlopeRise;
     m_caretSlopeRun       = OwnerTable.caretSlopeRun;
     m_caretOffset         = OwnerTable.caretOffset;
     m_reserved1           = OwnerTable.reserved1;
     m_reserved2           = OwnerTable.reserved2;
     m_reserved3           = OwnerTable.reserved3;
     m_reserved4           = OwnerTable.reserved4;
     m_metricDataFormat    = OwnerTable.metricDataFormat;
     m_numberOfHMetrics    = OwnerTable.numberOfHMetrics;
 }
Example #7
0
 // constructor
 public maxp_cache(Table_maxp OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_TableVersionNumber = OwnerTable.TableVersionNumber;
     m_NumGlyphs          = OwnerTable.NumGlyphs;
     if (m_TableVersionNumber.GetUint() == 0x00010000)
     {
         m_maxPoints             = OwnerTable.maxPoints;
         m_maxContours           = OwnerTable.maxContours;
         m_maxCompositePoints    = OwnerTable.maxCompositePoints;
         m_maxCompositeContours  = OwnerTable.maxCompositeContours;
         m_maxZones              = OwnerTable.maxZones;
         m_maxTwilightPoints     = OwnerTable.maxTwilightPoints;
         m_maxStorage            = OwnerTable.maxStorage;
         m_maxFunctionDefs       = OwnerTable.maxFunctionDefs;
         m_maxInstructionDefs    = OwnerTable.maxInstructionDefs;
         m_maxStackElements      = OwnerTable.maxStackElements;
         m_maxSizeOfInstructions = OwnerTable.maxSizeOfInstructions;
         m_maxComponentElements  = OwnerTable.maxComponentElements;
         m_maxComponentDepth     = OwnerTable.maxComponentDepth;
     }
 }
Example #8
0
 // constructor
 public EBDT_cache(Table_EBDT OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_version = OwnerTable.version;
 }
Example #9
0
            // constructor

            public head_cache(Table_head OwnerTable)
            {
                // copy the data from the owner table's MBOBuffer
                // and store it in the cache variables
                m_TableVersion       = OwnerTable.TableVersionNumber;
                m_fontRevision       = OwnerTable.fontRevision;
                m_checkSumAdjustment = OwnerTable.checkSumAdjustment;
                m_magicNumber        = OwnerTable.magicNumber;
                m_flags              = OwnerTable.flags;
                m_unitsPerEm         = OwnerTable.unitsPerEm;
                m_created            = OwnerTable.created;
                m_modified           = OwnerTable.modified;
                m_xMin               = OwnerTable.xMin;
                m_yMin               = OwnerTable.yMin;
                m_xMax               = OwnerTable.xMax;
                m_yMax               = OwnerTable.yMax;
                m_macStyle           = OwnerTable.macStyle;
                m_lowestRecPPEM      = OwnerTable.lowestRecPPEM;
                m_fontDirectionHint  = OwnerTable.fontDirectionHint;
                m_indexToLocFormat   = OwnerTable.indexToLocFormat;
                m_glyphDataFormat    = OwnerTable.glyphDataFormat;
            }
Example #10
0
            // constructor
            public EBLC_cache( Table_EBLC OwnerTable )
            {
                // copy the data from the owner table's MBOBuffer
                // and store it in the cache variables
                m_version = OwnerTable.version;
                m_numSizes = OwnerTable.numSizes;
                m_tableEBDT = OwnerTable.getTableEDBT();

                m_bitmapSizeTables = new ArrayList( (int)m_numSizes );

                for( uint i = 0; i < m_numSizes; i++ )
                {
                    bitmapSizeTable bst = OwnerTable.GetBitmapSizeTable( i );
                    m_bitmapSizeTables.Add( new bitmapSizeTableCache( OwnerTable, bst ));
                }

            }
Example #11
0
 // constructor
 public vhea_cache(Table_vhea OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_version                = OwnerTable.version;
     m_vertTypoAscender        = OwnerTable.vertTypoAscender;
     m_vertTypoDescender        = OwnerTable.vertTypoDescender;
     m_vertTypoLineGap        = OwnerTable.vertTypoLineGap;
     m_advanceHeightMax        = OwnerTable.advanceHeightMax;
     m_minTopSideBearing        = OwnerTable.minTopSideBearing;
     m_minBottomSideBearing    = OwnerTable.minBottomSideBearing;
     m_yMaxExtent            = OwnerTable.yMaxExtent;
     m_caretSlopeRise        = OwnerTable.caretSlopeRise;
     m_caretSlopeRun            = OwnerTable.caretSlopeRun;
     m_caretOffset            = OwnerTable.caretOffset;
     m_reserved1             = OwnerTable.reserved1;
     m_reserved2                = OwnerTable.reserved2;
     m_reserved3                = OwnerTable.reserved3;
     m_reserved4                = OwnerTable.reserved4;
     m_metricDataFormat        = OwnerTable.metricDataFormat;
     m_numOfLongVerMetrics    = OwnerTable.numOfLongVerMetrics;
 }
Example #12
0
        /// <summary>Write a single OTF to a disk file, with tables in
        /// proper order, checksums set, etc.
        /// </summary>
        public static bool WriteSfntFile(FileStream fs, OTFont font)
        {
            bool bRet = true;


            OTFixed     sfntVersion = new OTFixed(1, 0);
            ushort      numTables   = font.GetNumTables();
            OffsetTable ot          = new OffsetTable(sfntVersion, numTables);


            // order tables in fastfont order

            string [] arrOrderedNames = null;
            string [] ttNames         =
            {
                "head", "hhea", "maxp", "OS/2", "hmtx", "LTSH", "VDMX", "hdmx", "cmap", "fpgm",
                "prep", "cvt ", "loca", "glyf", "kern", "name", "post", "gasp", "PCLT"
            };
            string [] psNames =
            {
                "head", "hhea", "maxp", "OS/2", "name", "cmap", "post", "CFF "
            };

            if (font.ContainsTrueTypeOutlines())
            {
                arrOrderedNames = ttNames;
            }
            else if (font.ContainsPostScriptOutlines())
            {
                arrOrderedNames = psNames;
            }

            OTTable[] OrderedTables = new OTTable[numTables];
            for (ushort i = 0; i < numTables; i++)
            {
                OrderedTables[i] = font.GetTable(i);
            }

            if (arrOrderedNames != null)
            {
                ushort curpos = 0;
                for (int iName = 0; iName < arrOrderedNames.Length; iName++)
                {
                    for (ushort i = curpos; i < numTables; i++)
                    {
                        if (arrOrderedNames[iName] == (string)OrderedTables[i].m_tag)
                        {
                            OTTable temp = OrderedTables[curpos];
                            OrderedTables[curpos] = OrderedTables[i];
                            OrderedTables[i]      = temp;
                            curpos++;
                            break;
                        }
                    }
                }
            }


            // update the modified date in the head table

            for (int i = 0; i < OrderedTables.Length; i++)
            {
                if ((string)OrderedTables[i].m_tag == "head")
                {
                    // get the cache
                    Table_head            headTable = (Table_head)OrderedTables[i];
                    Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache();

                    // set the 'modified' field to the current date and time
                    DateTime dt = DateTime.Now;
                    headCache.modified = headTable.DateTimeToSecondsSince1904(dt);

                    // generate a new table and replace the head table in the list of ordered tables
                    Table_head newHead = (Table_head)headCache.GenerateTable();
                    OrderedTables[i] = newHead;

                    break;
                }
            }


            // build a list of directory entries

            long TableFilePos = 12 + numTables * 16;

            for (ushort i = 0; i < numTables; i++)
            {
                OTTable table = OrderedTables[i];
                OTTag   tag   = table.m_tag;

                // build a new directory entry
                DirectoryEntry de = new DirectoryEntry();
                de.tag      = new OTTag(tag.GetBytes());
                de.checkSum = table.CalcChecksum();
                de.offset   = (uint)TableFilePos;
                de.length   = table.GetLength();

                ot.DirectoryEntries.Add(de);

                TableFilePos += table.GetBuffer().GetPaddedLength();
            }


            // sort the directory entries

            if (numTables > 1)
            {
                for (int i = 0; i < numTables - 1; i++)
                {
                    for (int j = i + 1; j < numTables; j++)
                    {
                        if (((DirectoryEntry)(ot.DirectoryEntries[i])).tag > ((DirectoryEntry)(ot.DirectoryEntries[j])).tag)
                        {
                            DirectoryEntry temp = (DirectoryEntry)ot.DirectoryEntries[i];
                            ot.DirectoryEntries[i] = (DirectoryEntry)ot.DirectoryEntries[j];
                            ot.DirectoryEntries[j] = temp;
                        }
                    }
                }
            }


            // update the font checksum in the head table

            for (int i = 0; i < OrderedTables.Length; i++)
            {
                if ((string)OrderedTables[i].m_tag == "head")
                {
                    // calculate the checksum
                    uint sum = 0;
                    sum += ot.CalcOffsetTableChecksum();
                    sum += ot.CalcDirectoryEntriesChecksum();
                    for (int j = 0; j < OrderedTables.Length; j++)
                    {
                        sum += OrderedTables[j].CalcChecksum();
                    }

                    // get the cache
                    Table_head            headTable = (Table_head)OrderedTables[i];
                    Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache();

                    // set the checkSumAdujustment field
                    headCache.checkSumAdjustment = 0xb1b0afba - sum;

                    // generate a new table and replace the head table in the list of ordered tables
                    Table_head newHead = (Table_head)headCache.GenerateTable();
                    OrderedTables[i] = newHead;

                    break;
                }
            }


            // write the offset table

            fs.Write(ot.m_buf.GetBuffer(), 0, (int)ot.m_buf.GetLength());


            // write the directory entries

            for (int i = 0; i < numTables; i++)
            {
                DirectoryEntry de = (DirectoryEntry)ot.DirectoryEntries[i];
                fs.Write(de.m_buf.GetBuffer(), 0, (int)de.m_buf.GetLength());
            }


            // write the tables

            for (ushort i = 0; i < numTables; i++)
            {
                OTTable table = OrderedTables[i];

                fs.Write(table.m_bufTable.GetBuffer(), 0, (int)table.GetBuffer().GetPaddedLength());
            }


            return(bRet);
        }
Example #13
0
            protected ArrayList m_bitmapScaleTables; // bitmapScaleTableCache[]

                
            // constructor
            public EBSC_cache(Table_EBSC OwnerTable)
            {
                // copy the data from the owner table's MBOBuffer
                // and store it in the cache variables
                m_version = OwnerTable.version;
                m_numSizes = OwnerTable.numSizes;

                m_bitmapScaleTables = new ArrayList( (int)m_numSizes );

                for( uint i = 0; i < m_numSizes; i++ )
                {
                    m_bitmapScaleTables.Add( OwnerTable.GetBitmapScaleTable( i ));
                }

            }
Example #14
0
            protected char[] m_offset; // v2.5 NOTE: We may not need? so not supported yet

            // constructor
            public post_cache(Table_post OwnerTable)
            {
                m_Version = OwnerTable.Version;
                m_italicAngle = OwnerTable.italicAngle;
                m_underlinePosition = OwnerTable.underlinePosition;
                m_underlineThickness = OwnerTable.underlineThickness;
                m_isFixedPitch = OwnerTable.isFixedPitch;
                m_minMemType42 = OwnerTable.minMemType42;
                m_maxMemType42 = OwnerTable.maxMemType42;
                m_minMemType1 = OwnerTable.minMemType1;
                m_maxMemType1 = OwnerTable.maxMemType1;

                // NOTE: what about version 2.5 is that covered with this check?
                // NOTE: Are we not checking because it is deprecated?
                if( m_Version.GetUint() == 0x00020000 )
                {
                    m_numberOfGlyphs = OwnerTable.numberOfGlyphs;
                    m_glyphNameIndex = new ArrayList( m_numberOfGlyphs );

                    for( ushort i = 0; i < m_numberOfGlyphs; i++ )
                    {
                        m_glyphNameIndex.Add( OwnerTable.GetGlyphNameIndex( i ));
                    }

                    m_names = new ArrayList( (int)OwnerTable.NumberOfStrings );

                    // Get the gyph names
                    for( uint i = 0; i < OwnerTable.NumberOfStrings; i++ )
                    {
                        m_names.Add( OwnerTable.GetNameString( i ));
                    }
                }

            }
Example #15
0
        public OffsetTable(OTFixed version, ushort nTables)
        {
            m_buf = new MBOBuffer(12);

            sfntVersion = version;
            numTables = nTables;

            if (nTables != 0)
            {
                // these values are truly undefined when numTables is zero
                // since there is no power of 2 that is less that or equal to zero
                searchRange   = (ushort)(util.MaxPower2LE(nTables) * 16);
                entrySelector = util.Log2(util.MaxPower2LE(nTables));
                rangeShift    = (ushort)(nTables*16 - searchRange);
            }

            DirectoryEntries = new System.Collections.ArrayList();
        }
Example #16
0
        public void SetFixed(OTFixed value, uint offset)
        {
            uint n = value.GetUint();

            SetUint(n, offset);
        }
Example #17
0
 // constructor
 public PCLT_cache(Table_PCLT OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_Version                = OwnerTable.Version;
     m_FontNumber            = OwnerTable.FontNumber;
     m_Pitch                    = OwnerTable.Pitch;
     m_xHeight                = OwnerTable.xHeight;
     m_Style                    = OwnerTable.Style;
     m_TypeFamily            = OwnerTable.TypeFamily;
     m_CapHeight                = OwnerTable.CapHeight;
     m_SymbolSet                = OwnerTable.SymbolSet;
     m_Typeface                = OwnerTable.Typeface;
     m_CharacterComplement    = OwnerTable.CharacterComplement;
     m_FileName                = OwnerTable.FileName;
     m_StrokeWeight            = OwnerTable.StrokeWeight;
     m_WidthType             = OwnerTable.WidthType;
     m_SerifStyle            = OwnerTable.SerifStyle;
     m_Reserved                = OwnerTable.Reserved;                
 }
Example #18
0
 // constructor
 public hhea_cache(Table_hhea OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_TableVersionNumber    = OwnerTable.TableVersionNumber;
     m_Ascender                = OwnerTable.Ascender;
     m_Descender                = OwnerTable.Descender;
     m_LineGap                = OwnerTable.LineGap;
     m_advanceWidthMax        = OwnerTable.advanceWidthMax;
     m_minLeftSideBearing    = OwnerTable.minLeftSideBearing;
     m_minRightSideBearing    = OwnerTable.minRightSideBearing;
     m_xMaxExtent            = OwnerTable.xMaxExtent;
     m_caretSlopeRise        = OwnerTable.caretSlopeRise;
     m_caretSlopeRun            = OwnerTable.caretSlopeRun;
     m_caretOffset            = OwnerTable.caretOffset;
     m_reserved1             = OwnerTable.reserved1;
     m_reserved2                = OwnerTable.reserved2;
     m_reserved3                = OwnerTable.reserved3;
     m_reserved4                = OwnerTable.reserved4;
     m_metricDataFormat        = OwnerTable.metricDataFormat;
     m_numberOfHMetrics        = OwnerTable.numberOfHMetrics;
 }
Example #19
0
 // constructor
 public maxp_cache(Table_maxp OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_TableVersionNumber    = OwnerTable.TableVersionNumber;
     m_NumGlyphs                = OwnerTable.NumGlyphs;
     if( m_TableVersionNumber.GetUint() == 0x00010000 )
     {
         m_maxPoints                = OwnerTable.maxPoints;
         m_maxContours            = OwnerTable.maxContours;
         m_maxCompositePoints    = OwnerTable.maxCompositePoints;
         m_maxCompositeContours    = OwnerTable.maxCompositeContours;
         m_maxZones                = OwnerTable.maxZones;
         m_maxTwilightPoints        = OwnerTable.maxTwilightPoints;
         m_maxStorage            = OwnerTable.maxStorage;
         m_maxFunctionDefs        = OwnerTable.maxFunctionDefs;
         m_maxInstructionDefs    = OwnerTable.maxInstructionDefs;
         m_maxStackElements        = OwnerTable.maxStackElements;
         m_maxSizeOfInstructions    = OwnerTable.maxSizeOfInstructions;
         m_maxComponentElements    = OwnerTable.maxComponentElements;
         m_maxComponentDepth        = OwnerTable.maxComponentDepth;                    
     }
 }
Example #20
0
        /// <summary>Write a single OTF to a disk file, with tables in
        /// proper order, checksums set, etc.
        /// </summary>
        public static bool WriteSfntFile(FileStream fs, OTFont font)
        {
            bool bRet = true;

            OTFixed sfntVersion = new OTFixed(1,0);
            ushort numTables = font.GetNumTables();
            OffsetTable ot = new OffsetTable(sfntVersion, numTables);

            // order tables in fastfont order

            string [] arrOrderedNames = null;
            string [] ttNames =
                {
                    "head", "hhea", "maxp", "OS/2", "hmtx", "LTSH", "VDMX", "hdmx", "cmap", "fpgm",
                    "prep", "cvt ", "loca", "glyf", "kern", "name", "post", "gasp", "PCLT"
                };
            string [] psNames =
                {
                    "head", "hhea", "maxp", "OS/2", "name", "cmap", "post", "CFF "
                };

            if (font.ContainsTrueTypeOutlines())
            {
                arrOrderedNames = ttNames;
            }
            else if (font.ContainsPostScriptOutlines())
            {
                arrOrderedNames = psNames;
            }

            OTTable[] OrderedTables = new OTTable[numTables];
            for (ushort i=0; i<numTables; i++)
            {
                OrderedTables[i] = font.GetTable(i);
            }

            if (arrOrderedNames != null)
            {
                ushort curpos = 0;
                for (int iName=0; iName<arrOrderedNames.Length; iName++)
                {
                    for (ushort i=curpos; i<numTables; i++)
                    {
                        if (arrOrderedNames[iName] == (string)OrderedTables[i].m_tag)
                        {
                            OTTable temp = OrderedTables[curpos];
                            OrderedTables[curpos] = OrderedTables[i];
                            OrderedTables[i] = temp;
                            curpos++;
                            break;
                        }
                    }
                }
            }

            // update the modified date in the head table

            for (int i=0; i<OrderedTables.Length; i++)
            {
                if ((string)OrderedTables[i].m_tag == "head")
                {
                    // get the cache
                    Table_head headTable = (Table_head)OrderedTables[i];
                    Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache();

                    // set the 'modified' field to the current date and time
                    DateTime dt = DateTime.Now;
                    headCache.modified = headTable.DateTimeToSecondsSince1904(dt);

                    // generate a new table and replace the head table in the list of ordered tables
                    Table_head newHead = (Table_head)headCache.GenerateTable();
                    OrderedTables[i] = newHead;

                    break;
                }
            }

            // build a list of directory entries

            long TableFilePos = 12 + numTables*16;

            for (ushort i=0; i<numTables; i++)
            {
                OTTable table = OrderedTables[i];
                OTTag tag = table.m_tag;

                // build a new directory entry
                DirectoryEntry de = new DirectoryEntry();
                de.tag = new OTTag(tag.GetBytes());
                de.checkSum = table.CalcChecksum();
                de.offset = (uint)TableFilePos;
                de.length = table.GetLength();

                ot.DirectoryEntries.Add(de);

                TableFilePos += table.GetBuffer().GetPaddedLength();
            }

            // sort the directory entries

            if (numTables > 1)
            {
                for (int i=0; i<numTables-1; i++)
                {
                    for (int j=i+1; j<numTables; j++)
                    {
                        if (((DirectoryEntry)(ot.DirectoryEntries[i])).tag > ((DirectoryEntry)(ot.DirectoryEntries[j])).tag)
                        {
                            DirectoryEntry temp = (DirectoryEntry)ot.DirectoryEntries[i];
                            ot.DirectoryEntries[i] = (DirectoryEntry)ot.DirectoryEntries[j];
                            ot.DirectoryEntries[j] = temp;
                        }
                    }
                }
            }

            // update the font checksum in the head table

            for (int i=0; i<OrderedTables.Length; i++)
            {
                if ((string)OrderedTables[i].m_tag == "head")
                {
                    // calculate the checksum
                    uint sum = 0;
                    sum += ot.CalcOffsetTableChecksum();
                    sum += ot.CalcDirectoryEntriesChecksum();
                    for (int j=0; j<OrderedTables.Length; j++)
                    {
                        sum += OrderedTables[j].CalcChecksum();
                    }

                    // get the cache
                    Table_head headTable = (Table_head)OrderedTables[i];
                    Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache();

                    // set the checkSumAdujustment field
                    headCache.checkSumAdjustment = 0xb1b0afba - sum;

                    // generate a new table and replace the head table in the list of ordered tables
                    Table_head newHead = (Table_head)headCache.GenerateTable();
                    OrderedTables[i] = newHead;

                    break;
                }
            }

            // write the offset table

            fs.Write(ot.m_buf.GetBuffer(), 0, (int)ot.m_buf.GetLength());

            // write the directory entries

            for (int i=0; i<numTables; i++)
            {
                DirectoryEntry de = (DirectoryEntry)ot.DirectoryEntries[i];
                fs.Write(de.m_buf.GetBuffer(), 0, (int)de.m_buf.GetLength());
            }

            // write the tables

            for (ushort i=0; i<numTables; i++)
            {
                OTTable table = OrderedTables[i];

                fs.Write(table.m_bufTable.GetBuffer(), 0, (int)table.GetBuffer().GetPaddedLength());
            }

            return bRet;
        }
Example #21
0
 // constructor
 public EBDT_cache(Table_EBDT OwnerTable)
 {
     // copy the data from the owner table's MBOBuffer
     // and store it in the cache variables
     m_version = OwnerTable.version;
 }
Example #22
0
 public void SetFixed(OTFixed value, uint offset)
 {
     uint n = value.GetUint();
     SetUint(n, offset);
 }