From: bkph@wheat-chex.ai.mit.edu (Berthold K.P. Horn)
Newsgroups: comp.windows.ms.programmer
Subject: TrueType `decorative' font woes
Date: 16 Apr 92 15:45:32 GMT


Problem in accessing characters in non-text TrueType fonts:
===========================================================

I have a problem in using non-text TrueType fonts, such as, for example,
WingDings. I can't get at the real characters in the font (instead I get
alphanumerics that have no business being in WingDings). Or conversely,
when I DO get at the real characters in WingDings, then all the TrueType
TEXT fonts give me funky icons instead of alphanumerics.

Background:
-----------

In Windows, fonts can be either reencoded to Windows ANSI character set (as
all text fonts tend to be) or left alone to their `native' encoding 
(as Zapf DingBats and the Symbol font are).  

When you use CreateFont (or CreateFontIndirect) with Type 1 fonts, you
always get the right thing, since the metric file (PFM) specified whether
to use Windows ANSI encoding or not.  That is, if the `Family' field is set
to `Decorative' then the font is NOT reencoded, in all other cases it is
(This is not what ATM does, unfortunately, but that is another story).

Not so with TrueType fonts.  For example, if I use CreateFonts on WingDings
I get a plain text font - alphanumeric characters instead of funky glyphs.
Yet when I ask for its `FaceName' it lies to me and says it IS WingDings.
Now I CAN get at the real characters in WingDings by setting the `Family'
field in the CreatFont call to `Decorative'.  This way I get the correct
characters in WingDings. So whats the problem, you say?

Unfortunately this is not a solution, since if I always set Family to
Decorative, the TrueType TEXT fonts get screwed up.  That is, I get some
randomnly chosen `Decorative' TrueType font instead of the text font I asked
for (and again it lies to me about the Face Name).

(In the case of ATM fonts, the `Family' field in CreateFont has no effect,
since the PFM file says whether to use Windows ANSI encoding or
`native'encoding). 

Thus to use TrueType fonts I would need to know ahead of time whether the
font is `text' or `decorative' and the set the Family in the CreateFont call
accordingly.  This seems silly, since this information must be in the font
already.

Surely this can't be true!  Surely WingDings knows that it is `Decorative'?
Why on earth would CreateFont give me a text font when I ask for WingDings?
Why on earth would CreateFont give me WingDings when I ask for some plain
TrueType text font but set `Family' to `Decorative'?  Help!

By the way, The TrueType `Symbol' font is an exception to the above. It DOES
work the way the Type 1 fonts work.  That is, you get a font with symbols in
it if you call it the obvious way in CreateFont.  Seems like they may have
`special cased' this one since it is the most commonly used non-text font...

P.S. By the way, unfortunately TreuType and Type 1 symbol fonts have the
same name.  How to you FORCE selection of the non-TrueType version of a font
in this situation.  Amusingly Windows DOES provide a way to force use of the
TrueType version, but not the other way around...

Berthold K.P. Horn
Cambridge, Massachusetts, USA
Newsgroups: comp.windows.ms.programmer