示例#1
0
 public void GetOffest(int glyphId, out uint offset0, out uint offset1)
 {
     if (glyphId < 0 || glyphId >= numGlyphs + 1)
     {
         offset0 = 0;
         offset1 = 0;
         return;
     }
     if (File.Exists(filePath) == false)
     {
         offset0 = 0;
         offset1 = 0;
         return;
     }
     using (Stream stream = File.OpenRead(filePath))
         using (BinaryReaderFont reader = new BinaryReaderFont(stream)) {
             if (indexToLocFormat == 0)
             {
                 reader.Position = position + glyphId * 2;
                 offset0         = (uint)(reader.ReadUInt16() * 2);
                 offset1         = (uint)(reader.ReadUInt16() * 2);
                 return;
             }
             reader.Position = position + glyphId * 4;
             offset0         = reader.ReadUInt32();
             offset1         = reader.ReadUInt32();
         }
 }
示例#2
0
 public static FeatureVariationRecord Read(BinaryReaderFont reader)
 {
     return(new FeatureVariationRecord {
         conditionSetOffset = reader.ReadUInt32(),
         featureTableSubstitutionOffset = reader.ReadUInt32()
     });
 }
示例#3
0
 public static ConstantMapGroup Read(BinaryReaderFont reader)
 {
     return(new ConstantMapGroup {
         startCharCode = reader.ReadUInt32(),
         endCharCode = reader.ReadUInt32(),
         glyphID = reader.ReadUInt32()
     });
 }
示例#4
0
 public static SignatureRecord Read(BinaryReaderFont reader)
 {
     return(new SignatureRecord {
         format = reader.ReadUInt32(),
         length = reader.ReadUInt32(),
         offset = reader.ReadUInt32()
     });
 }
示例#5
0
 public static SequentialMapGroup Read(BinaryReaderFont reader)
 {
     return(new SequentialMapGroup {
         startCharCode = reader.ReadUInt32(),
         endCharCode = reader.ReadUInt32(),
         startGlyphID = reader.ReadUInt32()
     });
 }
示例#6
0
 public static SVGTable Read(BinaryReaderFont reader)
 {
     return(new SVGTable {
         version = reader.ReadUInt16(),
         offsetToSVGDocumentList = reader.ReadUInt32(),
         reserved = reader.ReadUInt32()
     });
 }
示例#7
0
 public static DataMap Read(BinaryReaderFont reader)
 {
     return(new DataMap {
         tag = reader.ReadTag(),
         dataOffset = reader.ReadUInt32(),
         dataLength = reader.ReadUInt32()
     });
 }
示例#8
0
 public static STXHeader Read(BinaryReaderFont reader, TableRecord record)
 {
     return(new STXHeader {
         nClasses = reader.ReadUInt32(),
         classTableOffset = reader.ReadUInt32(),
         stateArrayOffset = reader.ReadUInt32(),
         entryTableOffset = reader.ReadUInt32()
     });
 }
示例#9
0
 public static TableRecord Read(BinaryReaderFont reader)
 {
     return(new TableRecord {
         tableTag = reader.ReadTag(),
         checkSum = reader.ReadUInt32(),
         offset = reader.ReadUInt32(),
         length = reader.ReadUInt32()
     });
 }
示例#10
0
 public static COLRTable Read(BinaryReaderFont reader)
 {
     return(new COLRTable {
         version = reader.ReadUInt16(),
         numBaseGlyphRecords = reader.ReadUInt16(),
         baseGlyphRecordsOffset = reader.ReadUInt32(),
         layerRecordsOffset = reader.ReadUInt32(),
         numLayerRecords = reader.ReadUInt16()
     });
 }
示例#11
0
 public static VariationAxisRecord Read(BinaryReaderFont reader)
 {
     return(new VariationAxisRecord {
         axisTag = reader.ReadTag(),
         minValue = reader.ReadUInt32(),
         defaultValue = reader.ReadUInt32(),
         maxValue = reader.ReadUInt32(),
         flags = reader.ReadUInt16(),
         axisNameID = reader.ReadUInt16()
     });
 }
示例#12
0
 public static HVARTable Read(BinaryReaderFont reader)
 {
     return(new HVARTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         itemVariationStoreOffset = reader.ReadUInt32(),
         advanceWidthMappingOffset = reader.ReadUInt32(),
         lsbMappingOffset = reader.ReadUInt32(),
         rsbMappingOffset = reader.ReadUInt32()
     });
 }
示例#13
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);
        }
示例#14
0
        /// <summary>
        /// One per glyph, sorted by glyph ID.
        /// </summary>
        //public ushort[] glyphIdArray;

        public static IndexSubTable5 Read(BinaryReaderFont reader)
        {
            IndexSubTable5 value = new IndexSubTable5();

            value.header     = IndexSubHeader.Read(reader);
            value.imageSize  = reader.ReadUInt32();
            value.bigMetrics = BigGlyphMetrics.Read(reader);
            value.numGlyphs  = reader.ReadUInt32();
            value.position   = reader.Position;
            //value.glyphIdArray = reader.ReadUInt16Array((int)value.numGlyphs);
            return(value);
        }
示例#15
0
 public static VVARTable Read(BinaryReaderFont reader)
 {
     return(new VVARTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         itemVariationStoreOffset = reader.ReadUInt32(),
         advanceHeightMappingOffset = reader.ReadUInt32(),
         tsbMappingOffset = reader.ReadUInt32(),
         bsbMappingOffset = reader.ReadUInt32(),
         vOrgMappingOffset = reader.ReadUInt32()
     });
 }
示例#16
0
        public static new CmapSubtable13 Read(BinaryReaderFont reader)
        {
            CmapSubtable13 value = new CmapSubtable13 {
                format    = reader.ReadUInt16(),
                reserved  = reader.ReadUInt16(),
                length    = reader.ReadUInt32(),
                language  = reader.ReadUInt32(),
                numGroups = reader.ReadUInt32()
            };

            value.glyphs = ConstantMapGroup.ReadArray(reader, value.numGroups);
            return(value);
        }
示例#17
0
 public static STATTable Read(BinaryReaderFont reader)
 {
     return(new STATTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         designAxisSize = reader.ReadUInt16(),
         designAxisCount = reader.ReadUInt16(),
         designAxesOffset = reader.ReadUInt32(),
         axisValueCount = reader.ReadUInt16(),
         offsetToAxisValueOffsets = reader.ReadUInt32(),
         elidedFallbackNameID = reader.ReadUInt16()
     });
 }
示例#18
0
 public static GvarTable Read(BinaryReaderFont reader)
 {
     return(new GvarTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         axisCount = reader.ReadUInt16(),
         sharedTupleCount = reader.ReadUInt16(),
         sharedTuplesOffset = reader.ReadUInt32(),
         glyphCount = reader.ReadUInt16(),
         flags = reader.ReadUInt16(),
         glyphVariationDataArrayOffset = reader.ReadUInt32()
     });
 }
示例#19
0
        public static new CmapSubtable10 Read(BinaryReaderFont reader)
        {
            CmapSubtable10 value = new CmapSubtable10();

            value.format        = reader.ReadUInt16();
            value.reserved      = reader.ReadUInt16();
            value.length        = reader.ReadUInt32();
            value.language      = reader.ReadUInt32();
            value.startCharCode = reader.ReadUInt32();
            value.numChars      = reader.ReadUInt32();
            value.glyphs        = reader.ReadUInt16Array((int)value.numChars);
            return(value);
        }
示例#20
0
        public static new CmapSubtable8 Read(BinaryReaderFont reader)
        {
            CmapSubtable8 value = new CmapSubtable8 {
                format    = reader.ReadUInt16(),
                reserved  = reader.ReadUInt16(),
                length    = reader.ReadUInt32(),
                language  = reader.ReadUInt32(),
                is32      = reader.ReadBytes(8192),
                numGroups = reader.ReadUInt32()
            };

            value.groups = SequentialMapGroup.ReadArray(reader, value.numGroups);
            return(value);
        }
示例#21
0
        /// <summary>
        /// Array of SequentialMapGroup records.
        /// </summary>
        //public SequentialMapGroup[] groups;

        public static new CmapSubtable12 Read(BinaryReaderFont reader)
        {
            CmapSubtable12 value = new CmapSubtable12();

            value.filePath  = reader.FilePath;
            value.format    = reader.ReadUInt16();
            value.reserved  = reader.ReadUInt16();
            value.length    = reader.ReadUInt32();
            value.language  = reader.ReadUInt32();
            value.numGroups = reader.ReadUInt32();
            value.position  = reader.Position;
            //value.groups = SequentialMapGroup.ReadArray(reader, value.numGroups);
            return(value);
        }
示例#22
0
 public static FeatureTableSubstitutionRecord Read(BinaryReaderFont reader)
 {
     return(new FeatureTableSubstitutionRecord {
         featureIndex = reader.ReadUInt16(),
         alternateFeatureTable = reader.ReadUInt32()
     });
 }
示例#23
0
        //public VariationStore itemVarStore;

        public static BASETable Read(BinaryReaderFont reader)
        {
            long      position = reader.Position;
            BASETable value    = new BASETable {
                majorVersion    = reader.ReadUInt16(),
                minorVersion    = reader.ReadUInt16(),
                horizAxisOffset = reader.ReadUInt16(),
                vertAxisOffset  = reader.ReadUInt16()
            };

            if (value.majorVersion == 1 && value.minorVersion == 1)
            {
                value.itemVarStoreOffset = reader.ReadUInt32();
            }
            if (value.horizAxisOffset != 0)
            {
                reader.Position = position + value.horizAxisOffset;
                value.horizAxis = AxisTable.Read(reader);
            }
            if (value.vertAxisOffset != 0)
            {
                reader.Position = position + value.vertAxisOffset;
                value.vertAxis  = AxisTable.Read(reader);
            }
            if (value.itemVarStoreOffset != 0)
            {
                reader.Position = position + value.itemVarStoreOffset;
                //value.itemVarStore =
            }
            return(value);
        }
示例#24
0
        public static OffsetTable Read(BinaryReaderFont reader)
        {
            OffsetTable value = new OffsetTable();

            value.sfntVersion = reader.ReadUInt32();
            if (value.sfntVersion != Version1 && value.sfntVersion != VersionOTTO)
            {
                throw new Exception(
                          string.Format("Parse error: sfntVersion is not valid. 0x{0:X8}", value.sfntVersion)
                          );
            }
            value.numTables   = reader.ReadUInt16();
            value.searchRange = reader.ReadUInt16();
            if (MaximumPowerOf2(value.numTables) * 16 != value.searchRange)
            {
                throw new Exception(
                          string.Format("Parse error: searchRange is not valid. {0}", value.searchRange)
                          );
            }
            value.entrySelector = reader.ReadUInt16();
            if ((ushort)Math.Log(MaximumPowerOf2(value.numTables), 2) != value.entrySelector)
            {
                throw new Exception(
                          string.Format("Parse error: entrySelector is not valid. {0}", value.entrySelector)
                          );
            }
            value.rangeShift = reader.ReadUInt16();
            if (value.numTables * 16 - value.searchRange != value.rangeShift)
            {
                /*throw new Exception(
                 *      string.Format("Parse error: rangeShift is not valid. {0}", value.rangeShift)
                 * );*/
            }
            return(value);
        }
示例#25
0
 public static ItemVariationStore Read(BinaryReaderFont reader)
 {
     return(new ItemVariationStore {
         format = reader.ReadUInt16(),
         variationRegionListOffset = reader.ReadUInt32(),
         itemVariationDataCount = reader.ReadUInt16()
     });
 }
示例#26
0
 public static FeatureVariations Read(BinaryReaderFont reader)
 {
     return(new FeatureVariations {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         featureVariationRecordCount = reader.ReadUInt32()
     });
 }
示例#27
0
 public static IndexSubTable2 Read(BinaryReaderFont reader)
 {
     return(new IndexSubTable2 {
         header = IndexSubHeader.Read(reader),
         imageSize = reader.ReadUInt32(),
         bigMetrics = BigGlyphMetrics.Read(reader)
     });
 }
示例#28
0
 public static IndexSubHeader Read(BinaryReaderFont reader)
 {
     return(new IndexSubHeader {
         indexFormat = reader.ReadUInt16(),
         imageFormat = reader.ReadUInt16(),
         imageDataOffset = reader.ReadUInt32()
     });
 }
示例#29
0
 public static EBSCTable Read(BinaryReaderFont reader)
 {
     return(new EBSCTable {
         majorVersion = reader.ReadUInt16(),
         minorVersion = reader.ReadUInt16(),
         numSizes = reader.ReadUInt32()
     });
 }
示例#30
0
        public static GlyphBitmapData19 Read(BinaryReaderFont reader)
        {
            GlyphBitmapData19 value = new GlyphBitmapData19 {
                dataLen = reader.ReadUInt32()
            };

            value.data = reader.ReadBytes((int)value.dataLen);
            return(value);
        }