freetype-devel
[Top][All Lists]
Advanced

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

[Devel] Suspected error in cff_parse_font_matrix


From: Sander van der Wal
Subject: [Devel] Suspected error in cff_parse_font_matrix
Date: Wed, 2 May 2001 17:33:50 +0200

I have been looking to a problem that a certain pdf file had it's
characters being about twice as big as the should be, according to the
sizes inside the pdf file. After some debugging, it appears that this
increase in saze was due to this code in cffparse.c (release 2.0.2)

 static
  FT_Error  cff_parse_font_matrix( CFF_Parser*  parser )
  {
    CFF_Font_Dict*  dict   = (CFF_Font_Dict*)parser->object;
    FT_Matrix*      matrix = &dict->font_matrix;
    FT_Vector*      offset = &dict->font_offset;
    FT_UShort*      upm    = &dict->units_per_em;
    FT_Byte**       data   = parser->stack;
    FT_Error        error;
    FT_Fixed        temp;

    error = CFF_Err_Stack_Underflow;

    if ( parser->top >= parser->stack + 6 )
    {
      matrix->xx = cff_parse_fixed_thousand( data++ );
      matrix->yx = cff_parse_fixed_thousand( data++ );
      matrix->xy = cff_parse_fixed_thousand( data++ );
      matrix->yy = cff_parse_fixed_thousand( data++ );
      offset->x  = cff_parse_fixed_thousand( data++ );
      offset->y  = cff_parse_fixed_thousand( data   );

      temp = ABS( matrix->yy );

      *upm = (FT_UShort)( FT_DivFix( 0x10000L,
                          FT_DivFix( temp, 1000 ) ) >> 16 );

      if ( temp != 0x10000L )
      {
>>>>> /* if I comment this code out, it appears to work
        matrix->xx = FT_DivFix( matrix->xx, temp );
        matrix->yx = FT_DivFix( matrix->yx, temp );
        matrix->xy = FT_DivFix( matrix->xy, temp );
        matrix->yy = FT_DivFix( matrix->yy, temp );
        offset->x  = FT_DivFix( offset->x,  temp );
        offset->y  = FT_DivFix( offset->y,  temp );
>>>> */
      }

When I look at the numbers, the FontMatrix consists of the numbers
0.00049 0 0 0.00049 (encoded as a0 00 49 ff  etc

If the commented out code isn't commented out, the matrix becomes
0.001 0 0 0.001.

These numbers are consistent with the idea that the letters are twice
as large on screen as they should be.

Sander




reply via email to

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