Bitmap font alignment not working?

Regardless of how I set the text alignment, my bitmap fonts always align to the left. What am I doing wrong? Thanks

EDIT: Just realised this affects the alignment of the text within the paragraph, not the boundary box. So, I guess we need a way of getting the width the text and it can be positioned in the centre of the camera view width.

image

The alignment is weird, it only centers the text when multiple lines are displayed. And even then it is based on the paragraph width rather than the object width as you noticed. I’ve worked around this by either putting in a decorative line break of some sort (like a bunch of hyphens) that is as wide as the screen, or by adjusting the object placement after the fact

1 Like

You don’t quite understand how it works
BUT to be fair text objects are kinda different dimension

1st to change alignment properly you need to center text as object properly

For example you want to align it to right side of screen

You DO NOT change bitmap text X position to CameraBorderRight()-20

You change bitmap object X position to CameraBorderRight()-BitmapText.Width()-20

If you want to center it on center of screen
CameraCenterX()-BitmapText.Width()/2

Now armed with that knowledge go test how alignment really work with bitmap text

Where keep in mind there is also action to change center position of object aside from just changing position

1 Like

Thanks ZeroX4, I’ll test this tomorrow. Is the bitmap text width related to the boundary box or the actual text? e.g. if the text changes, does the width change accordingly?

Depends what you mean

Look your text from png atlas most likely have empty spaces

If you ask does AAA will take same space as WWW
That will depend on if your characters are mono space
Meaning if your characters no matter is it 1 or 8 or a or Z or L or i
They all take same space
Then 3 of any characters will have same width as any other 3 characters

If you ask does FOR EXAMPLE your 3 characters together makes your bitmap object width = idk let’s say 12 pixels
Then adding ANY new character will for sure increase width of your text object
Then yes you are right to assume so

BUT from what you read above
If you don’t have mono space font
Then it does not mean like
You change your text to
ASD and now width = 12 pixels
You change it to ASDasd now width IF its mono space will for sure = 24 pixels
Since 1 character would be 4 pixels so adding any new character would result in increasing width by 4 pixels

YET if they are not mono space like this very font we have on this forum

Look

1 2 3 4
! ! ! !
Well you see 4 characters in each row and 3 spaces
YET they do not occupy same space

So width of 1st row with numbers will be bigger than width of 2nd row with !

1 Like

Thanks for the detailed reply, but your first suggested was spot on. :innocent:

I simply needed to add the following action to centre the bitmap font.

Change the X position of txtBold: set to (CameraWidth()/2)-(txtBold.Width()/2)

1 Like