Sdl_ttf font sizes

i think i asked this a while ago with no response (if i’m wrong,
somebody point me to the responses), but here goes again:

in sdl_ttf, is there a way to change the font size used when rendering
surfaces after the lib as been initialized? my glance at the header
file didnt reveal a function to do so, but if sdl_ttf is a wrapper
around freetype, i would hope freetype would have a simple function to
change font sizes.

anybody know of a way to switch the size (point size) of a font after
sdl_ttf has been initialized? thanks.

– chris (@Christopher_Thielen)

Chris Thielen wrote:

in sdl_ttf, is there a way to change the font size used when rendering
surfaces after the lib as been initialized? my glance at the header
file didnt reveal a function to do so, but if sdl_ttf is a wrapper
around freetype, i would hope freetype would have a simple function to
change font sizes.

i don’t think, this is possible. if i had written sdl_ttf, i would
render the font to a bitmap cache, when loading the font, and do a
simple blitt of the single characters, when needed. i guess it is done
this way.

regards …
clemens

The showfont.c demo should give you all the information you require.

Dominique.

Chris Thielen wrote:> i think i asked this a while ago with no response (if i’m wrong,

somebody point me to the responses), but here goes again:

in sdl_ttf, is there a way to change the font size used when rendering
surfaces after the lib as been initialized? my glance at the header
file didnt reveal a function to do so, but if sdl_ttf is a wrapper
around freetype, i would hope freetype would have a simple function to
change font sizes.

anybody know of a way to switch the size (point size) of a font after
sdl_ttf has been initialized? thanks.

– chris (chris at luethy.net)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


http://www.DelphiGamer.com := for all your Object Pascal game
development needs;
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.

Sorry please ignore that last outburst.

Dominique.

Dominique Louis wrote:> The showfont.c demo should give you all the information you require.

Dominique.

Chris Thielen wrote:

i think i asked this a while ago with no response (if i’m wrong,
somebody point me to the responses), but here goes again:

in sdl_ttf, is there a way to change the font size used when rendering
surfaces after the lib as been initialized? my glance at the header
file didnt reveal a function to do so, but if sdl_ttf is a wrapper
around freetype, i would hope freetype would have a simple function to
change font sizes.

anybody know of a way to switch the size (point size) of a font after
sdl_ttf has been initialized? thanks.

– chris (chris at luethy.net)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


http://www.DelphiGamer.com := for all your Object Pascal game
development needs;
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.

Chris Thielen wrote:

in sdl_ttf, is there a way to change the font size used when rendering
surfaces after the lib as been initialized?

I think you’re just supposed to call TTF_OpenFont to obtain a different
font handle when you want a different font size. That’s the way all
font libraries I’ve ever used work – each unique size and style you use
is represented by a “font object” instance.–
= Video articles: http://tangentsoft.net/video/

So the only way to switch sizes is to close the font I’m working with
and open it up again at a different size?

– chris (@Christopher_Thielen)On Mon, 2002-07-29 at 15:58, Warren Young wrote:

Chris Thielen wrote:

in sdl_ttf, is there a way to change the font size used when rendering
surfaces after the lib as been initialized?

I think you’re just supposed to call TTF_OpenFont to obtain a different
font handle when you want a different font size. That’s the way all
font libraries I’ve ever used work – each unique size and style you use
is represented by a “font object” instance.

If you’re never going to use it at the old size, I guess this would be
the way.

You can always open it multiple times at different sizes, if I understand
SDL_ttf correctly. (Honestly, I’ve barely used it so far…)

-bill!On Mon, Jul 29, 2002 at 05:17:58PM -0700, Chris Thielen wrote:

So the only way to switch sizes is to close the font I’m working with
and open it up again at a different size?

Well, I’ll be switching the sizes back and forth. I’ll be needing the
old size again, so, is there a methodology in SDL_ttf to do that or …
what? Should I reinit the font?

– chris (@Christopher_Thielen)On Mon, 2002-07-29 at 17:26, nbs wrote:

On Mon, Jul 29, 2002 at 05:17:58PM -0700, Chris Thielen wrote:

So the only way to switch sizes is to close the font I’m working with
and open it up again at a different size?

If you’re never going to use it at the old size, I guess this would be
the way.

You can always open it multiple times at different sizes, if I understand
SDL_ttf correctly. (Honestly, I’ve barely used it so far…)

Well, I’ll be switching the sizes back and forth. I’ll be needing the
old size again, so, is there a methodology in SDL_ttf to do that or …
what? Should I reinit the font?

Just open the font twice, once with each point size.
You’ll get two different font handles, with the same font at different sizes.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Chris Thielen wrote:

You can always open it multiple times at different sizes, if I
understand SDL_ttf correctly. (Honestly, I’ve barely used it so
far…)

Well, I’ll be switching the sizes back and forth. I’ll be needing the
old size again, so, is there a methodology in SDL_ttf to do that or
… what? Should I reinit the font?

i have once used the following concept.

whenever i needed a font, i generetaed a key from fontname and size
(like “fixed.ttf,16”) and kept a list of key/fonthandle pairs. if the
key was allready in the list use the handle, otherwise open the font and
store the key and its handle in the list.

maybe this helps …
clemens

Thanks Sam, and thanks Clemens, yea, this all helps. Thanks.

– chris (@Christopher_Thielen)On Mon, 2002-07-29 at 18:21, Sam Lantinga wrote:

Well, I’ll be switching the sizes back and forth. I’ll be needing the
old size again, so, is there a methodology in SDL_ttf to do that or …
what? Should I reinit the font?

Just open the font twice, once with each point size.
You’ll get two different font handles, with the same font at different sizes.