本文整理汇总了Java中org.newdawn.slick.UnicodeFont.addGlyphs方法的典型用法代码示例。如果您正苦于以下问题:Java UnicodeFont.addGlyphs方法的具体用法?Java UnicodeFont.addGlyphs怎么用?Java UnicodeFont.addGlyphs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.UnicodeFont
的用法示例。
在下文中一共展示了UnicodeFont.addGlyphs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFont
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void addFont(String key, String file, int size, boolean bold, boolean italic, Effect [] effects) throws SlickException {
try {
AssetManager.ASSETS_TO_LOAD++;
UnicodeFont uni = new UnicodeFont(file, size, bold, italic);
uni.addAsciiGlyphs();
uni.addGlyphs(400, 600);
uni.getEffects().add(new ColorEffect(Color.WHITE));
uni.getEffects().addAll(Arrays.asList(effects));
uni.loadGlyphs();
if((fonts != null) && (uni != null)) {
fonts.put(key, uni);
AssetManager.ASSETS_LOADED++;
System.out.println(String.format("Font Loaded: %s", key));
}
} catch(Exception ex) {
ex.printStackTrace();
System.out.printf("ERROR: Font \"%s\" could not be loaded!\n", file);
}
}
示例2: loadGlyphs
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
/**
* Adds and loads glyphs for a font.
* @param font the font to add the glyphs to
* @param s the string containing the glyphs to load
*/
public static void loadGlyphs(UnicodeFont font, String s) {
if (s == null || s.isEmpty())
return;
// get set of added strings
HashSet<String> set = loadedGlyphs.get(font);
if (set == null) {
set = new HashSet<String>();
loadedGlyphs.put(font, set);
} else if (set.contains(s))
return; // string already in set
// load glyphs
font.addGlyphs(s);
set.add(s);
try {
font.loadGlyphs();
} catch (SlickException e) {
Log.warn(String.format("Failed to load glyphs for string '%s'.", s), e);
}
}
示例3: init
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
this.game = game;
Font font = new Font(Font.MONOSPACED, Font.PLAIN, 60);
ufont = new UnicodeFont(font);
ufont.addAsciiGlyphs();
ufont.addGlyphs(32, 127);
ufont.getEffects().add(new ColorEffect(Color.WHITE));
ufont.loadGlyphs();
}
示例4: init
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
static public void init(){
font = new UnicodeFont(new Font("Times New Roman", Font.BOLD, 14));
font.addAsciiGlyphs();
font.addGlyphs(400, 600);
font.getEffects().add(new ColorEffect(java.awt.Color.WHITE)); // FIXME ?
try {
font.loadGlyphs();
} catch (SlickException e) {
e.printStackTrace();
}
}