[HarfBuzz] Inter-glyph spacing

Simon Cozens simon at simon-cozens.org
Fri Sep 12 01:40:35 PDT 2014


Hello,
	I am moving from Pango to Harfbuzz for my typesetting application, but have 
noticed a difference in the output - in particular, the spacing between glyphs 
is not right; I think I must be doing something wrong in the rendering step.

	I set the fonts up like so:

       if (FT_New_Face(uds->ft_library, font_path, 0, &(uds->ft_face)))
         return 0;

       if (FT_Set_Char_Size(uds->ft_face,f->pointSize * 64.0, 0, 0, 0))
         return 0;

And then (largely copied from the SDL example)

     hb_ft_font = hb_ft_font_create(uds->ft_face, NULL);
     buf = hb_buffer_create();
     if (f->script)
       hb_buffer_set_script(buf, hb_tag_from_string(f->script, 
strlen(f->script)));
     if (f->direction)
       hb_buffer_set_direction(buf, f->direction);
     if (f->lang)
       hb_buffer_set_language(buf, 
hb_language_from_string(f->lang,strlen(f->lang)));

     /* Layout the text */
     hb_buffer_add_utf8(buf, text, strlen(text), 0, strlen(text));
     hb_shape(hb_ft_font, buf, NULL, 0);

	And then when rendering, I move the rendering pen forward by 
glyph_pos.x_advance/64.0 points after displaying each glyph. Is this the right 
way to handle the result of hb_buffer_get_glyph_positions? (I know I have to 
also handle x_offset but the x_offsets are all zero in this example.)

	What also confuses me is that the result is very font-specific. SIL fonts are 
squashed. Times and Optima render perfectly: Pango and Harfbuzz equivalent. 
Adobe Garamond Pro and Caslon Pro are horrible, with some very strange 
inter-glyph spacing; in particular there is too much space after every letter 
"a", and too little after an "s".

	I've attached a comparison of the Pango and Harfbuzz outputs. Any help would 
be appreciated.

Thanks!
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shapers.pdf
Type: application/pdf
Size: 43031 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20140912/d39c1973/attachment-0001.pdf>


More information about the HarfBuzz mailing list