本文整理汇总了Java中com.google.typography.font.sfntly.table.core.NameTable.NameEntry.name方法的典型用法代码示例。如果您正苦于以下问题:Java NameEntry.name方法的具体用法?Java NameEntry.name怎么用?Java NameEntry.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.typography.font.sfntly.table.core.NameTable.NameEntry
的用法示例。
在下文中一共展示了NameEntry.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}