freetype-devel
[Top][All Lists]
Advanced

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

Re: [Devel] Re-encoding interface requested?


From: Sander van der Wal
Subject: Re: [Devel] Re-encoding interface requested?
Date: Mon, 12 Mar 2001 17:41:24 +0100

I stumbled on an even easier way: FT_Get_Glyph_Name()

I needed to implement this for the CFF driver but that wasn't hard:
cffdrivr.c

  static
  FT_Error  get_cff_glyph_name( CFF_Face    face,
                                FT_UInt     glyph_index,
                                FT_Pointer  buffer,
                                FT_UInt     buffer_max )
  {
    CFF_Font*           font = (CFF_Font*)face->extra.data;
    FT_Memory           memory = FT_FACE_MEMORY(face);
    FT_String*          gname;
    FT_UShort           sid;
    PSNames_Interface*  psnames;

    psnames = (PSNames_Interface*)FT_Get_Module_Interface(
              face->root.driver->root.library, "psnames" );

    /* first, locate the sid in the charset table */
    sid = font->charset.sids[glyph_index];

    /* now, lookup the name itself */
    gname = CFF_Get_String( &font->string_index,
                            sid,
                            psnames );
    if ( buffer_max > 0 )
    {
      FT_UInt  len = strlen( gname );


      if (len >= buffer_max)
        len = buffer_max - 1;

      MEM_Copy( buffer, gname, len );
      ((FT_Byte*)buffer)[len] = 0;
    }

    FREE ( gname );
    return CFF_Err_Ok;
  }

further down, cff_get_interface becomes:

  static
  FT_Module_Interface  cff_get_interface( CFF_Driver   driver,
                                          const char*  interface )
  {
    FT_Module  sfnt;

#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
    if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
      return (FT_Module_Interface)get_cff_glyph_name;
#endif

    /* we simply pass our request to the `sfnt' module */
    sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );

    return sfnt ? sfnt->clazz->get_interface( sfnt, interface ) : 0;
  }


And in cffobjs.c, in function CFF_Init_Face():

  /* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW
*/
#if 0
        /* kerning available? */
        if ( face->kern_pairs )
          flags |= FT_FACE_FLAG_KERNING;
#endif

#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
        flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif

        root->face_flags = flags;

There might be some more changes needed, that this works satisfactory
for me.

Sander van der Wal


> See the TODO list in a CVS snapshot.  I plan on working on a cmap
synthesizer.
> I also want to add a a unction like below (though I didn't add it to
the list).
> What you propose sounds reasonable.  The hooks are there.  YYou pass
the glyph
> name, find its SID (string ID) and use the SID to find the GID
(glyph index)
> from the charset table.  The most difficult part of this is the
glyph name to
> SID mapping, just becuase of how CFF fonts are set up.  In
particular, you might
> have to iterate over the entire string table in the CFF font to find
the SID for
> a particular string.  Or you might have to consult the standard
strings table

> >
> > A couple of weeks ago (8 jan 2001) Leonard Rosenthol had a problem
> > with custom encodings for Type 1 fonts and CFF fonts having no
cmap.
> >
> > I have the same problems (because I am also doing a PDF viewer)
and I
> > think that the solution is to add a function to the public
interface
> > of freetype2. Right now there's FT_Get_Char_Index, to translate a
> > character code to a glyph index. If there would be a function
> >
> > FT_UInt   FT_Get_Glyphname_Index(FT_Face* face, const FT_String*
> > glyph_name)
> >
> > that returned the glyph index based on the glyph name, client
> > applications could do the re-encoding themselves.
> >
> > Is this a reasonable way? I can work on the implementations.
> >
>
>
> _______________________________________________
> Devel mailing list
> address@hidden
> http://www.freetype.org/mailman/listinfo/devel
>




reply via email to

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