1
\$\begingroup\$

I imported a font with Hiero and I draw the font like:

font.draw(batch, "1", 0, 48);

This is the resultant image:

enter image description here

So the font it moved up to hit the bottom perfectly, but it doesn't touch the left side perfectly. Why does this happen? Is there a way I can fix this? It seems like if I set the x coordinate to -3 it works, but this seems somewhat arbitrary. Any ideas?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

That spacing is called font kerning. And that is exactly why there is padding in front. The purpose of kerning is so that letters fit nicely next to each other, and that they aren't too close or too far away from each other.

\$\endgroup\$
0
\$\begingroup\$

I think you want full control of the text box, right?

Here is some code for you, soured from another Q&A thread:

GlyphLayout layout = new GlyphLayout(); //dont do this every frame! Store it as member
layout.setText("meow");
float width = layout.width;// contains the width of the current set text
float height = layout.height; // contains the height of the current set text
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .