Delving into the help system, I can't (thus far) find any mention of
kerning.
Is there something I have to do with one or more of CFont, DrawText(),
TextOut(), ExtTextOut() in order for text to respect the kerning pairs
defined in a TrueType font?
Dave
--
David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm
AliR.
"David Webber" <da...@musical-dot-demon-dot-co.uk> wrote in message
news:%23XSpQqr...@TK2MSFTNGP04.phx.gbl...
> Are you saying that the characters are not spaced correctly based on the
> font, or are yo trying to change the spacing?
The former.
The spacing of the characters is what it would be if there were no kerning
pairs.
[It's easy enough to check as Word 2007 - and maybe earlier versions - lets
you switch kerning on an off, so you can see how much difference it makes.
Typically, for example, AV will be closer together than the individual
spacing of the letters would imply.]
I sort of assumed that APIs like ExtTextOut and DrawText would respect the
kerning adjustment, but it appears not. After that I looked for possible
flags in a LOGFONT which might change this aspect of the font its used to
create, but I can't see anything. So I'm a bit puzzled. Something ought
to be going on deep down in the truetype font engine and there must be
something at the Windows API level (if not at the MFC level) to make it
happen???
> Something ought
> to be going on deep down in the truetype font engine and there must be
> something at the Windows API level (if not at the MFC level) to make it
> happen???
No, there is nothing. And there is no good reason for it to be.
Kerning is good for typography, where you deal with high resolutions.
The stuff on screen, at 72 dpi (or around that) should be as sharp
and clear as possible, so fancy stuff is left out.
Changes in that behavior resulted in major complaints
(for instance the first Safary port on Windows, and the first
previews of VS 2010)
A great interview here:
http://channel9.msdn.com/posts/scobleizer/Cleartype-Team-Typography-in-
Windows-Vista/
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
I could live with that on the screen, (though this stuff isn't *that* fancy)
but my WYSIWYG document prints exactly as it appears in the window - with no
kerning.
Is it not possible to *print* with kerning.
> A great interview here:
> http://channel9.msdn.com/posts/scobleizer/Cleartype-Team-Typography-in-
> Windows-Vista/
I'll get back to this when I have more time - it seems to be starting rather
slowly.
It's always fun seeing Bill Hill in one of those, but I didn't think
it was relevant to your question here.
Dave
I'd take a look at the Uniscribe functions. Kerning is simply a minor
improvement in appearance for most western European languages, for
for some others (e.g., Arabic scripts, if I'm not mistaken) it's
pretty much an absolute necessity. To support them well at all, I'm
pretty sure Uniscribe most include kerning support. Unless it was
designed by the same people who designed Visual Studio, it'll
probably do kerning for English and such as well.
--
Later,
Jerry.
The fonts also needs to have kerning information.
Just tried DrawText on Windows 7 and there is kerning
(Arial does not seem to have kerning info, Times New Roman does.)
>> I could live with that on the screen, (though this stuff isn't *that*
>> fancy)
>> but my WYSIWYG document prints exactly as it appears in the window - with
>> no kerning.
>>
>> Is it not possible to *print* with kerning.
>
> The fonts also needs to have kerning information.
> Just tried DrawText on Windows 7 and there is kerning
> (Arial does not seem to have kerning info, Times New Roman does.)
Thanks - I'll experiment further.
For years I have been designing an maintaining symbol fonts (currently with
High Logic Font Creator - an excellent program) for which kerning is not an
issue.
Recently I designed a text font, and my wife is currently patiently going
through it putting in the kerning information. We can see it fine in Word
(if we switch he option on) - so it's definitely there :-) but not in the
text output of my program (testing on Vista).
Can you tell me what "precision" parameter you used in the LOGFONT or
CreateFont?
"Jerry Coffin" <jerryv...@yahoo.com> wrote in message
news:MPG.260067e6a...@news.sunsite.dk...
> I'd take a look at the Uniscribe functions. Kerning is simply a minor
> improvement in appearance for most western European languages, for
> for some others (e.g., Arabic scripts, if I'm not mistaken) it's
> pretty much an absolute necessity. To support them well at all, I'm
> pretty sure Uniscribe most include kerning support. Unless it was
> designed by the same people who designed Visual Studio, it'll
> probably do kerning for English and such as well.
Thanks for this idea.
I looked into Uniscribe some while back and it looked complicated. :-(
But kerning tables are pretty bog standard these days in truetype fonts, and
therefore the truetype font engine must surely know about them. And if
that's the case it would seem logical that the bottom level Windows API with
HFONTs should be able to use kerning. And if they can then the layers on
top (like CFont) should automatically be able to use it.
Mihai's latest post seems to indicate it works on Windows 7 at least, so
maybe I'm just doing something wrong.
(And in any case the distinction between Latin and Arabic scripts is now
essentially gone: the characters are just there at the appropriate Unicode
code points in the font, and it would therefore seem odd if text output
respected kerning in one area of the font but not another.)
Still puzzling it out,
Here is the full dump:
lfHeight = -27
lfWidth = 0
lfEscapement = 0
lfOrientation = 0
lfWeight = 400
lfItalic = 0
lfUnderline = 0
lfStrikeOut = 0
lfCharSet = 0
lfOutPrecision = OUT_STROKE_PRECIS
lfClipPrecision = CLIP_STROKE_PRECIS
lfQuality = DRAFT_QUALITY
lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN
lfFaceName = _T("Times New Roman")
It is what the font selection dialog gives me by default, I did
not mess with it in any way.
And nothing fancy about the drawing either:
wnd->GetClientRect( &m_Rect );
CDC *pdc = wnd->GetDC();
CBrush brush(RGB(0xff,0xff,0xff));
pdc->FillRect( m_Rect, &brush );
CFont *pfOld = pdc->SelectObject( &m_Font );
pdc->SetBkMode( TRANSPARENT );
pdc->DrawText( inString, inString.GetLength(), m_Rect, 0 );
pdc->SelectObject( pfOld );
wnd->ReleaseDC( pdc );
And it might also matter how the kerning is created.
Some applications don't recognize the GPOS kern unless
ther is also a GSUB table (don't ask me why)
Might try to dump Times New Roman and take a look inside
TTX at http://www.letterror.com/code/ttx/ or
TTFdump at http://www.microsoft.com/typography/tools/tools.aspx
can come in handy
That's because it is :-)
> (And in any case the distinction between Latin and Arabic scripts is now
> essentially gone: the characters are just there at the appropriate Unicode
> code points in the font, and it would therefore seem odd if text output
> respected kerning in one area of the font but not another.)
Actually, Arabic fonts have very little use of kerning (if any).
"Mihai N." <nmihai_y...@yahoo.com> wrote in message
news:Xns9D382EE...@207.46.248.16...
>
>> Can you tell me what "precision" parameter you used in the LOGFONT or
>> CreateFont?
>
> Here is the full dump:
> lfHeight = -27
> lfWidth = 0
> lfEscapement = 0
> lfOrientation = 0
> lfWeight = 400
> lfItalic = 0
> lfUnderline = 0
> lfStrikeOut = 0
> lfCharSet = 0
> lfOutPrecision = OUT_STROKE_PRECIS
> lfClipPrecision = CLIP_STROKE_PRECIS
> lfQuality = DRAFT_QUALITY
> lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN
> lfFaceName = _T("Times New Roman")
>...
Thanks - I appear to be using
logfont.lfOutPrecision = OUT_TT_PRECIS;
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
but the code dates from somewhere up to 20 years ago and I'm not sure if
I've reviewed it since! I'll investigate the difference.
>...
> And it might also matter how the kerning is created.
> Some applications don't recognize the GPOS kern unless
> ther is also a GSUB table (don't ask me why)
>
> Might try to dump Times New Roman and take a look inside
> TTX at http://www.letterror.com/code/ttx/ or
> TTFdump at http://www.microsoft.com/typography/tools/tools.aspx
> can come in handy
So far I've just been looking at text output. Conclusions are weird:
2. Microsoft Word 2007, under Vista or Windows 7, gives a choice - kerned
or unkerned. It works for Times New Roman and it also works for my font.
2a. My MFC App under Vista: doesn't kern either TNR; or my font.
2b. My MFC App under 7: kerns TNR but *doesn't* kern my font.
Looks like I may have to experiment with LOGFONT settings *and* learn about
GPOS and GSUB (about which I am thus far completely ignorant, so thanks for
the hint!)
>
>> Can you tell me what "precision" parameter you used in the LOGFONT or
>> CreateFont?
>
>Here is the full dump:
> lfHeight = -27
> lfWidth = 0
****
Note that it is unusual to provide a width other than 0 except for special effects
(nonzero value produce really weird-looking fonts!)
****
> lfEscapement = 0
> lfOrientation = 0
> lfWeight = 400
****
400 is FW_NORMAL
****
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
[LOGFONT]
> Note that it is unusual to provide a width other than 0 except for special
> effects
> (nonzero value produce really weird-looking fonts!)
Yes - I stick to zero as a matter of course.
>> lfWeight = 400
> 400 is FW_NORMAL
Yes - I usually use FW_NORMAL or FW_BOLD (=700 IIRC)
>> lfItalic = 0
>> lfUnderline = 0
>> lfStrikeOut = 0
>> lfCharSet = 0
>> lfOutPrecision = OUT_STROKE_PRECIS
>> lfClipPrecision = CLIP_STROKE_PRECIS
>> lfQuality = DRAFT_QUALITY
>> lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN
>> lfFaceName = _T("Times New Roman")
It doesn't look like any of these affect kerning and...
>>And it might also matter how the kerning is created.
>>Some applications don't recognize the GPOS kern unless
>>ther is also a GSUB table (don't ask me why)
As far as I can see (after a little reading) High Logic Font Creator
doesn't allow me a GSUB table.
>>Might try to dump Times New Roman and take a look inside
>>TTX at http://www.letterror.com/code/ttx/ or
>>TTFdump at http://www.microsoft.com/typography/tools/tools.aspx
>>can come in handy
So my next step is to look at these.
I am also starting to wonder if GDI+ text output will give different
results.
>
>"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
>news:k3kop557t378trcet...@4ax.com...
>
>[LOGFONT]
>
>> Note that it is unusual to provide a width other than 0 except for special
>> effects
>> (nonzero value produce really weird-looking fonts!)
>
>Yes - I stick to zero as a matter of course.
>
>>> lfWeight = 400
>> 400 is FW_NORMAL
>
>Yes - I usually use FW_NORMAL or FW_BOLD (=700 IIRC)
>
>>> lfItalic = 0
>>> lfUnderline = 0
>>> lfStrikeOut = 0
>>> lfCharSet = 0
>>> lfOutPrecision = OUT_STROKE_PRECIS
>>> lfClipPrecision = CLIP_STROKE_PRECIS
>>> lfQuality = DRAFT_QUALITY
>>> lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN
>>> lfFaceName = _T("Times New Roman")
>
>It doesn't look like any of these affect kerning and...
***
No, kerning is not specified by any LOGFONT features. For Roman alphabets, the way you
handle kening is to locate a kerning pair, e.g., SAVVVVA which has the kerning pair "AV",
and do a TextOut of everything up to the kerning pair, e.g., "SA", then based on the
offsets of the characters, adjust the current position at which text is placed by the
kerning amount (which is always interpreted relative to the DC into which the font is
realized), then continue to the next kenring pair "VA" and repeat. You have to segment
your output in this way to get the kerning pairs to work if you are doing simple TextOut.
I was not aware that DrawText honored pair kerning data. Pair kerning data is metadata
for the font, and as such is a totally separate table. Take a look at my "Font Explorer"
from my MVP Tips site (this is an updated version from the Win32 book version), which
shows kerning pairs in a graphical table.
Back when I was doing work on the Bush Guard Memo fraud, someone argued about pair
kerning, and someone made the ridiculous statement that he had typed in "The quick brown
fox jumps over the lazy dog" twice, and the second time he had enabled pair kerning in
Word, and the two lines were absolutely indentical, proving conclusively that pair kerning
did nothing. The statement was ridiculous because he had committed "bad science" and had
not analyzed his experiment; even the most elementary research on Times New Roman shows
that there is not a single pair or pair-kerned characters in that sentence, so OF COURSE
pair kerning will have no effect! But such pompous pronouncements were accepted by those
not suffifiently intelligent to understand the problem or the technology, and were used
as arguments that the obvious fakes were in fact "authentic" because there was no kerning.
In fact, there was *exactly* the "pseudo-kerning" of the ABC widths, which anyone who
understood Microsoft font technology would have been familiar with (moral: don't act as an
expert if you are totally clueless) which showed beyond any question the font was Times
New Roman and therefore the memos were fakes. The order of the day in that controversy was
Proof By WIshful Thinking, which conveniently ignored any facts that provde the memos were
fakes.
****
>
>>>And it might also matter how the kerning is created.
>>>Some applications don't recognize the GPOS kern unless
>>>ther is also a GSUB table (don't ask me why)
>
>As far as I can see (after a little reading) High Logic Font Creator
>doesn't allow me a GSUB table.
****
I don't know what a GSUB table is, but a pair-kerning table is one of the forms of font
metadata and a font design program should allow its specification.
joe
****
>
>>>Might try to dump Times New Roman and take a look inside
>>>TTX at http://www.letterror.com/code/ttx/ or
>>>TTFdump at http://www.microsoft.com/typography/tools/tools.aspx
>>>can come in handy
>
>So my next step is to look at these.
>
>I am also starting to wonder if GDI+ text output will give different
>results.
>
>Dave