本文整理汇总了Java中com.google.typography.font.sfntly.table.core.NameTable.NameEntry类的典型用法代码示例。如果您正苦于以下问题:Java NameEntry类的具体用法?Java NameEntry怎么用?Java NameEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NameEntry类属于com.google.typography.font.sfntly.table.core.NameTable包,在下文中一共展示了NameEntry类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lintNameTable
import com.google.typography.font.sfntly.table.core.NameTable.NameEntry; //导入依赖的package包/类
private void lintNameTable(Font font) {
// Test if name entries are consistent. Logic is adapted from fix_full_font_name in
// font_optimizer.
NameTable name = (NameTable) font.getTable(Tag.name);
for (NameEntry entry : name) {
// System.out.println(entry);
if (entry.nameId() == NameId.FontFamilyName.value()) {
for (NameEntry entry2 : name) {
if (entry2.nameId() == NameId.FullFontName.value() &&
entry.platformId() == entry2.platformId() &&
entry.encodingId() == entry2.encodingId() &&
entry.languageId() == entry2.languageId()) {
if (!entry2.name().startsWith(entry.name())) {
reportProblem("Full font name doesn't begin with family name: " +
"FontFamilyName = " + entry.name() + "; FullFontName = " + entry2.name());
}
}
}
}
}
}
示例2: listNameEntries
import com.google.typography.font.sfntly.table.core.NameTable.NameEntry; //导入依赖的package包/类
/**
* Gets a list of entries in the name table of a font. These entries contain
* information related to the font, such as the font name, style name, and
* copyright notices.
*
* @param font
* the source font
* @return a list of entries in the name table of the font
*/
public static DataDisplayTable listNameEntries(Font font) {
String[] header = { "Platform", "Encoding", "Language", "Name", "Value" };
Align[] displayAlignment = { Align.Left, Align.Left, Align.Left, Align.Left, Align.Left };
DataDisplayTable table = new DataDisplayTable(Arrays.asList(header));
table.setAlignment(Arrays.asList(displayAlignment));
NameTable nameTable = (NameTable) FontUtils.getTable(font, Tag.name);
for (NameEntry entry : nameTable) {
String eidEntry = ""; // Platform-specific encoding
String lidEntry = ""; // Language
switch (PlatformId.valueOf(entry.platformId())) {
case Unicode:
eidEntry = UnicodeEncodingId.valueOf(entry.encodingId()).toString();
lidEntry = UnicodeLanguageId.valueOf(entry.languageId()).toString();
break;
case Macintosh:
eidEntry = MacintoshEncodingId.valueOf(entry.encodingId()).toString();
lidEntry = MacintoshLanguageId.valueOf(entry.languageId()).toString();
break;
case Windows:
eidEntry = WindowsEncodingId.valueOf(entry.encodingId()).toString();
lidEntry = WindowsLanguageId.valueOf(entry.languageId()).toString();
break;
default:
break;
}
String[] data = { String.format(
"%s (id=%d)", PlatformId.valueOf(entry.platformId()).toString(), entry.platformId()),
String.format("%s (id=%d)", eidEntry, entry.encodingId()),
String.format("%s (id=%d)", lidEntry, entry.languageId()),
NameId.valueOf(entry.nameId()).toString(), entry.name() };
table.add(Arrays.asList(data));
}
return table;
}
示例3: buildAndCheckFont
import com.google.typography.font.sfntly.table.core.NameTable.NameEntry; //导入依赖的package包/类
public static
Font[] buildAndCheckFont(FontFactory fontFactory, InputStream is, int debug) throws IOException {
Font[] fontArray = fontFactory.loadFonts(is);
for (Font font : fontArray) {
if (debug >= 1) {
logger.info(font.toString());
}
FontHeaderTable head = font.getTable(Tag.head);
if (head != null) {
long magicNumber = head.magicNumber();
if (0x5F0F3CF5 != magicNumber) {
throw new RuntimeException("Magic number is incorrect.");
}
if (debug >= 2) {
logger.fine("magic number = " + Long.toHexString(magicNumber));
MaximumProfileTable maxp = font.getTable(Tag.maxp);
logger.fine("Number of glyphs = " + maxp.numGlyphs());
logger.fine("\n------ Tables by File Location");
}
} else {
// should find a bhed table if no head table
FontDataTable bhed = font.getTable(Tag.intValue("bhed"));
if (bhed == null) {
throw new RuntimeException("No head table or bhed");
}
}
Set<Table> tables = new TreeSet<Table>(TABLE_COMPARATOR_BY_OFFSET);
tables.addAll(font.tableMap().values());
for (Table table : tables) {
if (debug >= 2) {
System.out.println(table);
}
Header header = table.header();
boolean csValid = table.calculatedChecksum() == header.checksum();
if (!csValid) {
logger.severe("\t**** Checksum not valid!");
logger.severe("\tcalculated = 0x" + Long.toHexString(table.calculatedChecksum()));
logger.severe("\tread = 0x" + Long.toHexString(header.checksum()));
throw new RuntimeException("Checksum for table " + Tag.stringValue(header.tag()));
}
}
if (debug >= 2) {
logger.fine("\n------ CMap Tables");
CMapTable cmap = (CMapTable) font.getTable(Tag.cmap);
for (CMap cmt : cmap) {
logger.fine(cmt.toString());
for (int c = 0; c < 256; c++) {
logger.finer(c + " = " + cmt.glyphId(c));
}
}
logger.fine("\n----- Name Tables");
NameTable name = (NameTable) font.getTable(Tag.name);
for (NameEntry entry : name) {
logger.finer(entry.toString());
}
}
}
return fontArray;
}