Page 1 of 1

CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 01:54
by Gykonik
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...

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 07:38
by YaronCT
Gykonik: what's m_gui? What's its type?

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

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 10:18
by Gykonik

Code: Select all

Bengine::GUI m_gui


I use the newest Version (1.0.8 I guess)

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 10:44
by YaronCT
Gykonik: This is a cegui forum, I don't know what "Bengine::GUI" is. U might wanna ask in a Bengine forum.

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 19:59
by Gykonik
Oh sry, Bengine is just my game-engine name, where I declared it...

It has nothing to do with a Bengine forum

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 20:35
by YaronCT
and "Bengine::GUI" is?.. I don't have supernatural powers.

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 20:55
by Gykonik
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);
}

Re: CEGUI Change Font size later in the program

Posted: Sat Apr 02, 2016 22:29
by Ident
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.