freetype-devel
[Top][All Lists]
Advanced

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

Re: [Devel] Enumerating font encoding


From: Keith Packard
Subject: Re: [Devel] Enumerating font encoding
Date: Fri, 01 Feb 2002 13:07:02 -0800

Ok, I've got some running code to help me enumerate font encodings.
Collecting the information is now essentially instantaneous, although I'll
want to test on a large set of TrueType fonts with Unicode encodings than I
have available now.

Here's a summary; the patch is somewhat large as it required new code
in every driver.  No existing code is affected, leaving us relatively 
assured that existing apps won't be broken by the change.

This is the external interface; nice and simple -- it just returns the 
next charcode that exists in the font after the specified one.  It returns
0 if there are encoded chars after the specified one.  The canonical way 
to find the first encoded char in a font is:

  if (FT_Get_Char_Index (face, 0))
    char = 0;
  else
    char = FT_Get_Next_Char (face, 0);

An alternative would be to have FT_Get_Next_Char return it's argument if
encoded, but I decided that would make the name less meaningful leading to
possible confusion (and infinite loops).  Suggestions for changing the 
semantics must be accompanied by a suggestion for a new name.

  /*************************************************************************/
  /*                                                                       */
  /* <Function>                                                            */
  /*    FT_Get_Next_Char                                                   */
  /*                                                                       */
  /* <Description>                                                         */
  /*    Returns the next charcode that is defined in the charmap.          */
  /*                                                                       */
  /* <Input>                                                               */
  /*    face     :: A handle to the source face object.                    */
  /*                                                                       */
  /*    charcode :: The character code.                                    */
  /*                                                                       */
  /* <Return>                                                              */
  /*    The charcode.  0 means `no encoded values above charcode'.         */
  /*                                                                       */
  FT_EXPORT( FT_ULong )
  FT_Get_Next_Char( FT_Face   face,
                    FT_ULong  charcode );

To support this function, new functions were added in

        FT_Driver_Class
                cff, cid, pcf, truetype, type1, winfonts
        TT_CMapTable
                sfnt
        PSNames_Interface
                psnames

I notice that in several interfaces there are mismatching types for 
charcodes; FT_UInt, FT_Long and FT_ULong are all used in various places.
Would a (separate) patch that uniformly switches these to FT_ULong be 
accepted?  This would have the effect of eliminating many casts in
data structure initializers involving function pointers.

I don't quite understand the format 2 TrueType charmap -- the code
seems to index subHeaderKeys using both high and low bytes of the 
character.  Can this really be right?  It seems to restrict the mapping
pretty severely; 16-bit fonts don't seem able to support any glyphs in 
page 0.

Keith Packard        XFree86 Core Team        Compaq Cambridge Research Lab





reply via email to

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