freetype
[Top][All Lists]
Advanced

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

[Freetype] Unexpected advance values


From: Ulf Klaperski
Subject: [Freetype] Unexpected advance values
Date: Tue, 20 Jul 2004 23:10:02 +0200
User-agent: Mutt/1.5.4i

Hi all,

I am trying to write a graphics library which creates output files in
xfig format, including the postscript fonts as used by xfig.
For calculating the text size I am trying to use freetype2. 

My problem: the text width given by freetype does not match the
expected values. Both xfig and ghostscript agree on the width of the
text. Only freetype2 provides values which are roughly 5-15% larger.

I am running my trial with a string of 50 "i".

- Font is Century Schoolbook L Roman
- Both GhostScript and Freetype2 load the font from the file c059013l.pfb
- I print the kerning, it's always 0
- xfig sets the string width to 3000, which makes an advance of 60
  per i
- Freetype2 reports a width of 55 and an advance.x of 63 (which is 5% too
  much). 
- If I replace the "i" with "M", I get 9450 instead of 8250 = 14.5%
  too much
- I tried no_hinting, but that gave only a slight change (9400) for "M"

I have appended the (stripped down) code below.

What am I doing wrong? Is there anything besides kerning which I have
to pay attention to?

Thanks in advance!

Ulf

->CODE:

  ft_fail = FT_New_Face(freetype_lib, easyvec_font_files[elm_font], // Century 
Schoolbook L Roman
                          0, &face );

  ft_fail = FT_Set_Char_Size(face,    /* handle to face object           */
                                 12*64,       /* char_width in 1/64th of points 
 */
                                  12*64,   /* char_height in 1/64th of points */
                                 1200,     /* horizontal device resolution    */
                                 1200 );   /* vertical device resolution      */

  text_width = text_height = 0;
  old_glyph_i = 0;
  for ( text_iter = elm_text.begin(); text_iter != elm_text.end(); ++text_iter 
) {
    cur_char = *text_iter;
    glyph_index = FT_Get_Char_Index(face, cur_char );

    ft_fail = FT_Load_Char( face, cur_char, FT_LOAD_RENDER );

    glyph = face->glyph;
    if ( old_glyph_i && glyph_index ) {
      FT_Vector delta;
      FT_Get_Kerning( face, old_glyph_i, glyph_index, FT_KERNING_DEFAULT, 
&delta );
      cout << "Kerning is " <<  (delta.x >> 6) << endl;
    }
    
    text_width += glyph->metrics.horiAdvance/64;
    cout << "C/WD/HD/W/H: <" << cur_char << ">" << glyph->metrics.width/64 << 
";" << glyph->advance.x/64 << ";" << text_width << ":" << text_height << endl;
    old_glyph_i = glyph_index;
  }
  cout << "Text width is " << text_width << endl;  



-- 
Jabber-ID: address@hidden



reply via email to

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