Fast method to scale text

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

ShadowTiger
Quite a regular
Quite a regular
Posts: 46
Joined: Fri Mar 19, 2010 05:31

Fast method to scale text

Postby ShadowTiger » Sat Aug 20, 2011 01:27

I basically am trying to make a picture-in-picture type of mode for my game.

I have a window thats usually 100% of the parent's size and i shrink it down to 75%.

This automatically scales down the images but it does not scale down the fonts. It looks like the fonts only scale when the resolution of the application changes, which is the expected behavior.

To compensate, when i shrink the window to 75% I also set the native resolution of every font in the game to 33% higher than normal. This causes the text to be the right size.

CEGUI::Font::setNativeResolution(Size(x,y));

This workaround works fine, but its somewhat slow. It takes about 1 second to change ~50 fonts, freezing my application in the meantime.

I could interpolate the change to avoid the freeze but then there would be a "pop in" effect as some fonts would be the wrong size until everything finishes loading.

Is this the only way to get this behavior or is there another work around (besides manually reassigning the fonts which would probably be a nightmare)?

Using CEGUI 7.5

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Fast method to scale text

Postby Jamarr » Mon Aug 22, 2011 18:57

ShadowTiger wrote:It takes about 1 second to change ~50 fonts, freezing my application in the meantime.


I am not familiar enough with the Font system, or the underlying FreeType2 library, to provide an in-depth answer here. I assume that CEGUI (or freetype) catches the character-glyphs as bitmaps/textures in order to decrease rendering times for subsequent frames; I also assume glyphs have to be rasterized regardless, making this caching of rasterized-glyphs a performance-related requirement. And from this, I again assume that having to re-rasterize all of the cached glyphs in a font takes some time and you are multiplying that timeframe by 50. I doubt you can really do much about it as is. Perhaps CE or Kulik could clarify this.

Do you really need 50 fonts loaded into memory simultaneously?

Assuming that all cached-glyphs are re-rasterized when the resolution changes, I wonder if unloading / reloading the fonts would help avoid re-rasterizing glyphs that are no longer in use, but still cached?
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests