internal string[][] GetNames(int id) { int[] table_location; table_location = (int[])tables["name"]; if (table_location == null) { return(null); } rf.Seek(table_location[0] + 2); int numRecords = rf.ReadUnsignedShort(); int startOfStorage = rf.ReadUnsignedShort(); ArrayList names = new ArrayList(); for (int k = 0; k < numRecords; ++k) { int platformID = rf.ReadUnsignedShort(); int platformEncodingID = rf.ReadUnsignedShort(); int languageID = rf.ReadUnsignedShort(); int nameID = rf.ReadUnsignedShort(); int length = rf.ReadUnsignedShort(); int offset = rf.ReadUnsignedShort(); if (nameID == id) { int pos = rf.FilePointer; rf.Seek(table_location[0] + startOfStorage + offset); string name; if (platformID == 0 || platformID == 3 || (platformID == 2 && platformEncodingID == 1)) { name = ReadUnicodeString(length); } else { name = ReadStandardString(length); } names.Add(new string[] { platformID.ToString(), platformEncodingID.ToString(), languageID.ToString(), name }); rf.Seek(pos); } } string[][] thisName = new string[names.Count][]; for (int k = 0; k < names.Count; ++k) { thisName[k] = (string[])names[k]; } return(thisName); }
public Hashtable GetFontList() { Hashtable ttFonts = new Hashtable(); try { DirectoryInfo di = new DirectoryInfo(GetFontDirectory()); if (di.Exists) { FileInfo[] fontFiles = di.GetFiles(); for (int i = 0; i < fontFiles.Length; i++) { string filename = fontFiles[i].FullName; rf = new RandomAccessBuffer(filename); rf.Seek(0); int ttId = rf.ReadInt(); if (ttId != 0x00010000 && ttId != 0x4F54544F) { continue; } int num_tables = rf.ReadUnsignedShort(); rf.SkipBytes(6); for (int k = 0; k < num_tables; ++k) { string tag = ReadStandardString(4); rf.SkipBytes(4); int[] table_location = new int[2]; table_location[0] = rf.ReadInt(); table_location[1] = rf.ReadInt(); tables[tag] = table_location; } string[][] fullName = GetNames(4); string[][] familyName = GetNames(1); ttFonts[fullName[0][3]] = filename; } } //Console.WriteLine("Before : " + ttFonts.Count); ReadRegistry(ttFonts); //Console.WriteLine("After : " + ttFonts.Count); } catch (Exception) { } return(ttFonts); }