freetype-devel
[Top][All Lists]
Advanced

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

[Devel] FT_Set_Pixel_Sizes() problem with BDF/PCF drivers


From: Detlef Würkner
Subject: [Devel] FT_Set_Pixel_Sizes() problem with BDF/PCF drivers
Date: Sun, 11 Jul 2004 21:01:46 +0200

Hello!

Was unsubscribed for a while, thanks to Werner for subscribing me again.
However, didnt check the missed mails online so forgive when I'm talking
about known issues.

Probably most other applications using FreeType2 wont have this problems,
but my application is an AmigaOS font engine and AmigaOS does
traditionally measure font sizes in pixels, not in points...

I'm using the FreeType2 font/size/glyph cache and call
FTC_Manager_LookupSize() to get a font size object. With BDF and PCF
bitmap font formats that contain one bitmap size per face I do set up
the scaler structure passed as argument to

scaler.width  = face->available_sizes->width;
scaler.height = face->available_sizes->height;
scaler.pixel  = TRUE;

Then FTC_Manager_LookupSize() calls FT_Set_Pixel_Sizes() with the width
and height passed in the scaler structure, this calls e.g.
BDF_Set_Pixel_Size() and this function compares something completely
different from a pixel size and fails for many BDF fonts:

  FT_CALLBACK_DEF( FT_Error )
  BDF_Set_Pixel_Size( FT_Size  size,
                      FT_UInt  char_width,
                      FT_UInt  char_height )
  {
    BDF_Face  face = (BDF_Face)FT_SIZE_FACE( size );
    FT_Face   root = FT_FACE( face );

    FT_UNUSED( char_width );
    FT_UNUSED( char_height );
[...]
    if ( size->metrics.y_ppem == root->available_sizes->y_ppem >> 6 )
    {
[...]
      return BDF_Err_Ok;
    }
    else
      return BDF_Err_Invalid_Pixel_Size;
  }

OTOH, BDF_Set_Point_Size looks like this:

  FT_CALLBACK_DEF( FT_Error )
  BDF_Set_Point_Size( FT_Size     size,
                      FT_F26Dot6  char_width,
                      FT_F26Dot6  char_height,
                      FT_UInt     horz_resolution,
                      FT_UInt     vert_resolution )
  {
    FT_UNUSED( char_width );
    FT_UNUSED( char_height );
    FT_UNUSED( horz_resolution );
    FT_UNUSED( vert_resolution );

    return BDF_Set_Pixel_Size( size, 0, 0 );
  }

IMHO the current content of BDF_Set_Pixel_Size() should be copied
to BDF_Set_Point_Size(), and then BDF_Set_Pixel_Size should be changed
to something like

  FT_CALLBACK_DEF( FT_Error )
  BDF_Set_Pixel_Size( FT_Size  size,
                      FT_UInt  char_width,
                      FT_UInt  char_height )
  {
    BDF_Face  face = (BDF_Face)FT_SIZE_FACE( size );
    FT_Face   root = FT_FACE( face );

    FT_UNUSED( char_width );


    if ( char_height == (FT_UInt)root->available_sizes->height )
    {
[...] /* Set size metrics here */
      return BDF_Err_Ok;
    }
    else
      return BDF_Err_Invalid_Pixel_Size;
  }

that compares the pixel height. The same for the PCF driver, although with
that format the problem did not appear here yet, probably because the PCF
metrics are normally more accurate than the BDF metrics or I didnt test
enough fonts.

To reproduce the problem, I have a courR08.bdf here where the available_sizes
object contains height 10, width 6, size 7, x_ppem 11, y_ppem 11, comparing
height 10 with y_ppem 11 always fails. Can send that font via private mail on
demand.

Ciao, Detlef
-- 
_ // address@hidden
\X/  Detlef Wuerkner, Langgoens/Germany



reply via email to

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