public override void Read(BinaryReader reader, Resource resource) { reader.BaseStream.Position = Offset; CRC32 = reader.ReadUInt32(); var size = reader.ReadUInt16(); for (var i = 0; i < size; i++) { var entry = new NameEntry { Name = reader.ReadNullTermString(Encoding.UTF8), Unknown1 = reader.ReadUInt32(), // TODO: This might be uint64 and be m_nId, same as RERL Unknown2 = reader.ReadUInt32(), }; Names.Add(entry); } var headerSize = reader.BaseStream.Position - Offset; Data = reader.ReadBytes((int)Size - (int)headerSize); if (Crc32.Compute(Data) != CRC32) { throw new InvalidDataException("CRC32 mismatch for read data."); } }
public override void Read(BinaryReader reader, Resource resource) { reader.BaseStream.Position = this.Offset; CRC32 = reader.ReadUInt32(); var size = reader.ReadUInt16(); int headerSize = 4 + 2; for (var i = 0; i < size; i++) { var entry = new NameEntry { Name = reader.ReadNullTermString(Encoding.UTF8), CRC32 = reader.ReadUInt32(), }; Names.Add(entry); headerSize += entry.Name.Length + 1 + 4; // string length + null byte + 4 bytes } Data = reader.ReadBytes((int)this.Size - headerSize); if (Crc32.Compute(Data) != CRC32) { throw new InvalidDataException("CRC32 mismatch for read data."); } }
private void ReadNames(FileStream fs) { int pos = NameOffset; Names = new List<NameEntry>(); for (int i = 0; i < NameCount; i++) { int len = ReadInt32(fs, pos); pos +=4; fs.Seek(pos, SeekOrigin.Begin); string s = ""; for (int j = 0; j < len - 1; j++) { s += (char)fs.ReadByte(); pos++; } pos++; int unk1 = ReadInt32(fs, pos); int flags = ReadInt32(fs, pos + 4); pos += 8; NameEntry e = new NameEntry(); e.name = s; e.unk = unk1; e.flags = flags; Names.Add(e); } }
/// <summary> /// UDKFile class constructor. It also load namelist, importlist and exportinfo (not exportdata) from udk file /// </summary> /// <param name="udkFilePath">full path + file name of desired udk file.</param> public UDKFile(string udkFilePath, bool fullFileInMemory = false) { Loaded = true; FileName = Path.GetFullPath(udkFilePath); using (FileStream udkStream = File.OpenRead(FileName)) { Names = new List<NameEntry>(); Imports = new List<ImportEntry>(); Exports = new List<ExportEntry>(); udkStream.Read(header, 0, header.Length); //unsure about magic number. for now just let it try anything if (magic != 2653586369) { //throw new FormatException("not a udk file"); } //again, unsure of what versions ought to be supported if (lowVers != 684 && highVers != 0) { //throw new FormatException("unsupported version"); } Stream listsStream; listsStream = udkStream; headerEnd = NameOffset; // fill names list listsStream.Seek(NameOffset, SeekOrigin.Begin); for (int i = 0; i < NameCount; i++) { long currOffset = listsStream.Position; int strLength = listsStream.ReadValueS32(); NameEntry n = new NameEntry(); if (strLength < 0) { n.name = listsStream.ReadString(strLength * -2, true, Encoding.Unicode); } else { n.name = listsStream.ReadString(strLength, true, Encoding.ASCII); } n.unk = listsStream.ReadValueS32(); n.flags = listsStream.ReadValueS32(); Names.Add(n); } //Debug.WriteLine("Names done. Current offset: "+listsStream.Position); //Debug.WriteLine("Import Offset: " + ImportOffset); // fill import list //Console.Out.WriteLine("IMPORT OFFSET: " + ImportOffset); listsStream.Seek(ImportOffset, SeekOrigin.Begin); byte[] buffer = new byte[ImportEntry.byteSize]; for (int i = 0; i < ImportCount; i++) { long offset = listsStream.Position; ImportEntry e = new ImportEntry(this, listsStream); Imports.Add(e); //Debug.WriteLine("Read import " + i + " " + e.ObjectName + ", offset: " + offset); }; // fill export list (only the headers, not the data) listsStream.Seek(ExportOffset, SeekOrigin.Begin); //Console.Out.WriteLine("Export OFFSET: " + ImportOffset); for (int i = 0; i < ExportCount; i++) { uint expInfoOffset = (uint)listsStream.Position; listsStream.Seek(44, SeekOrigin.Current); int count = listsStream.ReadValueS32(); listsStream.Seek(-48, SeekOrigin.Current); int expInfoSize = 68 + (count * 4); buffer = new byte[expInfoSize]; listsStream.Read(buffer, 0, buffer.Length); ExportEntry e = new ExportEntry(this, buffer, expInfoOffset); //Debug.WriteLine("Read export " + i + " " + e.ObjectName + ", offset: " + expInfoOffset+ ", size: "+expInfoSize); Exports.Add(e); } } Debug.WriteLine(getMetadataString()); }
public void RefreshList1() { listBox1.Items.Clear(); toolStripComboBox1.Items.Clear(); foreach (int index in Materials) toolStripComboBox1.Items.Add("#" + index + " : " + pcc.Exports[index].ObjectName); Objects = new List<NameEntry>(); for (int i = 0; i < pcc.Exports.Count(); i++) { if (pcc.Exports[i].ClassName == "StaticMesh") { NameEntry n = new NameEntry(); n.index = i; listBox1.Items.Add("StM#" + i + " : " + pcc.Exports[i].ObjectName); Objects.Add(n); } if (pcc.Exports[i].ClassName == "SkeletalMesh") { NameEntry n = new NameEntry(); n.index = i; listBox1.Items.Add("SkM#" + i + " : " + pcc.Exports[i].ObjectName); Objects.Add(n); } } }
public Typeface Read(Stream stream, ReadFlags readFlags = ReadFlags.Full) { var little = BitConverter.IsLittleEndian; using (var input = new ByteOrderSwappingBinaryReader(stream)) { ushort majorVersion = input.ReadUInt16(); ushort minorVersion = input.ReadUInt16(); ushort tableCount = input.ReadUInt16(); ushort searchRange = input.ReadUInt16(); ushort entrySelector = input.ReadUInt16(); ushort rangeShift = input.ReadUInt16(); var tables = new TableEntryCollection(); for (int i = 0; i < tableCount; i++) { tables.AddEntry(new UnreadTableEntry(ReadTableHeader(input))); } //------------------------------------------------------------------ OS2Table os2Table = ReadTableIfExists(tables, input, new OS2Table()); NameEntry nameEntry = ReadTableIfExists(tables, input, new NameEntry()); Head header = ReadTableIfExists(tables, input, new Head()); MaxProfile maximumProfile = ReadTableIfExists(tables, input, new MaxProfile()); HorizontalHeader horizontalHeader = ReadTableIfExists(tables, input, new HorizontalHeader()); HorizontalMetrics horizontalMetrics = ReadTableIfExists(tables, input, new HorizontalMetrics(horizontalHeader.HorizontalMetricsCount, maximumProfile.GlyphCount)); //-------------- Cmap cmaps = ReadTableIfExists(tables, input, new Cmap()); GlyphLocations glyphLocations = ReadTableIfExists(tables, input, new GlyphLocations(maximumProfile.GlyphCount, header.WideGlyphLocations)); Glyf glyf = ReadTableIfExists(tables, input, new Glyf(glyphLocations)); //-------------- Gasp gaspTable = ReadTableIfExists(tables, input, new Gasp()); VerticalDeviceMetrics vdmx = ReadTableIfExists(tables, input, new VerticalDeviceMetrics()); //-------------- PostTable postTable = ReadTableIfExists(tables, input, new PostTable()); Kern kern = ReadTableIfExists(tables, input, new Kern()); //-------------- //advanced typography GDEF gdef = ReadTableIfExists(tables, input, new GDEF()); GSUB gsub = ReadTableIfExists(tables, input, new GSUB()); GPOS gpos = ReadTableIfExists(tables, input, new GPOS()); BASE baseTable = ReadTableIfExists(tables, input, new BASE()); COLR colr = ReadTableIfExists(tables, input, new COLR()); CPAL cpal = ReadTableIfExists(tables, input, new CPAL()); VerticalHeader vhea = ReadTableIfExists(tables, input, new VerticalHeader()); if (vhea != null) { VerticalMatric vmtx = ReadTableIfExists(tables, input, new VerticalMatric(vhea.NumOfLongVerMetrics)); } EBLCTable fontBmpTable = ReadTableIfExists(tables, input, new EBLCTable()); //--------------------------------------------- //about truetype instruction init //--------------------------------------------- var typeface = new Typeface( nameEntry, header.Bounds, header.UnitsPerEm, glyf.Glyphs, horizontalMetrics, os2Table); //---------------------------- typeface.CmapTable = cmaps; typeface.KernTable = kern; typeface.GaspTable = gaspTable; typeface.MaxProfile = maximumProfile; typeface.HheaTable = horizontalHeader; //---------------------------- FpgmTable fpgmTable = ReadTableIfExists(tables, input, new FpgmTable()); //control values table CvtTable cvtTable = ReadTableIfExists(tables, input, new CvtTable()); if (cvtTable != null) { typeface.ControlValues = cvtTable.controlValues; } if (fpgmTable != null) { typeface.FpgmProgramBuffer = fpgmTable.programBuffer; } PrepTable propProgramTable = ReadTableIfExists(tables, input, new PrepTable()); if (propProgramTable != null) { typeface.PrepProgramBuffer = propProgramTable.programBuffer; } //------------------------- typeface.LoadOpenFontLayoutInfo( gdef, gsub, gpos, baseTable, colr, cpal); return(typeface); } }
private void Name_KeyUp(object sender, KeyEventArgs e) { NameEntry.GetBindingExpression(TextBox.TextProperty).UpdateSource(); }
public NameEntry(NameEntry next, AccessorLetExpr e) { Next = next; E = e; }
internal Typeface ReadTableEntryCollection(TableEntryCollection tables, BinaryReader input) { OS2Table os2Table = ReadTableIfExists(tables, input, new OS2Table()); NameEntry nameEntry = ReadTableIfExists(tables, input, new NameEntry()); Head header = ReadTableIfExists(tables, input, new Head()); MaxProfile maximumProfile = ReadTableIfExists(tables, input, new MaxProfile()); HorizontalHeader horizontalHeader = ReadTableIfExists(tables, input, new HorizontalHeader()); HorizontalMetrics horizontalMetrics = ReadTableIfExists(tables, input, new HorizontalMetrics(horizontalHeader.HorizontalMetricsCount, maximumProfile.GlyphCount)); //--- PostTable postTable = ReadTableIfExists(tables, input, new PostTable()); CFFTable cff = ReadTableIfExists(tables, input, new CFFTable()); //-------------- Cmap cmaps = ReadTableIfExists(tables, input, new Cmap()); GlyphLocations glyphLocations = ReadTableIfExists(tables, input, new GlyphLocations(maximumProfile.GlyphCount, header.WideGlyphLocations)); Glyf glyf = ReadTableIfExists(tables, input, new Glyf(glyphLocations)); //-------------- Gasp gaspTable = ReadTableIfExists(tables, input, new Gasp()); VerticalDeviceMetrics vdmx = ReadTableIfExists(tables, input, new VerticalDeviceMetrics()); //-------------- Kern kern = ReadTableIfExists(tables, input, new Kern()); //deprecated //-------------- //advanced typography GDEF gdef = ReadTableIfExists(tables, input, new GDEF()); GSUB gsub = ReadTableIfExists(tables, input, new GSUB()); GPOS gpos = ReadTableIfExists(tables, input, new GPOS()); BASE baseTable = ReadTableIfExists(tables, input, new BASE()); JSTF jstf = ReadTableIfExists(tables, input, new JSTF()); COLR colr = ReadTableIfExists(tables, input, new COLR()); CPAL cpal = ReadTableIfExists(tables, input, new CPAL()); VerticalHeader vhea = ReadTableIfExists(tables, input, new VerticalHeader()); if (vhea != null) { VerticalMetrics vmtx = ReadTableIfExists(tables, input, new VerticalMetrics(vhea.NumOfLongVerMetrics)); } STAT stat = ReadTableIfExists(tables, input, new STAT()); if (stat != null) { FVar fvar = ReadTableIfExists(tables, input, new FVar()); if (fvar != null) { GVar gvar = ReadTableIfExists(tables, input, new GVar()); CVar cvar = ReadTableIfExists(tables, input, new CVar()); HVar hvar = ReadTableIfExists(tables, input, new HVar()); MVar mvar = ReadTableIfExists(tables, input, new MVar()); AVar avar = ReadTableIfExists(tables, input, new AVar()); } } //test math table MathTable mathtable = ReadTableIfExists(tables, input, new MathTable()); //--------------------------------------------- //about truetype instruction init //--------------------------------------------- Typeface typeface = null; bool isPostScriptOutline = false; bool isBitmapFont = false; if (glyf == null) { //check if this is cff table ? if (cff == null) { //check cbdt/cblc ? CBLC cblcTable = ReadTableIfExists(tables, input, new CBLC()); if (cblcTable != null) { CBDT cbdtTable = ReadTableIfExists(tables, input, new CBDT()); //read cbdt //bitmap font BitmapFontGlyphSource bmpFontGlyphSrc = new BitmapFontGlyphSource(cblcTable, cbdtTable); Glyph[] glyphs = bmpFontGlyphSrc.BuildGlyphList(); typeface = new Typeface( nameEntry, header.Bounds, header.UnitsPerEm, bmpFontGlyphSrc, glyphs, horizontalMetrics, os2Table); isBitmapFont = true; } else { //TODO: EBLC fontBmpTable = ReadTableIfExists(tables, input, new EBLC()); throw new NotSupportedException(); } } else { //... //PostScript outline font isPostScriptOutline = true; typeface = new Typeface( nameEntry, header.Bounds, header.UnitsPerEm, cff, horizontalMetrics, os2Table); } } else { typeface = new Typeface( nameEntry, header.Bounds, header.UnitsPerEm, glyf.Glyphs, horizontalMetrics, os2Table); } //---------------------------- typeface.CmapTable = cmaps; typeface.KernTable = kern; typeface.GaspTable = gaspTable; typeface.MaxProfile = maximumProfile; typeface.HheaTable = horizontalHeader; //---------------------------- if (!isPostScriptOutline && !isBitmapFont) { FpgmTable fpgmTable = ReadTableIfExists(tables, input, new FpgmTable()); //control values table CvtTable cvtTable = ReadTableIfExists(tables, input, new CvtTable()); if (cvtTable != null) { typeface.ControlValues = cvtTable._controlValues; } if (fpgmTable != null) { typeface.FpgmProgramBuffer = fpgmTable._programBuffer; } PrepTable propProgramTable = ReadTableIfExists(tables, input, new PrepTable()); if (propProgramTable != null) { typeface.PrepProgramBuffer = propProgramTable._programBuffer; } } //------------------------- typeface.LoadOpenFontLayoutInfo( gdef, gsub, gpos, baseTable, colr, cpal); //------------ { SvgTable svgTable = ReadTableIfExists(tables, input, new SvgTable()); if (svgTable != null) { typeface._svgTable = svgTable; } } typeface.PostTable = postTable; if (mathtable != null) { var mathGlyphLoader = new MathGlyphLoader(); mathGlyphLoader.LoadMathGlyph(typeface, mathtable); } #if DEBUG //test //int found = typeface.GetGlyphIndexByName("Uacute"); if (typeface.IsCffFont) { //optional typeface.UpdateAllCffGlyphBounds(); } #endif return(typeface); }
private TrueTypeFontTable ReadNameTable(uint length, TrueTypeTableEntryList list, BigEndianReader reader) { NamingTable nt = new NamingTable(reader.Position); nt.Format = reader.ReadUInt16(); nt.Count = reader.ReadUInt16(); nt.StringOffset = reader.ReadUInt16(); nt.Names = new NameEntryList(); List <NameRecord> records = new List <NameRecord>(); NameEntry entry; if (nt.Count > 0) { for (int i = 0; i < nt.Count; i++) { NameRecord rec = new NameRecord(); rec.PlatformID = reader.ReadUInt16(); rec.EncodingID = reader.ReadUInt16(); rec.LanguageID = reader.ReadUInt16(); rec.NameID = reader.ReadUInt16(); rec.StringLength = reader.ReadUInt16(); rec.StringDataOffset = reader.ReadUInt16(); records.Add(rec); } long startStore = nt.FileOffset + nt.StringOffset; int currlang = System.Globalization.CultureInfo.CurrentCulture.LCID; int parentlang = System.Globalization.CultureInfo.CurrentCulture.Parent != null ? System.Globalization.CultureInfo.CurrentCulture.Parent.LCID : 0; foreach (NameRecord rec in records) { reader.Position = startStore + (long)rec.StringDataOffset; if (rec.PlatformID == 0 || rec.PlatformID == 3) { rec.Value = reader.ReadUnicodeString(rec.StringLength); } else { rec.Value = reader.ReadString(rec.StringLength); } if (nt.Names.TryGetEntry(rec.NameID, out entry) == false) { entry = new NameEntry(); entry.NameID = rec.NameID; nt.Names.Add(entry); } entry.NameItems.Add(rec); if (rec.LanguageID == 0) { entry.InvariantName = rec.Value; } else if (rec.LanguageID == currlang) { entry.LocalName = rec.Value; } else if (rec.LanguageID == parentlang && string.IsNullOrEmpty(entry.LocalName)) { entry.LocalName = rec.Value; } } } return(nt); }
internal bool ReadTableEntryCollection(Typeface typeface, RestoreTicket ticket, TableEntryCollection tables, BinaryReader input) { if (ticket != null) { return(ReadTableEntryCollectionOnRestoreMode(typeface, ticket, tables, input)); } typeface.SetTableEntryCollection(tables.CloneTableHeaders()); var rd = new EntriesReaderHelper(tables, input); //PART 1: basic information OS2Table os2Table = rd.Read(new OS2Table()); Meta meta = rd.Read(new Meta()); NameEntry nameEntry = rd.Read(new NameEntry()); Head head = rd.Read(new Head()); MaxProfile maxProfile = rd.Read(new MaxProfile()); HorizontalHeader horizontalHeader = rd.Read(new HorizontalHeader()); HorizontalMetrics horizontalMetrics = rd.Read(new HorizontalMetrics(horizontalHeader.NumberOfHMetrics, maxProfile.GlyphCount)); VerticalHeader vhea = rd.Read(new VerticalHeader()); if (vhea != null) { VerticalMetrics vmtx = rd.Read(new VerticalMetrics(vhea.NumOfLongVerMetrics)); } Cmap cmaps = rd.Read(new Cmap()); VerticalDeviceMetrics vdmx = rd.Read(new VerticalDeviceMetrics()); Kern kern = rd.Read(new Kern()); //------------------------------------ //PART 2: glyphs detail //2.1 True type font GlyphLocations glyphLocations = rd.Read(new GlyphLocations(maxProfile.GlyphCount, head.WideGlyphLocations)); Glyf glyf = rd.Read(new Glyf(glyphLocations)); Gasp gaspTable = rd.Read(new Gasp()); COLR colr = rd.Read(new COLR()); CPAL cpal = rd.Read(new CPAL()); //2.2 Cff font PostTable postTable = rd.Read(new PostTable()); CFFTable cff = rd.Read(new CFFTable()); //additional math table (if available) MathTable mathtable = rd.Read(new MathTable()); //------------------------------------ //PART 3: advanced typography GDEF gdef = rd.Read(new GDEF()); GSUB gsub = rd.Read(new GSUB()); GPOS gpos = rd.Read(new GPOS()); BASE baseTable = rd.Read(new BASE()); JSTF jstf = rd.Read(new JSTF()); STAT stat = rd.Read(new STAT()); if (stat != null) { //variable font FVar fvar = rd.Read(new FVar()); if (fvar != null) { GVar gvar = rd.Read(new GVar()); CVar cvar = rd.Read(new CVar()); HVar hvar = rd.Read(new HVar()); MVar mvar = rd.Read(new MVar()); AVar avar = rd.Read(new AVar()); } } bool isPostScriptOutline = false; bool isBitmapFont = false; typeface.SetBasicTypefaceTables(os2Table, nameEntry, head, horizontalMetrics); if (glyf == null) { //check if this is cff table ? if (cff == null) { //check cbdt/cblc ? CBLC cblcTable = rd.Read(new CBLC()); if (cblcTable != null) { CBDT cbdtTable = rd.Read(new CBDT()); //read cbdt //bitmap font BitmapFontGlyphSource bmpFontGlyphSrc = new BitmapFontGlyphSource(cblcTable); bmpFontGlyphSrc.LoadCBDT(cbdtTable); Glyph[] glyphs = bmpFontGlyphSrc.BuildGlyphList(); typeface.SetBitmapGlyphs(glyphs, bmpFontGlyphSrc); isBitmapFont = true; } else { //TODO: EBLC fontBmpTable = rd.Read(new EBLC()); throw new NotSupportedException(); } } else { isPostScriptOutline = true; typeface.SetCffFontSet(cff.Cff1FontSet); } } else { typeface.SetTtfGlyphs(glyf.Glyphs); } //---------------------------- typeface.CmapTable = cmaps; typeface.KernTable = kern; typeface.MaxProfile = maxProfile; typeface.HheaTable = horizontalHeader; //---------------------------- typeface.GaspTable = gaspTable; if (!isPostScriptOutline && !isBitmapFont) { //for true-type font outline FpgmTable fpgmTable = rd.Read(new FpgmTable()); //control values table CvtTable cvtTable = rd.Read(new CvtTable()); PrepTable propProgramTable = rd.Read(new PrepTable()); typeface.ControlValues = cvtTable?._controlValues; typeface.FpgmProgramBuffer = fpgmTable?._programBuffer; typeface.PrepProgramBuffer = propProgramTable?._programBuffer; } //------------------------- typeface.LoadOpenFontLayoutInfo( gdef, gsub, gpos, baseTable, colr, cpal); //------------ typeface.SetSvgTable(rd.Read(new SvgTable())); typeface.PostTable = postTable; if (mathtable != null) { MathGlyphLoader.LoadMathGlyph(typeface, mathtable); } #if DEBUG //test //int found = typeface.GetGlyphIndexByName("Uacute"); if (typeface.IsCffFont) { //optional typeface.UpdateAllCffGlyphBounds(); } #endif typeface.UpdateLangs(meta); typeface.UpdateFrequentlyUsedValues(); return(true); }
public GDMSex GetSexByName(string name) { NameEntry nm = FindName(name); return((nm == null) ? GDMSex.svUnknown : nm.Sex); }
public Typeface Read(Stream stream, ReadFlags readFlags = ReadFlags.Full) { bool little = BitConverter.IsLittleEndian; using (var input = new ByteOrderSwappingBinaryReader(stream)) { ushort majorVersion = input.ReadUInt16(); ushort minorVersion = input.ReadUInt16(); ushort tableCount = input.ReadUInt16(); ushort searchRange = input.ReadUInt16(); ushort entrySelector = input.ReadUInt16(); ushort rangeShift = input.ReadUInt16(); var tables = new TableEntryCollection(); for (int i = 0; i < tableCount; i++) { tables.AddEntry(new UnreadTableEntry(ReadTableHeader(input))); } //------------------------------------------------------------------ OS2Table os2Table = ReadTableIfExists(tables, input, new OS2Table()); NameEntry nameEntry = ReadTableIfExists(tables, input, new NameEntry()); Head header = ReadTableIfExists(tables, input, new Head()); MaxProfile maximumProfile = ReadTableIfExists(tables, input, new MaxProfile()); HorizontalHeader horizontalHeader = ReadTableIfExists(tables, input, new HorizontalHeader()); HorizontalMetrics horizontalMetrics = ReadTableIfExists(tables, input, new HorizontalMetrics(horizontalHeader.HorizontalMetricsCount, maximumProfile.GlyphCount)); //--- PostTable postTable = ReadTableIfExists(tables, input, new PostTable()); CFFTable ccf = ReadTableIfExists(tables, input, new CFFTable()); //-------------- Cmap cmaps = ReadTableIfExists(tables, input, new Cmap()); GlyphLocations glyphLocations = ReadTableIfExists(tables, input, new GlyphLocations(maximumProfile.GlyphCount, header.WideGlyphLocations)); Glyf glyf = ReadTableIfExists(tables, input, new Glyf(glyphLocations)); //-------------- Gasp gaspTable = ReadTableIfExists(tables, input, new Gasp()); VerticalDeviceMetrics vdmx = ReadTableIfExists(tables, input, new VerticalDeviceMetrics()); //-------------- Kern kern = ReadTableIfExists(tables, input, new Kern()); //-------------- //advanced typography GDEF gdef = ReadTableIfExists(tables, input, new GDEF()); GSUB gsub = ReadTableIfExists(tables, input, new GSUB()); GPOS gpos = ReadTableIfExists(tables, input, new GPOS()); BASE baseTable = ReadTableIfExists(tables, input, new BASE()); COLR colr = ReadTableIfExists(tables, input, new COLR()); CPAL cpal = ReadTableIfExists(tables, input, new CPAL()); VerticalHeader vhea = ReadTableIfExists(tables, input, new VerticalHeader()); if (vhea != null) { VerticalMetrics vmtx = ReadTableIfExists(tables, input, new VerticalMetrics(vhea.NumOfLongVerMetrics)); } //test math table MathTable mathtable = ReadTableIfExists(tables, input, new MathTable()); EBLCTable fontBmpTable = ReadTableIfExists(tables, input, new EBLCTable()); //--------------------------------------------- //about truetype instruction init //--------------------------------------------- Typeface typeface = null; bool isPostScriptOutline = false; if (glyf == null) { //check if this is cff table ? if (ccf == null) { //TODO: review here throw new NotSupportedException(); } //... //PostScript outline font isPostScriptOutline = true; typeface = new Typeface( nameEntry, header.Bounds, header.UnitsPerEm, ccf, horizontalMetrics, os2Table); } else { typeface = new Typeface( nameEntry, header.Bounds, header.UnitsPerEm, glyf.Glyphs, horizontalMetrics, os2Table); } //---------------------------- typeface.CmapTable = cmaps; typeface.KernTable = kern; typeface.GaspTable = gaspTable; typeface.MaxProfile = maximumProfile; typeface.HheaTable = horizontalHeader; //---------------------------- if (!isPostScriptOutline) { FpgmTable fpgmTable = ReadTableIfExists(tables, input, new FpgmTable()); //control values table CvtTable cvtTable = ReadTableIfExists(tables, input, new CvtTable()); if (cvtTable != null) { typeface.ControlValues = cvtTable.controlValues; } if (fpgmTable != null) { typeface.FpgmProgramBuffer = fpgmTable.programBuffer; } PrepTable propProgramTable = ReadTableIfExists(tables, input, new PrepTable()); if (propProgramTable != null) { typeface.PrepProgramBuffer = propProgramTable.programBuffer; } } //------------------------- typeface.LoadOpenFontLayoutInfo( gdef, gsub, gpos, baseTable, colr, cpal); //------------ //test { SvgTable svgTable = ReadTableIfExists(tables, input, new SvgTable()); if (svgTable != null) { typeface._svgTable = svgTable; } } typeface.PostTable = postTable; if (mathtable != null) { var mathGlyphLoader = new MathGlyphLoader(); mathGlyphLoader.LoadMathGlyph(typeface, mathtable); } #if DEBUG //test int found = typeface.GetGlyphIndexByName("Uacute"); if (typeface.IsCffFont) { //optional typeface.UpdateAllCffGlyphBounds(); } #endif return(typeface); } }
public static void ReadNames() { int pos = header.NameOffset; namelist = new List<NameEntry>(); for (int i = 0; i < header.NameCount; i++) { NameEntry e = new NameEntry(); e.Offset = pos; int len = GetInt(pos) - 1; pos += 4; e.Name = ""; for (int j = 0; j < len; j++) e.Name += (char)memory[pos + j]; pos += len + 1; e.Unk1 = GetInt(pos); e.Unk2 = GetInt(pos + 4); pos += 8; namelist.Add(e); } }
public async Task <ActionResult <NameEntry> > PostNameEntry(NameEntry nameEntry) { await _repository.CreateName(nameEntry); return(CreatedAtAction("GetNameEntry", new { id = nameEntry.Id }, nameEntry)); }