Reusing a loaded font

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

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Reusing a loaded font

Postby spannerman » Thu Jul 06, 2006 00:40

I think its something quite simple, but I cant see it.

Say I have a true type font called myCoolFont.ttf. This font is described, along with its size, in a font xml file. So I'd load the font like this:

Code: Select all

CEGUI::FontManager::getSingleton().createFont("myCoolFont.font");


I have two StaticText boxes. Both use myCoolFont.ttf.
I want one staticText to have a font size of 10, and the other a size of 15.

How do I do that without loading the same font twice?

I know you can dynamically change the size of a font like so:

Code: Select all

Font *f = CEGUI::FontManager::getSingleton().getFont("FontName");
f->setProperty ("PointSize", 12);


But that will change that font instance, and everywhere it is used. Is it possible to clone a font?

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Thu Jul 06, 2006 03:18

Words are not coming easily tonight so hopefully the following can be understood in english; I doubt my french explanation would be well received...

What you are asking for does not seem possible.

The font class converts a font into a texture via FreeTypeFont::rasterize(). Each "character" from the font is converted into an image representation of a certain size.

A glyph can only be present once within that texture. When drawing text with Font::drawTextLine() there is a glyph = getGlyphData(text[c]); to retrieve the glyph for a character. That code would need some serious rewrite to support something like glyph = getGlyphData(text[c], pointSize);

This also prevents a glyph to be present in multiple formats: normal, bold, italic. These would require multiple .ttf files.

When simply changing the font size a function to copy the texture from an existing font to a new one would be useful to avoid reloading from disk.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Reusing a loaded font

Postby Ident » Mon Jun 29, 2015 16:53

Dynamic font size changing should be solved in 0.8 as far as I see it : https://bitbucket.org/cegui/cegui/issue ... ing-a-font
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 22 guests