[ad_1]
I create my font utilizing the next code:
public BitmapFont createFont(FreeTypeFontGenerator ftfg, float dp)
{
FreeTypeFontParameter f = new FreeTypeFontParameter();
f.dimension = (int)(dp * Gdx.graphics.getDensity());
f.colour = Color.BLACK;
f.minFilter = Texture.TextureFilter.Nearest;
f.magFilter = Texture.TextureFilter.MipMapLinearNearest;
ftfg.scaleForPixelHeight((int)(dp * Gdx.graphics.getDensity()));
return ftfg.generateFont(f);
}
myFont = createFont(new FreeTypeFontGenerator(Gdx.recordsdata.inner("Fonts/Roboto-Black.ttf")), 16);
I’ve some labels to which I set the font utilizing:
Label myLabel= new Label("Text", uiSkin);
myLabel.setWrap(true);
myLabel.getStyle().font = myFont;
How I create the stage:
Stage assortmentStage = new Stage(new StretchViewport(Gdx.graphics.getWidth(), Gdx.graphics.getWidth()));
I additionally tried with no viewport or with different viewports.
In my resize methodology:
public void resize(int width, int top) {
Viewport viewport = assortmentStage.getViewport();
viewport.replace(width, top, false);
viewport.apply();
}
The downside is that once I resize the window on Desktop the font will get distorted. Do I’ve to create one other font within the resize methodology, after which for every label that I’ve, reassign the brand new font? Or ought to I do one thing else?
[ad_2]