/// <summary> /// Sets the start character. /// </summary> /// <param name="table">The table.</param> /// <param name="characterSet">The new character set to use.</param> public void SetCharacterSet(NamingTable table, CharacterSet characterSet) { if (namingTables.ContainsKey(table)) namingTables[table] = characterSet; else namingTables.Add(table, characterSet); }
/// <summary> /// Generates a new unique name from the naming table. /// </summary> /// <param name="table">The table to generate a name from.</param> /// <returns>A unique name</returns> public string GenerateName(NamingTable table) { //Check the naming table exists if (!namingTables.ContainsKey(table)) SetCharacterSet(table, DefaultCharacterSet); //Generate a new name if (table == NamingTable.Field) //For fields append an _ to make sure it differs from properties etc return "_" + namingTables[table].Generate(); return namingTables[table].Generate(); }
/// <summary> /// Sets the start character. /// </summary> /// <param name="table">The table.</param> /// <param name="characterSet">The new character set to use.</param> public void SetCharacterSet(NamingTable table, CharacterSet characterSet) { if (namingTables.ContainsKey(table)) { namingTables[table] = characterSet; } else { namingTables.Add(table, characterSet); } }
/// <summary> /// Generates a new unique name from the naming table. /// </summary> /// <param name="table">The table to generate a name from.</param> /// <returns>A unique name</returns> public string GenerateName(NamingTable table) { //Check the naming table exists if (!namingTables.ContainsKey(table)) { SetCharacterSet(table, DefaultCharacterSet); } //Generate a new name if (table == NamingTable.Field) //For fields append an _ to make sure it differs from properties etc { return("_" + namingTables[table].Generate()); } return(namingTables[table].Generate()); }
public void SetCharacterSet(NamingTable table, CharacterSet characterSet) { namingTables[table] = characterSet; }
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); }