by Michael S. Kaplan, published on 2013/04/12 07:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2013/04/12/10410514.aspx
Over in the Suggestion Box, Mike asked:
LOGFONT LF_FACESIZE potential buffer overrun?
LOGFONT LF_FACESIZE is only 32 characters, but I found a font name (I assume installed by Windows) that was greater than 32 characters:
Lucida Sans Typewriter Bold Oblique
Sure enough it crashes at least two programs I tried just by picking it. Bad limitation or just poorly written code?
Well, on the whole I would tend to blame the crashing programs.
It is their bug, after all!
I am of two minds on this issue.
On the one hand, the name of the font is its least important attribute -- the font file name is what's important.
Most of the filenames fit 8.3 naming rules.
But on the other hand, the name of the font is its most important attribute -- the font author has their ego and their creative spirit tied up in it.
We are, however, confusing other attributes of the font here.
The font's core identity is Lucida Sans Typewriter; the fact that it may choose to be bold or oblique is kind of besides the point, isn't it?
So in this case the bug is in the program trying to cram other attributes into the name that are better served by other members of the LOGFONT.
This neatly sidesteps the entire issue, since Lucida Sans Typewriter fits well within the limit! :-)
If you want me to tackle the larger issue, you'll have to come up with a longer core font name.
If you can!
John Cowan on 12 Apr 2013 9:19 AM:
Perhaps "Typewriter" could be abbreviated in the metadata, leaving us with the 31-character "Lucida Sans Typwrt Bold Oblique"?
ErikF on 12 Apr 2013 10:46 AM:
The original bad font name was "Lucida Sans Unicode" in Windows 3.1/95, which many people interpreted as meaning "the Lucida font that didn't have any Unicode" but of course was one of the few fonts that had Unicode support!