コード例 #1
0
 public static STXHeader Read(BinaryReaderFont reader, TableRecord record)
 {
     return(new STXHeader {
         nClasses = reader.ReadUInt32(),
         classTableOffset = reader.ReadUInt32(),
         stateArrayOffset = reader.ReadUInt32(),
         entryTableOffset = reader.ReadUInt32()
     });
 }
コード例 #2
0
 public static TableRecord[] ReadArray(BinaryReaderFont reader, int count)
 {
     TableRecord[] array = new TableRecord[count];
     for (int i = 0; i < count; i++)
     {
         array[i] = Read(reader);
     }
     return(array);
 }
コード例 #3
0
        public static PrepTable Read(BinaryReaderFont reader, TableRecord record)
        {
            PrepTable value = new PrepTable();

            value.position = reader.Position;
            value.filePath = reader.FilePath;
            value.length   = (int)record.length;
            //value.data = reader.ReadBytes((int)record.length);
            return(value);
        }
コード例 #4
0
        public static MorxTable Read(BinaryReaderFont reader, TableRecord record)
        {
            MorxTable value = new MorxTable {
                version = reader.ReadUInt16(),
                unused  = reader.ReadUInt16(),
                nChains = reader.ReadUInt32(),
            };

            return(value);
        }
コード例 #5
0
        public static MetamorphosisChains Read(BinaryReaderFont reader, TableRecord record)
        {
            MetamorphosisChains value = new MetamorphosisChains {
                defaultFlags    = reader.ReadUInt32(),
                chainLength     = reader.ReadUInt32(),
                nFeatureEntries = reader.ReadUInt32(),
                nSubtables      = reader.ReadUInt32()
            };

            return(value);
        }
コード例 #6
0
        protected void DebugLogRecords()
        {
            Regex regex = new Regex("\t|\n");

            for (int i = 0; i < Tables.offset.numTables; i++)
            {
                TableRecord record = Tables.Records[i];
                string      text   = record.ToString();
                text = regex.Replace(text, "");
                Console.WriteLine(text.Replace(",", ", "));
            }
        }
コード例 #7
0
        public static CvtTable Read(BinaryReaderFont reader, TableRecord record)
        {
            CvtTable value = new CvtTable();

            value.data = Array.ConvertAll(
                reader.ReadInt16Array((int)(record.length / 2)),
                new Converter <short, int>((a) => {
                return(a);
            })
                );
            return(value);
        }
コード例 #8
0
        public static PostTable Read(BinaryReaderFont reader, TableRecord record)
        {
            PostTable value = new PostTable {
                version            = reader.ReadFixed(),
                italicAngle        = reader.ReadFixed(),
                underlinePosition  = reader.ReadFWORD(),
                underlineThickness = reader.ReadFWORD(),
                isFixedPitch       = reader.ReadUInt32(),
                minMemType42       = reader.ReadUInt32(),
                maxMemType42       = reader.ReadUInt32(),
                minMemType1        = reader.ReadUInt32(),
                maxMemType1        = reader.ReadUInt32(),
            };

            if (value.version == 0x20000)
            {
                value.numGlyphs      = reader.ReadUInt16();
                value.glyphNameIndex = reader.ReadUInt16Array(value.numGlyphs);
                int remain = (int)record.length - 34;
                remain -= value.numGlyphs * 2;
                List <string> names = new List <string>();
                while (remain > 0)
                {
                    byte nameLength = reader.ReadByte();
                    if (nameLength == 0)
                    {
                        break;
                    }
                    string name = reader.ReadString(nameLength);
                    remain -= nameLength + 1;
                    names.Add(name);
                }
                value.names = names.ToArray();
            }
            return(value);
        }
コード例 #9
0
        public void ReadTables(BinaryReaderFont reader)
        {
            if (offset == null)
            {
                return;
            }
            int length = offset.numTables;

            for (int i = 0; i < length; i++)
            {
                TableRecord record = Records[i];
                //Console.WriteLine(record);
                //bool checkSum = reader.TableChecksum(record);
                //Console.WriteLine("checkSum {0}: {1}", record.tableTag, checkSum);
                reader.Position = record.offset;
                long memory = 0;
                                #if DEBUG
                memory = GC.GetTotalMemory(false);
                                #endif

                switch (record.tableTag)
                {
                case AvarTable.Tag:                         // OpenType Font Variations
                    avar = AvarTable.Read(reader);
                    break;

                case BASETable.Tag:                         // Advanced Typographic Table
                    //BASE = BASETable.Read(reader);
                    break;

                case CBDTTable.Tag:                         // Related to Bitmap Glyphs, Related to Color Fonts
                    CBDT = CBDTTable.Read(reader, CBLC);
                    break;

                case CBLCTable.Tag:                         // Related to Bitmap Glyphs, Related to Color Fonts
                    CBLC = CBLCTable.Read(reader);
                    break;

                case CFFTable.Tag:                          // Related to CFF Outlines
                    CFF = CFFTable.Read(reader);
                    break;

                case CFF2Table.Tag:                         // Related to CFF Outlines
                    //CFF2 = CFF2Table.Read(reader);
                    break;

                case CmapTable.Tag:                         // Required Table
                    cmap = CmapTable.Read(reader);
                    break;

                case COLRTable.Tag:                         // Related to Color Fonts
                    //COLR = COLRTable.Read(reader);
                    break;

                case CPALTable.Tag:                         // Related to Color Fonts
                    //CPAL = CPALTable.Read(reader);
                    break;

                case CvarTable.Tag:                         // OpenType Font Variations
                    cvar = CvarTable.Read(reader);
                    break;

                case CvtTable.Tag:                          // Related to TrueType Outlines
                    cvt = CvtTable.Read(reader, record);
                    break;

                case DSIGTable.Tag:                         // Other OpenType Table
                    //DSIG = DSIGTable.Read(reader);
                    break;

                case EBDTTable.Tag:                         // Related to Bitmap Glyphs
                    EBDT = EBDTTable.Read(reader, EBLC);
                    break;

                case EBLCTable.Tag:                         // Related to Bitmap Glyphs
                    EBLC = EBLCTable.Read(reader);
                    break;

                case EBSCTable.Tag:                         // Related to Bitmap Glyphs
                    //EBSC = EBSCTable.Read(reader);
                    break;

                case FpgmTable.Tag:                         // Related to TrueType Outlines
                    fpgm = FpgmTable.Read(reader, record);
                    break;

                case FvarTable.Tag:                         // OpenType Font Variations
                    fvar = FvarTable.Read(reader);
                    break;

                case GaspTable.Tag:                         // Related to TrueType Outlines
                    //gasp = GaspTable.Read(reader);
                    break;

                case GDEFTable.Tag:                         // Advanced Typographic Table
                    //GDEF = GDEFTable.Read(reader);
                    break;

                case GlyfTable.Tag:                         // Related to TrueType Outlines
                    glyf = GlyfTable.Read(reader, loca);
                    break;

                case GPOSTable.Tag:                         // Advanced Typographic Table
                    //GPOS = GPOSTable.Read(reader);
                    break;

                case GSUBTable.Tag:                         // Advanced Typographic Table
                    //GSUB = GSUBTable.Read(reader);
                    break;

                case GvarTable.Tag:                         // OpenType Font Variations
                    //gvar = GvarTable.Read(reader);
                    break;

                case HdmxTable.Tag:                         // Other OpenType Table
                    hdmx = HdmxTable.Read(reader);
                    break;

                case HeadTable.Tag:                         // Required Table
                    head = HeadTable.Read(reader);
                    break;

                case HheaTable.Tag:                         // Required Table
                    hhea = HheaTable.Read(reader);
                    break;

                case HmtxTable.Tag:                         // Required Table
                    hmtx = HmtxTable.Read(reader, hhea, maxp);
                    break;

                case HVARTable.Tag:                         // OpenType Font Variations
                    //HVAR = HVARTable.Read(reader);
                    break;

                case JSTFTable.Tag:                         // Advanced Typographic Table
                    //JSTF = JSTFTable.Read(reader);
                    break;

                case KernTable.Tag:                         // Other OpenType Table
                    //kern = KernTable.Read(reader);
                    break;

                case LocaTable.Tag:                         // Related to TrueType Outlines
                    loca = LocaTable.Read(reader, head, maxp);
                    break;

                case LTSHTable.Tag:                         // Other OpenType Table
                    //LTSH = LTSHTable.Read(reader);
                    break;

                case MATHTable.Tag:                         // Advanced Typographic Table
                    //MATH = MATHTable.Read(reader);
                    break;

                case MaxpTable.Tag:                         // Required Table
                    maxp = MaxpTable.Read(reader);
                    break;

                case MERGTable.Tag:                         // Other OpenType Table
                    //MERG = MERGTable.Read(reader);
                    break;

                case MetaTable.Tag:                         // Other OpenType Table
                    //meta = MetaTable.Read(reader);
                    break;

                case MVARTable.Tag:                         // OpenType Font Variations
                    //MVAR = MVARTable.Read(reader);
                    break;

                case NameTable.Tag:                         // Required Table
                    name = NameTable.Read(reader);
                    break;

                case OS2Table.Tag:                          // Required Table
                    //OS2 = OS2Table.Read(reader);
                    break;

                case PcltTable.Tag:                         // Other OpenType Table
                    pclt = PcltTable.Read(reader);
                    break;

                case PostTable.Tag:                         // Required Table
                    //post = PostTable.Read(reader, record);
                    break;

                case PrepTable.Tag:                         // Related to TrueType Outlines
                    prep = PrepTable.Read(reader, record);
                    break;

                case SbixTable.Tag:                         // Related to Bitmap Glyphs, Related to Color Fonts
                    sbix = SbixTable.Read(reader, maxp);
                    break;

                case STATTable.Tag:                         // OpenType Font Variations, Other OpenType Table
                    //STAT = STATTable.Read(reader);
                    break;

                case SVGTable.Tag:                          // Related to SVG Outlines, Related to Color Fonts
                    //SVG = SVGTable.Read(reader);
                    break;

                case VDMXTable.Tag:                         // Other OpenType Table
                    //VDMX = VDMXTable.Read(reader);
                    break;

                case VheaTable.Tag:                         // Other OpenType Table
                    //vhea = VheaTable.Read(reader);
                    break;

                case VmtxTable.Tag:                         // Other OpenType Table
                    //vmtx = VmtxTable.Read(reader);
                    break;

                case VORGTable.Tag:                         // Related to CFF Outlines
                    //VORG = VORGTable.Read(reader);
                    break;

                case VVARTable.Tag:                         // OpenType Font Variations
                    //VVAR = VVARTable.Read(reader);
                    break;
                }
                                #if DEBUG
                if (Font.IsDebug)
                {
                    memory = GC.GetTotalMemory(false) - memory;
                    Console.WriteLine("{0} memory: {1}", record.tableTag, memory);
                }
                                #endif
            }
        }
コード例 #10
0
 public void ReadTableRecords(BinaryReaderFont reader)
 {
     offset  = OffsetTable.Read(reader);
     Records = TableRecord.ReadArray(reader, offset.numTables);
     Array.Sort(Records, (a, b) => {
         if (a.tableTag == HeadTable.Tag)
         {
             return(-1);
         }
         if (b.tableTag == HeadTable.Tag)
         {
             return(1);
         }
         if (a.tableTag == MaxpTable.Tag)
         {
             return(-1);
         }
         if (b.tableTag == MaxpTable.Tag)
         {
             return(1);
         }
         if (a.tableTag == HheaTable.Tag)
         {
             return(-1);
         }
         if (b.tableTag == HheaTable.Tag)
         {
             return(1);
         }
         if (a.tableTag == LocaTable.Tag)
         {
             return(-1);
         }
         if (b.tableTag == LocaTable.Tag)
         {
             return(1);
         }
         if (a.tableTag == EBLCTable.Tag)
         {
             return(-1);
         }
         if (b.tableTag == EBLCTable.Tag)
         {
             return(1);
         }
         if (a.tableTag == CBLCTable.Tag)
         {
             return(-1);
         }
         if (b.tableTag == CBLCTable.Tag)
         {
             return(1);
         }
         if (a.offset < b.offset)
         {
             return(-1);
         }
         if (a.offset > b.offset)
         {
             return(1);
         }
         return(0);
     });
 }