For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > September 2004 > Type 1 Fonts in Perl/Tk804.27 under WinXP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Type 1 Fonts in Perl/Tk804.27 under WinXP
Theron Stanford

2004-09-01, 8:57 pm

I have a Type 1 font with Unicode characters outside the U+0000-U+00FF
range that I'd like to use in Perl/Tk804.027 on WinXP. Switching to
another font is not an option -- the glyphs *have* to look a certain
way (it's for educational software teaching Chinese).

The font is already in the Fonts folder; it consists of a .pfm file
(the metrics) and a .pfb file (the glyph descriptions). WinXP claims
"native" support for Type 1 fonts. Thus, the font works quite
smoothly in applications such as Notepad and Microsoft Word. If the
font has the character, you get it; if the font doesn't, it displays a
centered dot instead.

However, Perl/Tk seems to do something else. Characters outside the
U+0000-U+00FF range automatically get replaced by "similar" characters
from a different font. The font I want to use is san serif, and the
replacements appear to be coming from Arial. This happens both in
Text widgets and in labels on Button widgets. So, no centered dots,
but quite a few mismatched characters.

How can I tell? Well, I visually compare an 18-pt display on Word and
in Perl/Tk. In particular, the font in question uses "grade-school"
lowercase a, a circle with a vertical line segment attached at the
right, not the lowercase a with the overhang.

I suspect it is a difference in rendering engines, but I haven't
combed all the way through the Tk804.027 source to see how it's done,
and I don't have the source for Notepad or Word for comparison
(surprise).

Any known workarounds, short of trying to convert my font to OpenType?

For those of you playing at home, the font is URW Gothic L Book. It
comes with Ghostscript. The characters that really stick out are the
lowercase a and i with macrons and carons.

Theron
Theron Stanford

2004-09-16, 8:38 pm

Problem solved. It's in the Tcl/Tk sources.

To be more specific: There's a function called LoadFontRanges() in
tkWinFont.c that checks a font for valid characters. It uses
GetFontData() from the Win32 API to do this, but this function returns
failure for fonts that aren't TrueType. LoadFontRanges() then
defaults to U+0000-U+00FF.

I fixed this by writing a little XSUB that uses GetFontUnicodeRanges()
from the WinXP API to make the adjustment. (I intend to submit a
patch for tkWinFont.c to the Tcl/Tk core in the near future, so it
works on both Tcl/Tk and Perl/Tk.)

Theron

> I have a Type 1 font with Unicode characters outside the U+0000-U+00FF
> range that I'd like to use in Perl/Tk804.027 on WinXP.
>
> ...
>
> The font is already in the Fonts folder; it consists of a .pfm file
> (the metrics) and a .pfb file (the glyph descriptions). WinXP claims
> "native" support for Type 1 fonts.
>
> ...
>
> However, Perl/Tk seems to do something else. Characters outside the
> U+0000-U+00FF range automatically get replaced by "similar" characters
> from a different font.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com