Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the same font with different sizes in libgdx

Tags:

java

fonts

libgdx

I am using BitmapFonts, LabelStyles and Labels for my texts.

I want to resize some labels, so I use this:

fontType.scale(-.6f);

LabelStyle style = new LabelStyle(fontType, Color.WHITE);

titleLabel = new Label("Points", style);
titleLabel.setColor(Color.RED);
titleLabel.x = 260; 
titleLabel.y = 310;

But when I want to resize another label, all the labels containing that font resize (I create a new LabelStyle). So I resize the label instead of the font, but that doesnt solve the problem, because it doesnt resize the label, any idea?

like image 776
Rudy_TM Avatar asked Mar 12 '12 18:03

Rudy_TM


1 Answers

You will have to create separate BitmapFonts and LabelStyle for each Label(or groups of Labels) if you want to scale them independently.

From checking libgdx source code, Label uses the reference to BitmapFont from LabelStyle and passes it to a BitmapFontCache used internally; no deep copy is made at any point so they are all using the same BitmapFont you created the LabelStyle with.

like image 190
XiaoChuan Yu Avatar answered Oct 18 '22 13:10

XiaoChuan Yu