本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.generateFont方法的典型用法代碼示例。如果您正苦於以下問題:Java FreeTypeFontGenerator.generateFont方法的具體用法?Java FreeTypeFontGenerator.generateFont怎麽用?Java FreeTypeFontGenerator.generateFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator
的用法示例。
在下文中一共展示了FreeTypeFontGenerator.generateFont方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ChatMessage
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public ChatMessage(String sender, String message) {
super(skin);
// debugAll();
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/DroidSans.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 17;
parameter.minFilter = Texture.TextureFilter.Linear;
parameter.magFilter = Texture.TextureFilter.Linear;
final Label.LabelStyle labelStyle = skin.get("chat-sender", Label.LabelStyle.class);
labelStyle.font = generator.generateFont(parameter);
this.sender = new Label(sender, labelStyle);
this.message = new Label(message, skin.get("chat-message", Label.LabelStyle.class));
this.message.setWrap(true);
add(this.sender).fillX().expandX();
row();
add(this.message).fillX().expandX();
generator.dispose(); // don't forget to dispose to avoid memory leaks!
}
示例2: createFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public static BitmapFont createFont(String fontPath, int size, Color color, Color borderColor, int borderWidth) {
// load font
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.absolute(fontPath));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
// https://github.com/libgdx/libgdx/wiki/Gdx-freetype
parameter.size = size;
parameter.borderColor = borderColor;
parameter.borderWidth = borderWidth;
parameter.color = color;
BitmapFont font48 = generator.generateFont(parameter);
generator.dispose();
return font48;
}
示例3: initUtils
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private void initUtils() {
//init camera & viewport
camera = new OrthographicCamera();
viewport = new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT, camera);
viewport.apply(true);
camera.update();
//init sprite batch
batch = new SpriteBatch();
batch.setProjectionMatrix(camera.combined);
//init font
FreeTypeFontGenerator fontGenerator = polymorph.getAssetManager().get(Polymorph.FONT_BOLD_PATH, FreeTypeFontGenerator.class);
FreeTypeFontParameter fontSettings = new FreeTypeFontParameter();
fontSettings.size = 80;
fontSettings.minFilter = TextureFilter.Linear;
fontSettings.magFilter = TextureFilter.Linear;
font = fontGenerator.generateFont(fontSettings);
}
示例4: createFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private static BitmapFont createFont(int fontSize , Fonts type) {
FileHandle fontFile = null;
switch(type){
case HEMI_HEAD: fontFile = Gdx.files.internal("fonts/HEMIHEAD.TTF"); break;
case VERA: fontFile = Gdx.files.internal("fonts/Vera.ttf"); break;
case VERA_BD: fontFile = Gdx.files.internal("fonts/VeraBd.ttf"); break;
default:
break;
}
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = fontSize;
BitmapFont font = generator.generateFont(parameter);
generator.dispose();
return font;
}
示例5: initFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
/**
* 初始遊戲字體
*/
private void initFont() {
FreetypeFontLoader.FreeTypeFontLoaderParameter fontConfig = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
fontConfig.fontFileName = "font.ttf";
fontConfig.fontParameters.size = 22;
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameters = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameters.size = 18;
f18 = generator.generateFont(parameters);
parameters.size = 22;
f22 = generator.generateFont(parameters);
parameters.size = 24;
f24 = generator.generateFont(parameters);
generator.dispose();
}
示例6: getFontIcon
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private Drawable getFontIcon(FileChooser.FileItem item) {
FileHandle fileHandle = item.getFile();
BitmapFont bitmapFont;
try {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = CB.getScaledInt(50);
parameter.characters = SkinFont.DEFAULT_CHARACTER;
parameter.genMipMaps = true;
parameter.minFilter = Texture.TextureFilter.MipMapNearestNearest;
bitmapFont = generator.generateFont(parameter);
} catch (Exception e) {
return getImageIcon(item);
}
Drawable drawable = new BitmapFontDrawable(bitmapFont, item.getFile().nameWithoutExtension());
return drawable;
}
示例7: initFonts
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
private void initFonts() {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/roboto.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter params = new FreeTypeFontGenerator.FreeTypeFontParameter();
params.size = 48;
params.color = new Color(.25f, .25f, .85f, 1);
params.shadowOffsetX = 0;
params.shadowOffsetY = 0;
params.shadowColor = Color.BLACK;
titleFont = generator.generateFont(params);
params = new FreeTypeFontGenerator.FreeTypeFontParameter();
params.size = 32;
params.color = Color.BLACK;
buttonFont = generator.generateFont(params);
generator.dispose();
}
示例8: GridMapRenderer
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public GridMapRenderer() {
// load font from a .ttf file
try {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/font/jgfont.ttf"));
FreeTypeFontParameter fp = new FreeTypeFontParameter();
fp.size = 9;
font9 = generator.generateFont(fp);
generator.dispose();
shapeRenderer = RTSGame.game.cameraShapeRenderer;
fontBatch = new SpriteBatch();
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: QuadTreeRenderer
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public QuadTreeRenderer() {
// load font from a .ttf file
try {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/font/jgfont.ttf"));
FreeTypeFontParameter fp = new FreeTypeFontParameter();
fp.size = 9;
font9 = generator.generateFont(fp);
generator.dispose();
shapeRenderer = RTSGame.game.cameraShapeRenderer;
fontBatch = new SpriteBatch();
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: create
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
@Override
public void create () {
boolean flip = false;
batch = new SpriteBatch();
if (flip) {
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(flip);
cam.update();
batch.setProjectionMatrix(cam.combined);
}
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), flip);
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
parameter.flip = flip;
parameter.genMipMaps = true;
FreeTypeBitmapFontData fontData = generator.generateData(parameter);
ftFont = generator.generateFont(parameter);
generator.dispose();
}
示例11: render
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public void render () {
if (Gdx.input.justTouched()) {
for (int i = 0; i < 10; i++) {
if (font != null) {
font.dispose();
}
FileHandle fontFile = Gdx.files.internal("data/arial.ttf");
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
font = generator.generateFont(parameter);
generator.dispose();
}
for (int i = 0; i < 10; i++)
System.gc();
Gdx.app.log("FreeTypeDisposeTest", "generated 10 fonts");
Gdx.app.log("FreeTypeDisposeTest", Gdx.app.getJavaHeap() + ", " + Gdx.app.getNativeHeap());
}
}
示例12: loadFonts
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
public static void loadFonts(){
FreeTypeFontGenerator font_gen = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 100;
font100 = font_gen.generateFont(parameter);
font100.getRegion().getTexture().setFilter(TextureFilter.Linear,TextureFilter.Linear);
font100.setColor(Color.BLACK);
font100.setScale(1, -1);
parameter.size = 75;
font75 = font_gen.generateFont(parameter);
font75.getRegion().getTexture().setFilter(TextureFilter.Linear,TextureFilter.Linear);
font75.setColor(Color.BLACK);
font75.setScale(1, -1);
parameter.size = 250;
font250 = font_gen.generateFont(parameter);
font250.getRegion().getTexture().setFilter(TextureFilter.Linear,TextureFilter.Linear);
font250.setColor(Color.BLACK);
font250.setScale(1, -1);
font_gen.dispose();
}
示例13: getHeadlineFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
/**
* Liefert BitmapFont, die gut geeignet sind fuer Ueberschriften.
*
* @param size
* vom Typ FontSize umd die Groesse der Schriftart zu definieren
* @return b BitmapFont
*/
@SuppressWarnings("deprecation")
public static BitmapFont getHeadlineFont(final FontSize size) {
if (headlineFonts == null){
headlineFonts = new BitmapFont[FontSize.values().length];
}
if (headlineFonts[size.ordinal()] == null) {
int startIdx = directoryFonts.indexOf(FOLDERNAME_FONTS);
String relativeFilePath = directoryFonts.substring(startIdx, directoryFonts.length()).replace("\\", "/") + FILESEPARATOR + "headlinefont/GetVoIP Grotesque.ttf";
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(relativeFilePath));
headlineFonts[size.ordinal()] = generator.generateFont(size.getVal());
}
headlineFonts[size.ordinal()].setScale(1f);
return headlineFonts[size.ordinal()];
}
示例14: getFont
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
/**
* Gets a font from the cache if it exists otherwise creates it based on the following arguments
* @param fontID id of the font, must be in the format: {ttf-file-name}-{size}
* @param defaultPath path to the ttf file used to create the font if it doesn't exist
* @return the BitmapFont or null if it doesn't exist and no path is provided
*/
public static BitmapFont getFont(String fontID, String defaultPath) {
if (fonts.containsKey(fontID)) {
return fonts.get(fontID);
}
else if (defaultPath != null) {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(defaultPath));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = Integer.parseInt(fontID.split("-")[1]);
BitmapFont font = generator.generateFont(parameter);
generator.dispose();
fonts.put(fontID, font);
return font;
}
return null;
}
示例15: show
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入方法依賴的package包/類
@Override
public void show() {
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.setToOrtho(false);
camera.position.x = Gdx.graphics.getWidth() / 2;
camera.position.y = Gdx.graphics.getHeight() / 2;
//Get the font.
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("mainmenu/new/kenvector_future.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 15;
font = generator.generateFont(parameter);
generator.dispose();
System.gc(); //We no longer need the Main Menu stuff, we should clean it up.
}