I am currently using Scene 2d to create some user interface for this libgdx app I am making. I found Vis UI and realized that it would work out pretty well. Everything is fine except for the font.
Since, Vis UI is made on Scene 2d, I attempted to use the mothods descriped here, to change the font.
I tried the simple answer (which was also marked correct)
Skin skin = VisUI.getSkin();
VisUI.dispose(false);
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("customText.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 14;
skin.add("default-font", generator.generateFont(parameter), BitmapFont.class);
skin.add("small-font", generator.generateFont(parameter), BitmapFont.class);
VisUI.load(skin);
Then I tried the more complex answer
VisUI.dispose(true);
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("customText.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 14;
ObjectMap<String, Object> fontMap = new ObjectMap<String, Object>();
fontMap.put("default-font", generator.generateFont(parameter));
fontMap.put("small-font", generator.generateFont(parameter));
SkinLoader.SkinParameter par = new SkinLoader.SkinParameter(fontMap);
assets.load(VisUI.SkinScale.X1.getSkinFile().path(), Skin.class, par);
assets.finishLoading();
Skin skin = assets.get(VisUI.SkinScale.X1.getSkinFile().path());
VisUI.load(skin);
None of the two methods actually made a difference with the ScrollableTextArea
The previous code was placed in the constructor while I made sure that I created my VisWindow
after changes to VisUI since I place the window creation in the show()
method in libgdx's Screen interface.
Inside the VisWindow
it is basially the following items and thats it.
textArea = new ScrollableTextArea("...");
VisTable table = new VisTable();
VisScrollPane scrollPane = new VisScrollPane(table);
scrollPane.setFlickScroll(false);
scrollPane.setFadeScrollBars(false);
add(textArea.createCompatibleScrollPane()).growX().growY().row();
I don't get what I did wrong. Am I not supposed to use Scene2d to change the font? Or did I forget something somewhere.
Any suggestion is welcome. Thanks in advance.