gdx-smart-font icon indicating copy to clipboard operation
gdx-smart-font copied to clipboard

Scaling issue with FitViewport

Open bmbariah opened this issue 8 years ago • 0 comments

I have implemented your lib with my libgdx game but the font scales out of proportion when I use a FitViewport with my own world co-ordinates as shown in the 2 images below.

The first image shows when I don't use my FitViewport and the second one shows when I do. Kindly assist. My entire game uses the FitViewport but text simply isn't sharp...

I simply want the text in my game to scale like the first image but when using a viewport

public class ExampleMain implements Screen {

Start app;

@Override
    public void show() {

        SmartFontGenerator fontGen = new SmartFontGenerator(app);
        FileHandle exoFile = Gdx.files.internal("fonts/OpenSans.ttf");
        BitmapFont fontSmall = fontGen.createFont(exoFile, "exo-small", 24);
        BitmapFont fontMedium = fontGen.createFont(exoFile, "exo-medium", 48);
        BitmapFont fontLarge = fontGen.createFont(exoFile, "exo-large", 64);

       //1st image
       //This one causes text to display correctly but doesn't use the FitViewport
        stage = new Stage();

       //2nd image
         //This one causes text to display incorrectly but uses the FitViewport (
        stage = new Stage(app.viewport);

}

This is how I have set up my viewports...

public class Start extends Game {
 
     public void create()
    {
        screenWidth = Gdx.graphics.getWidth();
        screenHeight = Gdx.graphics.getHeight();
        gameHeight = screenHeight / (screenWidth / gameWidth);
        midPointY = (int) (gameHeight / 2);
        camera = new OrthographicCamera();
        camera.setToOrtho(true, gameWidth, gameHeight);
        //viewport = new ExtendViewport(360, 1, camera);
        viewport = new FitViewport(gameWidth, gameHeight, camera);
        viewport.apply();

ok resize

Any ideas? Thanks.

bmbariah avatar Nov 09 '16 12:11 bmbariah