Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Alan Gray on May 28, 2012, 09:40:19 PM
-
I am having great success at creating UI textures with a triple-atlas scheme for our multi-res iPhone/iPad game. Now I am working on adding multi-resolution fonts to the atlases - and something doesn't make sense. I have three font files created for the three resolutions (Glyph Designer I think) that match the three atlases. Each one of those fonts has a font texture and a font definition (txt) file. With atlas swapping (atlas.replacement =), how does it know the sizes, offsets, etc. of the alternate resolutions? I tried to create the font in each atlas using the same font name. But it just created a single font and overwrote with the last font I created. I'm obviously missing something. What is the correct way to create multi-atlas fonts?
-
When swapping, you need to swap the atlas first, then swap the font.
When creating fonts, you will want to place them in different folders so they don't overwrite each other.
-
Yay - that makes sense. Thanks! Does the font texture name need to be the same in all atlases?
-
I don't think it needs to be the same, since you'll be swapping the font anyway, and the new font can reference a different sprite.
-
I tried it with different names for the font textures and it it works like a charm. The only funky thing I'm seeing is not an NGUI issue - but with the font creation tool. Even though the fonts sizes are exactly half the size of the higher res version, the spacing doesn't come out exactly the same when displaying strings at different resolutions. Looking through the font definition file, the values for character width and height are not always half of the higher res font. It's more than just rounding to the nearest pixel. For example, the 64-point "j" has a width of 25. The 32-point "j" has a width of 15.
Anyway, thanks for the help. Got me past the hurdle.
-
Antialias has a bigger effect on low res fonts, so you can't always count on it to be exactly half the size. You also can't count on the localscale to be the same as font size, because it depends on the font and also antialiasing from your bitmapper program.