Page 1 of 1

CEGUI 0.6.2b Quick Font Scaling Question

Posted: Fri Nov 27, 2009 16:38
by ReGeX
Hello,

I just started implementing a custom Font wrapper class to my software, but I am having difficulty implementing font scaling (a feature which seems extremely easy to implement in 0.7.x). I have used the PointSize property to set the font's pixel size to 7 so that it will display properly on a 640x480 resolution and could be scaled on larger resolutions. My goal is to be able to have the font display within the same proportions, for example, on a 1024x768 resolution like the rest of the window (proportions being the same relative size to the window). I have set the native resolution after constructing the font object with the method provided, and then attempted to scale it by using the notifyScreenResolution method. Currently, the font gets smaller (logically, of course) on the larger resolutions. As I am quite new to CEGUI, I feel that this is a simple and quick issue. Any feedback would be greatly appreciated.

Best regards,
ReGeX

Re: CEGUI 0.6.2b Quick Font Scaling Question

Posted: Fri Nov 27, 2009 16:49
by Jabberwocky
Hopefully someone will correct me if I'm wrong. I think the only way you can achieve font scaling is to "fake it", and actually define several different .font files, each with a different "Size".

So for example, you might have 3 font files:
tahoma-8.font
tahoma-10.font
tahoma-12.font

In the first would be: Size="8"
In the 2nd would be: Size="10"
In the 3rd would be: Size="12"

Then, you'd have to manually switch between these fonts to make your text smaller or larger.

Re: CEGUI 0.6.2b Quick Font Scaling Question

Posted: Fri Nov 27, 2009 17:29
by Jamarr
I think you just need to set the Font Property AutoScaled to True either...

in the .font file:

Code: Select all

<Font Name="default" Filename="default.ttf" Type="FreeType" Size="14" NativeHorzRes="1024" NativeVertRes="768" AutoScaled="True"/>


or in code:

Code: Select all

font->setProperty("AutoScaled", "True");

Re: CEGUI 0.6.2b Quick Font Scaling Question

Posted: Fri Nov 27, 2009 18:02
by ReGeX
Absolutely perfect!

The combination of the setNativeResolution method and the AutoScaled property worked like a charm. Thank you for the suggestion, Jamarr.

Jabberwocky, I was planning to use that method at a last resort, but thank you for your reply. :)

Regards,
ReGeX

Re: CEGUI 0.6.2b Quick Font Scaling Question

Posted: Fri Nov 27, 2009 18:20
by Jabberwocky
Thanks Jamarr,
Good to know there's a better alternative than my crappy hack. :)