public static Font[] Parse(string path) { Font[] fonts = null; if (File.Exists(path) == false) { return(fonts); } using (Stream stream = File.OpenRead(path)) using (BinaryReaderFont reader = new BinaryReaderFont(stream)) { reader.FilePath = path; string tag = reader.ReadTag(); stream.Position = 0; switch (tag) { case TTCHeader.Tag: fonts = ParseTTC(reader); break; default: fonts = new Font[] { Font.Read(reader) }; break; } } return(fonts); }
public static LangSysRecord Read(BinaryReaderFont reader) { return(new LangSysRecord { langSysTag = reader.ReadTag(), langSysOffset = reader.ReadUInt16() }); }
public static ScriptRecord Read(BinaryReaderFont reader) { return(new ScriptRecord { scriptTag = reader.ReadTag(), scriptOffset = reader.ReadUInt16() }); }
public static FeatureRecord Read(BinaryReaderFont reader) { return(new FeatureRecord { featureTag = reader.ReadTag(), featureOffset = reader.ReadUInt16() }); }
public static BaseLangSysRecord Read(BinaryReaderFont reader) { return(new BaseLangSysRecord { baseLangSysTag = reader.ReadTag(), minMaxOffset = reader.ReadUInt16() }); }
public static DataMap Read(BinaryReaderFont reader) { return(new DataMap { tag = reader.ReadTag(), dataOffset = reader.ReadUInt32(), dataLength = reader.ReadUInt32() }); }
public static FeatMinMaxRecord Read(BinaryReaderFont reader) { return(new FeatMinMaxRecord { featureTableTag = reader.ReadTag(), minCoord = reader.ReadUInt16(), maxCoord = reader.ReadUInt16() }); }
public static MvarValueRecord Read(BinaryReaderFont reader) { return(new MvarValueRecord { valueTag = reader.ReadTag(), deltaSetOuterIndex = reader.ReadUInt16(), deltaSetInnerIndex = reader.ReadUInt16() }); }
public static AxisRecord Read(BinaryReaderFont reader) { return(new AxisRecord { axisTag = reader.ReadTag(), axisNameID = reader.ReadUInt16(), axisOrdering = reader.ReadUInt16() }); }
public static GlyphData Read(BinaryReaderFont reader, uint dataLength) { return(new GlyphData { originOffsetX = reader.ReadInt16(), originOffsetY = reader.ReadInt16(), graphicType = reader.ReadTag(), data = reader.ReadBytes((int)dataLength) }); }
public static TableRecord Read(BinaryReaderFont reader) { return(new TableRecord { tableTag = reader.ReadTag(), checkSum = reader.ReadUInt32(), offset = reader.ReadUInt32(), length = reader.ReadUInt32() }); }
public static OS2Table Read(BinaryReaderFont reader) { OS2Table value = new OS2Table { version = reader.ReadUInt16(), xAvgCharWidth = reader.ReadInt16(), usWeightClass = reader.ReadUInt16(), usWidthClass = reader.ReadUInt16(), fsType = reader.ReadUInt16(), ySubscriptXSize = reader.ReadInt16(), ySubscriptYSize = reader.ReadInt16(), ySubscriptXOffset = reader.ReadInt16(), ySubscriptYOffset = reader.ReadInt16(), ySuperscriptXSize = reader.ReadInt16(), ySuperscriptYSize = reader.ReadInt16(), ySuperscriptXOffset = reader.ReadInt16(), ySuperscriptYOffset = reader.ReadInt16(), yStrikeoutSize = reader.ReadInt16(), yStrikeoutPosition = reader.ReadInt16(), sFamilyClass = reader.ReadInt16(), panose = reader.ReadBytes(10), ulUnicodeRange1 = reader.ReadUInt32(), ulUnicodeRange2 = reader.ReadUInt32(), ulUnicodeRange3 = reader.ReadUInt32(), ulUnicodeRange4 = reader.ReadUInt32(), achVendID = reader.ReadTag(), fsSelection = reader.ReadUInt16(), usFirstCharIndex = reader.ReadUInt16(), usLastCharIndex = reader.ReadUInt16(), sTypoAscender = reader.ReadInt16(), sTypoDescender = reader.ReadInt16(), sTypoLineGap = reader.ReadInt16(), usWinAscent = reader.ReadUInt16(), usWinDescent = reader.ReadUInt16() }; if (value.version >= 1) { value.ulCodePageRange1 = reader.ReadUInt32(); value.ulCodePageRange2 = reader.ReadUInt32(); } if (value.version >= 4) { value.sxHeight = reader.ReadInt16(); value.sCapHeight = reader.ReadInt16(); value.usDefaultChar = reader.ReadUInt16(); value.usBreakChar = reader.ReadUInt16(); value.usMaxContext = reader.ReadUInt16(); } if (value.version >= 5) { value.usLowerOpticalPointSize = reader.ReadUInt16(); value.usUpperOpticalPointSize = reader.ReadUInt16(); } return(value); }
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() }); }
public static BaseScriptRecord Read(BinaryReaderFont reader, long start) { BaseScriptRecord value = new BaseScriptRecord { baseScriptTag = reader.ReadTag(), baseScriptOffset = reader.ReadUInt16() }; long position = reader.Position; if (value.baseScriptOffset != 0) { reader.Position = start + value.baseScriptOffset; value.baseScript = BaseScript.Read(reader); } reader.Position = position; return(value); }
public static TTCHeader Read(BinaryReaderFont reader) { TTCHeader value = new TTCHeader(); value.ttcTag = reader.ReadTag(); if (value.ttcTag != Tag) { throw new System.Exception( string.Format("Parse error: ttcTag is not valid. {0}", value.ttcTag) ); } value.majorVersion = reader.ReadUInt16(); value.minorVersion = reader.ReadUInt16(); value.numFonts = reader.ReadUInt32(); value.offsetTable = reader.ReadUInt32Array((int)value.numFonts); if (value.majorVersion >= 2) { value.dsigTag = reader.ReadUInt32(); value.dsigLength = reader.ReadUInt32(); value.dsigOffset = reader.ReadUInt32(); } return(value); }