CEGUI 0.6.2b Quick Font Scaling Question

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

ReGeX
Just popping in
Just popping in
Posts: 9
Joined: Sat May 02, 2009 02:54

CEGUI 0.6.2b Quick Font Scaling Question

Postby ReGeX » Fri Nov 27, 2009 16:38

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

User avatar
Jabberwocky
Quite a regular
Quite a regular
Posts: 86
Joined: Wed Oct 31, 2007 18:16
Location: Canada
Contact:

Re: CEGUI 0.6.2b Quick Font Scaling Question

Postby Jabberwocky » Fri Nov 27, 2009 16:49

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.
The Salvation Prophecy
Space Combat. Planet Exploration. Strategic Domination.

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

Re: CEGUI 0.6.2b Quick Font Scaling Question

Postby Jamarr » Fri Nov 27, 2009 17:29

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");
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!

ReGeX
Just popping in
Just popping in
Posts: 9
Joined: Sat May 02, 2009 02:54

Re: CEGUI 0.6.2b Quick Font Scaling Question

Postby ReGeX » Fri Nov 27, 2009 18:02

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

User avatar
Jabberwocky
Quite a regular
Quite a regular
Posts: 86
Joined: Wed Oct 31, 2007 18:16
Location: Canada
Contact:

Re: CEGUI 0.6.2b Quick Font Scaling Question

Postby Jabberwocky » Fri Nov 27, 2009 18:20

Thanks Jamarr,
Good to know there's a better alternative than my crappy hack. :)
The Salvation Prophecy

Space Combat. Planet Exploration. Strategic Domination.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 17 guests