本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator類的典型用法代碼示例。如果您正苦於以下問題:Java FreeTypeFontGenerator類的具體用法?Java FreeTypeFontGenerator怎麽用?Java FreeTypeFontGenerator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FreeTypeFontGenerator類屬於com.badlogic.gdx.graphics.g2d.freetype包,在下文中一共展示了FreeTypeFontGenerator類的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: loadAssets
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private void loadAssets() {
InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
assetManager = new AssetManager(fileHandler);
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));
assetManager.load(SKIN_PATH, Skin.class);
assetManager.load(MASTER_PATH, TextureAtlas.class);
assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
assetManager.load(MUSIC_PATH, Music.class);
assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
assetManager.load(GOOD_PATH, Sound.class);
assetManager.load(HALF_PATH, Sound.class);
assetManager.load(BAD_PATH, Sound.class);
assetManager.finishLoading();
}
示例4: 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);
}
示例5: 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;
}
示例6: 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();
}
示例7: create
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
public void create() {
batch = new SpriteBatch();
font = new BitmapFont();
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("gfx/fonts/roboto-regular.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 16;
font = generator.generateFont(parameter); // font size 16 pixels
generator.dispose();
music = Gdx.audio.newMusic(Gdx.files.internal("sounds/main.ogg"));
music.setLooping(true);
music.play();
this.setScreen(new MenuScreen(this));
}
示例8: HUD
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private HUD() {
stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
stage.addListener(inputListener = new InputListener(true));
Gdx.input.setInputProcessor(stage);
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
skin = new Skin(Gdx.files.internal("uiskin.json"));
createFlashImage();
createProgressLabel();
createInfoLabel();
createLevelCompleteUI();
hideLevelComplete();
if (Globals.isMobile()) {
createMobileButtons();
}
}
示例9: createReplayButton
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private void createReplayButton() {
FreeTypeFontGenerator.FreeTypeFontParameter fontParam = new FreeTypeFontGenerator.FreeTypeFontParameter();
fontParam.size = Gdx.graphics.getWidth() / 8;
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
style.font = fontGenerator.generateFont(fontParam);
style.fontColor = Color.WHITE;
final TextButton playButton = new TextButton("REPLAY?", skin);
playButton.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
playButton.setPosition(0, 0);
playButton.setStyle(style);
playButton.addListener(new ClickListener() {
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
game.setScreen(new Driver(game));
}
});
stage.addActor(playButton);
}
示例10: Font
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
public Font(String filePath, int size, Color color, boolean filter)
{
// ASSIGN ATTRIBUTES
this.size = size;
this.color = color;
// GENERATE FONT
generator = new FreeTypeFontGenerator(Gdx.files.internal(filePath));
if (filter) // IF FILTER ENABLED
{
parameter.genMipMaps = true;
parameter.minFilter = Texture.TextureFilter.Linear;
parameter.magFilter = Texture.TextureFilter.Linear;
}
parameter.size = size;
parameter.color = color;
font = generator.generateFont(parameter);
generator.dispose();
}
示例11: 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;
}
示例12: Font
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
public Font(final Application APP, String fileName, String filePath, int size, boolean filter)
{
// ASSIGN ATTRIBUTES
this.size = size;
FreetypeFontLoader.FreeTypeFontLoaderParameter parameter = new FreetypeFontLoader.FreeTypeFontLoaderParameter();
FileHandleResolver resolver = new InternalFileHandleResolver();
APP.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
APP.assets.setLoader(BitmapFont.class, ".otf", new FreetypeFontLoader(resolver));
// GENERATE FONT
if (filter) // IF FILTER ENABLED
{
parameter.fontParameters.genMipMaps = true;
parameter.fontParameters.minFilter = Texture.TextureFilter.Linear;
parameter.fontParameters.magFilter = Texture.TextureFilter.Linear;
}
parameter.fontFileName = filePath;
parameter.fontParameters.size = size;
APP.assets.load(fileName, BitmapFont.class, parameter);
APP.assets.finishLoading();
font = APP.assets.get(fileName, BitmapFont.class);
}
示例13: MenuScreen
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
public MenuScreen(TTmath game, OrthoCamera camera, SpriteBatch sb){
this.camera = camera;
this.game = game;
this.sb = sb;
game.resetScore();
game.manageScreens(this);
// game.mainMenuScreen = this;
createStage();
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
font = createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createButton();
}
示例14: createDisplay
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
private void createDisplay() {
if(created){
return;
}
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createQuestions();
createStage();
createLabel();
createButton();
createScoreLabel();
createIncorrectLabel();
created = true;
game.problemScreen = this;
}
示例15: GameOverScreen
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; //導入依賴的package包/類
public GameOverScreen(TTmath game, OrthoCamera camera, SpriteBatch sb) {
this.game = game;
this.camera = camera;
this.sb = sb;
// game.gameOver = this;
game.setScreen(this);
Gdx.input.setCatchBackKey(true);
FreeTypeFontGenerator TEXT_8BIT = new FreeTypeFontGenerator(Gdx.files.internal("resources/Minecraftia-Regular.ttf"));
createFont(TEXT_8BIT, 25);
TEXT_8BIT.dispose();
createStage();
createLabel();
createButton();
}