コード例 #1
0
ファイル: OTFont.cs プロジェクト: camertron/Font-Validator
        /// <summary>Get font version from "name" table, or <c>null</c> if
        /// no "name" table yet.</summary>
        public string GetFontVersion()
        {
            string sVersion = null;

            Table_name nameTable = (Table_name)GetTable("name");

            if (nameTable != null)
            {
                sVersion = nameTable.GetVersionString();
            }

            return(sVersion);
        }
コード例 #2
0
ファイル: OTFont.cs プロジェクト: camertron/Font-Validator
        /// <summary>Get font name from "name" table, or <c>null</c> if
        /// no "name" table yet.</summary>
        public string GetFontName()
        {
            string sName = null;

            Table_name nameTable = (Table_name)GetTable("name");

            if (nameTable != null)
            {
                sName = nameTable.GetNameString();
            }

            return(sName);
        }
コード例 #3
0
ファイル: Table_name.cs プロジェクト: sjvudp/Font-Validator
            protected ArrayList m_nameRecords; // NameRecordCache[]

            // constructor
            public name_cache(Table_name OwnerTable)
            {
                m_format = OwnerTable.FormatSelector;

                m_nameRecords = new ArrayList(OwnerTable.NumberNameRecords);

                for (ushort i = 0; i < OwnerTable.NumberNameRecords; i++)
                {
                    NameRecord nr          = OwnerTable.GetNameRecord(i);
                    string     sNameString = OwnerTable.GetString(nr.PlatformID, nr.EncodingID, nr.LanguageID, nr.NameID);
                    addNameRecord(nr.PlatformID, nr.EncodingID, nr.LanguageID, nr.NameID, sNameString);
                }
            }
コード例 #4
0
ファイル: Table_name.cs プロジェクト: sjvudp/Font-Validator
            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);
            }
コード例 #5
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;
            }
コード例 #6
0
            protected ArrayList m_nameRecords; // NameRecordCache[]

            // constructor
            public name_cache(Table_name OwnerTable)
            {
            
                m_format = OwnerTable.FormatSelector;
                
                m_nameRecords = new ArrayList( OwnerTable.NumberNameRecords );

                for( ushort i = 0; i < OwnerTable.NumberNameRecords; i++ )
                {
                    NameRecord nr = OwnerTable.GetNameRecord( i );                    
                    string sNameString = OwnerTable.GetString( nr.PlatformID, nr.EncodingID, nr.LanguageID, nr.NameID );                    
                    addNameRecord(nr.PlatformID, nr.EncodingID, nr.LanguageID, nr.NameID, sNameString);
                }
            }
コード例 #7
0
        public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf)
        {
            OTTable table = null;

            string sName = GetUnaliasedTableName(tag);

            switch (sName)
            {
            case "BASE": table = new Table_BASE(tag, buf); break;

            case "CFF ": table = new Table_CFF(tag, buf); break;

            case "cmap": table = new Table_cmap(tag, buf); break;

            case "cvt ": table = new Table_cvt(tag, buf); break;

            case "DSIG": table = new Table_DSIG(tag, buf); break;

            case "EBDT": table = new Table_EBDT(tag, buf); break;

            case "EBLC": table = new Table_EBLC(tag, buf); break;

            case "EBSC": table = new Table_EBSC(tag, buf); break;

            case "fpgm": table = new Table_fpgm(tag, buf); break;

            case "gasp": table = new Table_gasp(tag, buf); break;

            case "GDEF": table = new Table_GDEF(tag, buf); break;

            case "glyf": table = new Table_glyf(tag, buf); break;

            case "GPOS": table = new Table_GPOS(tag, buf); break;

            case "GSUB": table = new Table_GSUB(tag, buf); break;

            case "hdmx": table = new Table_hdmx(tag, buf); break;

            case "head": table = new Table_head(tag, buf); break;

            case "hhea": table = new Table_hhea(tag, buf); break;

            case "hmtx": table = new Table_hmtx(tag, buf); break;

            case "JSTF": table = new Table_JSTF(tag, buf); break;

            case "kern": table = new Table_kern(tag, buf); break;

            case "loca": table = new Table_loca(tag, buf); break;

            case "LTSH": table = new Table_LTSH(tag, buf); break;

            case "maxp": table = new Table_maxp(tag, buf); break;

            case "name": table = new Table_name(tag, buf); break;

            case "OS/2": table = new Table_OS2(tag, buf); break;

            case "PCLT": table = new Table_PCLT(tag, buf); break;

            case "post": table = new Table_post(tag, buf); break;

            case "prep": table = new Table_prep(tag, buf); break;

            case "VDMX": table = new Table_VDMX(tag, buf); break;

            case "vhea": table = new Table_vhea(tag, buf); break;

            case "vmtx": table = new Table_vmtx(tag, buf); break;

            case "VORG": table = new Table_VORG(tag, buf); break;

            //case "Zapf": table = new Table_Zapf(tag, buf); break;
            default: table = new Table__Unknown(tag, buf); break;
            }

            return(table);
        }
コード例 #8
0
        public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf)
        {
            OTTable table = null;

            string sName = GetUnaliasedTableName(tag);

            switch (sName)
            {
                case "BASE": table = new Table_BASE(tag, buf); break;
                case "CFF ": table = new Table_CFF(tag, buf); break;
                case "cmap": table = new Table_cmap(tag, buf); break;
                case "cvt ": table = new Table_cvt(tag, buf); break;
                case "DSIG": table = new Table_DSIG(tag, buf); break;
                case "EBDT": table = new Table_EBDT(tag, buf); break;
                case "EBLC": table = new Table_EBLC(tag, buf); break;
                case "EBSC": table = new Table_EBSC(tag, buf); break;
                case "fpgm": table = new Table_fpgm(tag, buf); break;
                case "gasp": table = new Table_gasp(tag, buf); break;
                case "GDEF": table = new Table_GDEF(tag, buf); break;
                case "glyf": table = new Table_glyf(tag, buf); break;
                case "GPOS": table = new Table_GPOS(tag, buf); break;
                case "GSUB": table = new Table_GSUB(tag, buf); break;
                case "hdmx": table = new Table_hdmx(tag, buf); break;
                case "head": table = new Table_head(tag, buf); break;
                case "hhea": table = new Table_hhea(tag, buf); break;
                case "hmtx": table = new Table_hmtx(tag, buf); break;
                case "JSTF": table = new Table_JSTF(tag, buf); break;
                case "kern": table = new Table_kern(tag, buf); break;
                case "loca": table = new Table_loca(tag, buf); break;
                case "LTSH": table = new Table_LTSH(tag, buf); break;
                case "maxp": table = new Table_maxp(tag, buf); break;
                case "name": table = new Table_name(tag, buf); break;
                case "OS/2": table = new Table_OS2(tag, buf); break;
                case "PCLT": table = new Table_PCLT(tag, buf); break;
                case "post": table = new Table_post(tag, buf); break;
                case "prep": table = new Table_prep(tag, buf); break;
                case "VDMX": table = new Table_VDMX(tag, buf); break;
                case "vhea": table = new Table_vhea(tag, buf); break;
                case "vmtx": table = new Table_vmtx(tag, buf); break;
                case "VORG": table = new Table_VORG(tag, buf); break;
                //case "Zapf": table = new Table_Zapf(tag, buf); break;
                default: table = new Table__Unknown(tag, buf); break;
            }

            return table;
        }