freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] PCF glyph numbers


From: David Turner
Subject: Re: [Devel] PCF glyph numbers
Date: Thu, 24 Apr 2003 18:41:31 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312

Hello,

Keith Packard wrote:
The num_glyphs field in an FT_Face object indicates the number of glyphs available in a font. For TrueType and Type1 fonts, the glyphs range in number from 0..num_glyphs-1. However, for PCF fonts, they range from 1..num_glyphs.

Is there any guarantee that glyph values will be limited to either of these two ranges? Or are glyph numbers truely random?


That's most probably a bug in the PCF font driver, because the norm
is that:

  - valid glyph indices always range from 0 to num_glyphs-1

  - glyph 0 always correspond to the "missing glyph"

in certain formats (e.g. WinFNT, or in Type 1 where certain fonts
do not contain a ".notdef" glyph), the font driver is responsible
for synthetizing an artificial "missing glyph" and bumping "num_glyphs"
by 1, shifting all glyph indices when appropriate.

I suspect that the PCF font driver doesn't follow this convention to
the letter. Wait, I just looked at the code, and spotted two distinct
bugs:

  A - FT_Load_Glyph() incorrectly accepts "num_glyphs" as a valid
      glyph index. line 468 of src/base/ftobjs.c should look like:

           if ( glyph_index >= (FT_UInt)face->num_glyphs )
            return FT_Err_Invalid_Argument;

      (replacing the ">" with ">=")


  B - The PCF font driver doesn't initialize correctly face->num_glyphs,
      line 970 of src/pcf/pcfread.c should be replaced by:

        root->num_glyphs = face->nmetrics + 1;


note that the PCF driver routines already support the +1 shift in glyph
indices (i.e. look at the charmap routines, or the glyph loading one..)

Werner, could you commit these changes. I'm unfortunately at work where
any kind of CVS access is impossible.. And I have little time at home
to work on FreeType at the moment.

Hope this helps,

- David Turner
- The FreeType Project  (www.freetype.org)


--
This message and any attachments (the "message") is intended solely for the
addressees and is confidential. If you receive this message in error, please
delete it and immediately notify the sender.
Any use not in accordance with its purpose, any dissemination or disclosure,
either whole or partial, is prohibited except formal approval.
The E-Mail transmission can not guarantee the integrity of this message.
CANAL+TECHNOLOGIES will not therefore be liable for the message if modified.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]