freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] default encoding


From: David Turner
Subject: Re: [Freetype] default encoding
Date: Wed, 10 Jul 2002 16:29:36 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530

Hello Tor,

Tor Andersson wrote:
Hi all,

Does anybody know how to get FT_Get_Char_Index() to use the
default/built-in encoding of a font? I've looked high and far and found
no obvious solution.


you're question is ambiguous. What do you mean exactly by
"default encoding" ??

 - a TrueType font may contain one or more charmaps, there is
   no "default" defined by the standard per-se, though it is
   highly recommended that all fonts have a Unicode and Apple Roman
   charmaps. Not all fonts do

 - most bitmap font formats store the glyphs in a pre-defined
   order corresponding to a given "encoding". Since there are
   so many of these defined, we don't include them within FreeType

 - a Type 1 font contains an "encoding" dictionary that acts
   as a FreeType charmap for very simply character repertoires
   (i.e. with less than 255 characters in them).

   by default, FreeType will always synthetize a Unicode charmap
   from the glyph names dictionary, and select it. You need to
   change the active charmap in your FT_Face object before calling
   FT_Get_Char_Index

   you can however access the Type 1 font encoding by parsing
   the face->charmaps array. We support the following descriptions

        platform_id   encoding_id   encoding

             7             0        ft_encoding_adobe_standard
             7             1        ft_encoding_adobe_export
             7             2        ft_encoding_adobe_custom

   so, to select the default encoding of a Type 1 font, you should
   do something like:

     found = 0;
     for ( ii = 0; ii < face->num_charmaps; ii++ )
     {
       FT_CharMap  cmap = face->charmaps[ii];

       if ( cmap->platform_id == 7 )
       {
         FT_Set_CharMap( face, cmap );
         found = 1;
         break;
       }
     }

  - for CFF fonts, we don't support charmaps for now. Sorry, but
    feel free to provide a patch if you have one :-)

  - for OpenType fonts, we support charmaps available as "cmap"
    sub-tables of the SFNT structures, and nothing when it is
    embedded in the CFF portion of the file.

Hope this helps,

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




reply via email to

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