One thing that works is to decide on the max size you want (height
and width) for the text, and then create the font using various
sizes, using binary search to find the font size that best fills
the area in question.
The text you want to display could be some well-known string, so
you know what'll happen for a number of common easily testable
fonts, and at least have some hope of having a readable screen
when a user prefers Atlantis Parade Demi Black and enters her name
in Kanji or something.
Cheers,
/ h+
> -----Original Message-----
> From: gam...@li...
> [mailto:gam...@li...]On Behalf Of
> Brian Hook
> Sent: Thursday, April 18, 2002 4:19 PM
> To: 'GDWindows'
> Subject: [GD-Windows] CreateFont question
>
>
> I'm using CreateFont() to make a font for high scores, statistics, etc.
> I'm doing a pretty vanilla call:
>
> hFont = CreateFont( -MulDiv( kiPointSize, GetDeviceCaps( hDC,
> LOGPIXELSY ), 72 ),// nHeight
> 0,
> // nWidth
> 0,
> // nEscapement
> 0,
> // nOrientation
> FW_BOLD,
> // fnWeight
> FALSE,
> // fdwItalic
> FALSE,
> // fdwUnderline
> FALSE,
> // fdwStrikeout
> OEM_CHARSET,
> // fdwCharSet
> OUT_DEFAULT_PRECIS,
> // fdwOutputPrecision
> CLIP_DEFAULT_PRECIS,
> // fdwClipPrecision
> DEFAULT_QUALITY,
> // fdwQuality
> FF_MODERN | FIXED_PITCH,
> // fdwPitchAndFamily
> NULL );
> // typeface name
>
> The problem is that on systems where the user has selected "Big Fonts",
> I always get vastly oversized fonts that don't fit in my various text
> boxes. Anyone have suggestions on what to do in such cases?
>
> The obvious alternative is to do my own font handling, but for various
> reasons I'd prefer to avoid that (specifically, internationalization
> issues).
>
> Brian
>
>
> _______________________________________________
> Gamedevlists-windows mailing list
> Gam...@li...
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=555
>
|