private void readCmap(BinaryReaderV binred, FontTables cmapTable) { binred.BaseStream.Position = cmapTable.offset; CMap cmap = new CMap(); cmap.version = binred.ReadBigEndUInt16(); cmap.numTables = binred.ReadBigEndUInt16(); cmap.encodingRecs = new EncodingRecord[cmap.numTables]; for (int i = 0; i < cmap.numTables; i++) { EncodingRecord er = new EncodingRecord(); er.platformID = binred.ReadBigEndUInt16(); er.encodingID = binred.ReadBigEndUInt16(); er.offset = binred.ReadBigEndUInt32(); } }
private FontTables[] readFontFile(string filePath) { using (BinaryReaderV binred = new BinaryReaderV(filePath)) { fileLength = (int)binred.BaseStream.Length; header = binred.ReadBigEndUInt32(); if (header != 0x4f54544f && header != 0x00010000) //cff or ttf { return(null); } numTables = binred.ReadBigEndUInt16(); searchRange = binred.ReadBigEndUInt16(); //? entrySelector = binred.ReadBigEndUInt16(); //? rangeShift = binred.ReadBigEndUInt16(); //? FontTables[] fontTables = new FontTables[numTables]; for (int i = 0; i < numTables; i++) { FontTables ft = new FontTables(); string tagName = Encoding.ASCII.GetString(binred.ReadBytes(4)); ft.tag = tagName; ft.checkSum = binred.ReadBigEndUInt32(); ft.offset = binred.ReadBigEndUInt32(); ft.length = binred.ReadBigEndUInt32(); long hold = binred.BaseStream.Position; binred.BaseStream.Position = ft.offset; byte[] bb = binred.ReadBytes((int)ft.length); ft.data = bb; binred.BaseStream.Position = hold; fontTables[i] = ft; fontDict.Add(ft.tag, ft); } //readCmap(binred, fontDict["cmap"]); return(fontTables);//.OrderBy(p => p.offset).ToArray(); } }