本文整理汇总了Java中com.google.typography.font.sfntly.Font.MacintoshEncodingId类的典型用法代码示例。如果您正苦于以下问题:Java MacintoshEncodingId类的具体用法?Java MacintoshEncodingId怎么用?Java MacintoshEncodingId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MacintoshEncodingId类属于com.google.typography.font.sfntly.Font包,在下文中一共展示了MacintoshEncodingId类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listNameEntries
import com.google.typography.font.sfntly.Font.MacintoshEncodingId; //导入依赖的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;
}
示例2: testSubsetGlyphs
import com.google.typography.font.sfntly.Font.MacintoshEncodingId; //导入依赖的package包/类
public void testSubsetGlyphs() throws Exception {
int glyphCount = 11;
Font[] srcFontArray = TestFontUtils.loadFont(fontFile);
Font srcFont = srcFontArray[0];
LocaTable srcLocaTable = srcFont.getTable(Tag.loca);
GlyphTable srcGlyphTable = srcFont.getTable(Tag.glyf);
List<Integer> srcLoca = new ArrayList<Integer>(glyphCount + 1);
for (int i = 0; i <= glyphCount + 1; i++) {
srcLoca.add(srcLocaTable.loca(i));
}
FontFactory factory = FontFactory.getInstance();
Subsetter subsetter = new DumbSubsetter(srcFont, factory);
// BitSet glyphs = new BitSet();
// glyphs.set(0, 10);
List<Integer> glyphs = new ArrayList<Integer>(glyphCount);
glyphs.add(0);
glyphs.add(1);
glyphs.add(2);
glyphs.add(3);
glyphs.add(4);
glyphs.add(5);
glyphs.add(6);
glyphs.add(7);
glyphs.add(8);
glyphs.add(9);
glyphs.add(11);
glyphs.add(10);
subsetter.setGlyphs(glyphs);
List<CMapTable.CMapId> cmapIds = new ArrayList<CMapTable.CMapId>();
cmapIds.add(CMapTable.CMapId.getInstance(
PlatformId.Macintosh.value(), MacintoshEncodingId.Mongolian.value()));
cmapIds.add(CMapTable.CMapId.WINDOWS_BMP);
subsetter.setCMaps(cmapIds, 1);
Set<Integer> removeTables = new HashSet<Integer>();
removeTables.add(Tag.GPOS);
removeTables.add(Tag.GSUB);
removeTables.add(Tag.kern);
subsetter.setRemoveTables(removeTables);
Font.Builder dstFontBuilder = subsetter.subset();
Map<Integer, Table.Builder<? extends Table>> tableBuilders = dstFontBuilder.tableBuilderMap();
Set<Integer> builderTags = dstFontBuilder.tableBuilderMap().keySet();
Font dstFont = dstFontBuilder.build();
LocaTable dstLocaTable = dstFont.getTable(Tag.loca);
// TODO(stuartg): subsetter needs to modify other tables with the new glyph
List<Integer> dstLoca = new ArrayList<Integer>(glyphCount + 1);
for (int i = 0; i <= glyphCount + 1; i++) {
dstLoca.add(dstLocaTable.loca(i));
}
for (int i = 0; i <= 10; i++) {
assertEquals(srcLoca.get(i), dstLoca.get(i));
}
assertEquals(srcLoca.get(11) - srcLoca.get(10), dstLoca.get(12) - dstLoca.get(11));
assertEquals(srcLoca.get(12) - srcLoca.get(11), dstLoca.get(11) - dstLoca.get(10));
CMapTable cmapTable = dstFont.getTable(Tag.cmap);
assertNotNull(cmapTable.cmap(CMapTable.CMapId.WINDOWS_BMP));
assertEquals(1, cmapTable.numCMaps());
// make sure tables removed
assertFalse(dstFont.hasTable(Tag.GPOS));
assertFalse(dstFont.hasTable(Tag.GSUB));
assertFalse(dstFont.hasTable(Tag.kern));
if (DEBUG) {
File dstFontFile = TestFontUtils.serializeFont(dstFont, ".ttf");
System.out.println(dstFontFile);
}
}