Text Object and Bitmap fonts?


(George Kurelic) #1

I’m really surprised This isn’t requested more. I’m planning my UI and there’s a large dynamic text box that will be populated with high scores. I would like to be able put a text box in tiled, pointing at a tileset of letters to be used for a bitmap font. then I can put placeholder text to see if I like the alignment.

What I’m doing now is putting a rectangle object with image, tiling and alignment instructions in the custom properties. then I run the game, see if it lines up right, nudge it in Tiled, and repeat. I’m glad this is the only dynamic text I’m dealing with, otherwise this would be a huge pain


Development Updates
(Thorbjørn Lindeijer) #2

I definitely agree there should be a text object. There’s several people who have requested this already actually, but I just haven’t gotten around to it:

https://github.com/bjorn/tiled/issues/1429

niedzielski even posted a bounty on the issue, so if nobody else does it I will make sure to get to it soon, and I’ve added it to the Tiled 1.0 milestone.

Supporting bitmap fonts based on tilesets is an interesting idea, though I’m not sure if it’s the easiest approach. Usually the letters are not all the same size, so either tilesets will need to support this (it should be supported eventually anyway) or each letter would need to be its own image. There’s also the fact that you’d need to assign a property to each tile telling Tiled what character is represents. I think there are probably already common ways of dealing with bitmap fonts, and then it would make sense to support that more directly in Tiled. What format is your font in?

In any case bitmap font support is definitely a larger issue than supporting a text object based on system fonts.


(George Kurelic) #3

I can start looking into it, starting with a normal system font.

In terms of exporting a field using bitmap font, I expect it being not that different from the properties of a normal textfield object, except it would point to a bitmap font definition, which is similar to a tileset but with optional kerning properties per character. Most bitmap fonts in editors/engines assume monospace, so kerning could come later.

For instance a bitmap font def would have a source image, tile width/height, margin, spacing, and a list of characters in the image from topleft to bottom right

name: "numbers_small"
image:
tileWidth: 8
tileHeight: 10
characters: “0123456789”

and the textfield object might just list numbers_small in the font drop down, or there’s a radio button to select bitmap font over system font which affects the dropdown contents


(Thorbjørn Lindeijer) #4

@Geokureli Did you notice I’ve implemented the first version of the new Text object this week? You can check it out using a development snapshot build.

Currently it only supports rendering using system fonts, so I could rely on the Qt font rendering support, including text wrapping and alignment. Of course it would still be nice to extend this to also support bitmap fonts eventually, as well as to allow referring to some TTF file directly.


(George Kurelic) #5

Thanks for the heads up, I’ll be sure to check it out!