CEGUI Change Font size later in the program

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

Gykonik
Just popping in
Just popping in
Posts: 15
Joined: Thu Mar 31, 2016 18:33

CEGUI Change Font size later in the program

Postby Gykonik » Sat Apr 02, 2016 01:54

Hello,

I have the following question:
Can I set the Font-Size of CEGUI later in the program again, without initialize the whole CEGUI again?

I thought with

Code: Select all

m_gui.setFont("FONT")


but it seems, that this can only be set on the beginning and only one time...

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: CEGUI Change Font size later in the program

Postby YaronCT » Sat Apr 02, 2016 07:38

Gykonik: what's m_gui? What's its type?

Also, plz always specify which cegui version u work with.

Gykonik
Just popping in
Just popping in
Posts: 15
Joined: Thu Mar 31, 2016 18:33

Re: CEGUI Change Font size later in the program

Postby Gykonik » Sat Apr 02, 2016 10:18

Code: Select all

Bengine::GUI m_gui


I use the newest Version (1.0.8 I guess)

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: CEGUI Change Font size later in the program

Postby YaronCT » Sat Apr 02, 2016 10:44

Gykonik: This is a cegui forum, I don't know what "Bengine::GUI" is. U might wanna ask in a Bengine forum.

Gykonik
Just popping in
Just popping in
Posts: 15
Joined: Thu Mar 31, 2016 18:33

Re: CEGUI Change Font size later in the program

Postby Gykonik » Sat Apr 02, 2016 19:59

Oh sry, Bengine is just my game-engine name, where I declared it...

It has nothing to do with a Bengine forum

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: CEGUI Change Font size later in the program

Postby YaronCT » Sat Apr 02, 2016 20:35

and "Bengine::GUI" is?.. I don't have supernatural powers.

Gykonik
Just popping in
Just popping in
Posts: 15
Joined: Thu Mar 31, 2016 18:33

Re: CEGUI Change Font size later in the program

Postby Gykonik » Sat Apr 02, 2016 20:55

sry...

I think this are the relevant things:

Code: Select all

m_context = &CEGUI::System::getSingleton().createGUIContext(m_renderer->getDefaultRenderTarget());
m_root = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "root");
m_context->setRootWindow(m_root);


void GUI::setFont(const std::string& fontFile) {
   CEGUI::FontManager::getSingleton().createFromFile(fontFile + ".font");
   m_context->setDefaultFont(fontFile);
}

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

Re: CEGUI Change Font size later in the program

Postby Ident » Sat Apr 02, 2016 22:29

A Font can be set for each CEGUI::Window, you can change the Font anytime later to any other Font that you have created beforehand.

Every font is rendered using a texture atlas, which is created for each Font and Font size, so you probably do not want to have too many different Fonts (and font sizes) in your game (which is also wise from a graphic design standpoint) if you care about performance.

If you do not set a Font for a Window, then default Font is taken from it. The default Font is specified in the GUIContext as you have shown. If you change the default Font there then all windows without specific Font defined for them should be updating their Fonts. If they do not do that then this is a bug we must fix! Are you saying changing the GUIContext's font does not change any Fonts of your windows? If you want to check if this is a bug, namely a lack of update, then try to directly invalidate the Window after changing the Context's Font using Window::invalidate() and see if that makes the Font appear as expected thereafter. If that makes any difference then someone forgot to trigger updates here and we must fix it.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 11 guests