private string getStringData(NameRecord record, Reader reader, long startPos) { int len = record.Length; int off = record.Offset; StringBuilder result = new StringBuilder(); byte[] buf = new byte[len]; reader.Position = (int)(startPos + off); reader.Read(buf); for (int j = 0; j < buf.Length; ++j) { if (buf[j] != 0) { result.Append((char)buf[j]); } } return(result.ToString()); }
private string getFontName(ushort platformID, ushort encodingID, ushort languageID, Reader reader, long startPos) { NameRecord recordFullName = getNameRecord(platformID, encodingID, languageID, 4); if (recordFullName != null) { return(getStringData(recordFullName, reader, startPos)); } NameRecord postScriptName = getNameRecord(platformID, encodingID, languageID, 6); if (postScriptName != null) { return(getStringData(postScriptName, reader, startPos)); } NameRecord recordFamilyName = getNameRecord(platformID, encodingID, languageID, 1); if (recordFamilyName != null) { NameRecord recordSubfamilyName = getNameRecord(platformID, encodingID, languageID, 2); string strSubfamily = ""; if (recordSubfamilyName != null) { strSubfamily = getStringData(recordSubfamilyName, reader, startPos); } if (strSubfamily == "Regular") { return(getStringData(recordFamilyName, reader, startPos)); } else { return(getStringData(recordFamilyName, reader, startPos) + strSubfamily); } } return(""); }