patch requested for freetype2/internal header usage (using font_bbox)

Drew Parsons dparsons at debian.org
Sat Jan 21 22:22:47 PST 2006


Dear FreeType developers,

I am involved with Xprint, an X11 extension enabling printing using the
X protocol [1].

Xprint uses FreeType2, but unfortunately its postscript driver uses the
internal freetype headers.  You've written very clearly [2] that this
should not be done, and I would to take up your kind offer to work with
us to patch the problem.

The incriminating code is found in Xprint/ps/psout_ftpstype3.c.  It can
be found in X.org's new modular system at
http://cvs.freedesktop.org/xorg/xserver/xorg/Xprint/ps/psout_ftpstype3.c?view=markup
However the freetype support is not yet switched on in the modular
build, so if you need to compile it yourself you might find the old
monolithic builds [3] ready for use.

The internal headers are referenced in psout_ftpstype3.c around l.58:

#define USE_FT_INTERNALS 1
#ifdef USE_FT_INTERNALS
#include FT_INTERNAL_TYPE1_TYPES_H
#include "t42types.h"
#include FT_INTERNAL_OBJECTS_H
#endif /* USE_FT_INTERNALS */

FT_INTERNAL_TYPE1_TYPES_H is defined as internal/t1types.h, one the
internal headers in quiestion. "t42types.h" moreover is in src/type42/,
not even exported.  I don't know why the original author also referenced
FT_INTERNAL_OBJECTS_H, but I can find the other two headers used below.

As far as I can make out, they are used to define the function
FT_Get_PS_Font_BBox( ) near l.290:

#ifdef USE_FT_INTERNALS
static FT_BBox *
FT_Get_PS_Font_BBox( FT_Face face )
{
  const char *driver_name;
  FT_BBox    *font_bbox = NULL;

  if ( face && face->driver && face->driver->root.clazz )
  {
    driver_name = face->driver->root.clazz->module_name;
    if ( ft_strcmp( driver_name, "type1" ) == 0 )
      font_bbox = &(((T1_Face)face)->type1.font_bbox);
    else if ( ft_strcmp( driver_name, "t1cid" ) == 0 )
      font_bbox = &(((CID_Face)face)->cid.font_bbox);
    else if ( ft_strcmp( driver_name, "type42" ) == 0 )
      font_bbox = &(((T42_Face)face)->type1.font_bbox);
  }

  return font_bbox;
}
#endif /* USE_FT_INTERNALS */

If I'm reading it correctly, it's the use of face->type1.font_bbox with
face case as T1_Face which is explicitly using the Freetype internal
structures, since font_bbox is defined in T1_Font in internal/t1types.h. Likewise for t42types.h.  

Is there a public interface for accessing these font_bboxes without
breaking the way you want the freetype code to be used?

The font bbox is used in psout_ftpstype3.c around l.365 (in
PSType3_generateOutlineFont( ) ), where the font bbox values are used to
write a postscript FontBBox.

Patches or clues gratefully accepted!

Thanks,

Drew Parsons



[1] http://xprint.mozdev.org/

[2] http://freetype.sourceforge.net/freetype2/freetype-2.2.0.html

[3] Latest monolithic source:
http://cvs.freedesktop.org/xorg/xc/programs/Xserver/Xprint/ps/,
older tarball:
http://prdownloads.sourceforge.net/xprint/xprint-2004-07-07-release_009_001-i386-pc-linux-gnu.tar.gz?download


More information about the xorg-modular mailing list