[HarfBuzz] No kerning?

Behdad Esfahbod behdad.esfahbod at gmail.com
Mon Oct 5 13:22:08 PDT 2015


The default is on, so that's irrelevant.

On 15-10-05 04:07 PM, Jamie Dale wrote:
> I wasn't aware such a thing existed. I've tried turning it on as per your
> example, however it doesn't seem to have made any difference.
> 
> -Jamie.
> 
> On 5 October 2015 at 20:45, Konstantin Ritt <ritt.ks at gmail.com
> <mailto:ritt.ks at gmail.com>> wrote:
> 
>     Did you enable 'kern' feature? Something like that:
> 
>     consthb_feature_tfeatures[1]={
> 
>     {HB_TAG('k','e','r','n'),!!kerningEnabled,0,uint(-1)}
> 
>     };
> 
>     constintnum_features=1;
> 
> 
>     boolshapedOk=hb_shape_full(hb_font,buffer,features,num_features,0);
> 
> 
> 
>     Regards,
>     Konstantin
> 
>     2015-10-05 23:32 GMT+04:00 Jamie Dale <jamiedale88+harfbuzz at gmail.com
>     <mailto:jamiedale88+harfbuzz at gmail.com>>:
> 
>         Hey all,
> 
>         In our application we have two text shaping backends; a simple
>         "kerning only" implementation using our existing font rendering code
>         (fast, but can't handle complex languages), and a HarfBuzz based
>         implementation for when we need to support complex languages (although
>         ideally the HarfBuzz implementation should be able to produce mostly
>         equivalent results when compared to our existing font rendering when
>         dealing with languages like English).
> 
>         If you've seen my previous email entitled "Using FreeType load flags",
>         then you'll know I'm using some custom font functions to try and
>         ensure HarfBuzz uses the correct FreeType hinting flags, as well as
>         cache a lot of FreeType calls, and use the correct scale.
> 
>         So far this has worked out really well, however I've noticed that the
>         HarfBuzz implementation isn't applying kerning when shaping English
>         text (probably other languages too).
> 
>         The images below are using the Roboto font, and show the output from
>         each implementation. 
>         The top image is using our "kerning only" implementation, and the
>         bottom image is using HarfBuzz. Note that the "T" and "e" characters
>         are further apart in the bottom image.
>         Inline images 2
>         Inline images 1
> 
>         Here's the (slightly cut down) code I'm using to create my HarfBuzz font:
> 
>         hb_font_t* CreateHarfBuzzFont(FT_Face InFace, const uint32
>         InGlyphFlags, const int32 InFontSize, const float InFontScale)
>         {
>         hb_font_t* HarfBuzzFont = nullptr;
> 
>         // Set the character size to render at (needs to be in 1/64 of a "point")
>         FT_Set_Char_Size(InFace, 0, InFontSize * 64, 96, 96);
> 
>         if (InFontScale != 1.0f)
>         {
>         FT_Matrix ScaleMatrix;
>         ScaleMatrix.xy = 0;
>         ScaleMatrix.xx = (FT_Fixed)(InFontScale * 65536);
>         ScaleMatrix.yy = (FT_Fixed)(InFontScale * 65536);
>         ScaleMatrix.yx = 0;
>         FT_Set_Transform(InFace, &ScaleMatrix, nullptr);
>         }
>         else
>         {
>         FT_Set_Transform(InFace, nullptr, nullptr);
>         }
> 
>         {
>         // Create a sub-font from the default FreeType implementation so we
>         can override some font functions to provide low-level caching
>         hb_font_t* HarfBuzzFTFont = hb_ft_font_create(InFace, nullptr);
>         HarfBuzzFont = hb_font_create_sub_font(HarfBuzzFTFont);
>         hb_font_destroy(HarfBuzzFTFont);
>         }
> 
>         hb_font_set_funcs(...); // Sets functions that use the user-data
>         below, implementations are mostly default, but with a caching layer,
>         and usage of FreeType hinting flags
>         hb_font_set_user_data(...); // Ensures we have access to InGlyphFlags
>         and the low-level caches
>         hb_font_set_scale(HarfBuzzFont, InFontScale, InFontScale);
> 
>         return HarfBuzzFont;
>         }
> 
>         Am I just missing something simple? I tried calling hb_font_set_ppem
>         but that didn't seem to make any difference.
> 
>         Thanks,
>         Jamie.
> 
>         _______________________________________________
>         HarfBuzz mailing list
>         HarfBuzz at lists.freedesktop.org <mailto:HarfBuzz at lists.freedesktop.org>
>         http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> 
> 
> 
> 
> 
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> 


More information about the HarfBuzz mailing list