Re: GDI Font data vs Photoshop rasterised data
- From: "Mike D Sutton" <EDais@xxxxxxxx>
- Date: Tue, 11 Apr 2006 20:07:18 +0100
Hi. I don't really know whether this question needs to be asked in a
Photoshop newsgroup, or a GDI newsgroup - but here goes anyway ...
I'm writing a font tool that takes the glyphs from a tga file, and
exports my own custom format for our game engine. This is so our
artists can quickly modify the characters/colours in Photoshop if
required.
I'm getting the font data (ie. kerning pairs, baseline, abc widths,
etc) from the font using Windows GDI functions. The user obviously has
to specify in my tool which font they used in the tga file.
My problem is that the font data doesn't exactly match the pixel data
in Photoshop. It's close, but not close enough. As an example, take
the gmBlackBoxX member of the GLYPHMETRICS structure. Providing that
my mapping mode is set to MM_TEXT (and taking into account the scaling
that I mention in my next paragraph), I would presume that gmBlackBoxX
would exactly match the physical width of the character in the tga
image.
Regarding the scaling that I mentioned in the last paragraph - I take
into account the Photoshop image's resolution (pixels per inch), and
scale using the following forumula ...
screen_pixels_per_inch = (float) GetDeviceCaps (device_context,
LOGPIXELSX);
conversion_coefficient = 72.0f / screen_pixels_per_inch;
result = (int) ((float) value * conversion_x_coefficient);
Where "72.0f" is the resolution of the photoshop image (pixels/inch),
and "value" is the font data value (eg. gmBlackBoxX). Obviously using
LOGPIXELSY instead of LOGPIXELSX when doing a vertical scale.
As I said earlier, it is very close. But a lot of the time it's one or
two pixels out. For the text in my game to appear correctly, it needs
to be exactly what Photoshop rasterises to.
Photoshop uses a far more complex layout engine than GDI, so you're most likely encountering floating point rounding
errors which account for this discrepancy. One option would be to simply render the character map using GDI, then allow
your artists to do any post-processing in Photoshop such as adding layer effects and so on. This way you're using GDI's
measurements and Photoshop's rendering capabilities.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/
.
- Follow-Ups:
- Re: GDI Font data vs Photoshop rasterised data
- From: Mihai N.
- Re: GDI Font data vs Photoshop rasterised data
- References:
- Prev by Date: GDI Font data vs Photoshop rasterised data
- Next by Date: Skewif transformation.
- Previous by thread: GDI Font data vs Photoshop rasterised data
- Next by thread: Re: GDI Font data vs Photoshop rasterised data
- Index(es):
Relevant Pages
|