Re: GDI Font data vs Photoshop rasterised data

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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/


.



Relevant Pages

  • Re: Font looks fine in 3rd party app, but looks tish in VB6
    ... If I use this same font in say Adobe Photoshop it looks great. ... >It appears that VB6 does give a nice aliased look to the font that is why ... How does it look in other apps, ...
    (microsoft.public.vb.general.discussion)
  • Re: Photoshop 4 Type tool doesnt work
    ... whatever I type, whatever font I select, whatever ... Why does it seem Photoshop is putting ... As I recall there was a separate install step required for installing maps ... Didn't v4 treat Text as a Selection, ...
    (comp.graphics.apps.photoshop)
  • Photoshop 4 Type tool doesnt work
    ... whatever I type, whatever font I select, whatever ... Presumably the rectangle is the text box, as it's longer the more text ... Why does it seem Photoshop is putting ... I'm at 3% physical memory, but the page-file is only 10% used - so if ...
    (comp.graphics.apps.photoshop)
  • Re: font substitution error...again
    ... Only problem is that Photoshop CS2 barfs with a very ... > Does Photoshop offer the option of turning off font names displayed IN the font ... > Steve Rindsberg, PPT MVP ...
    (microsoft.public.mac.office.powerpoint)
  • Re: whats wrong here: scan pass for transparency
    ... Joergen Bech ha scritto: ... Why GDI shold be less precise than photoshop. ... you might get something to work at some, but not all, sizes. ...
    (microsoft.public.dotnet.framework.drawing)