@@ -445,21 +445,17 @@ int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_UInt mode, bool fallbac
445445 FT2Font *left_ft_object = glyph_to_font[left];
446446 FT2Font *right_ft_object = glyph_to_font[right];
447447 if (left_ft_object != right_ft_object) {
448- // could potentially do something different?
448+ // we do not know how to do kerning between different fonts
449+ return 0 ;
449450 }
450- // if left_ft_object is not the same the right_ft_object,
451+ // if left_ft_object is the same as right_ft_object,
451452 // do the exact same thing which set_text does.
452453 return right_ft_object->get_kerning (left, right, mode, false );
453454 }
454- if (!FT_HAS_KERNING (face)) {
455- return 0 ;
456- }
457- FT_Vector delta;
458-
459- if (!FT_Get_Kerning (face, left, right, mode, &delta)) {
460- return (int )(delta.x ) / (hinting_factor << kerning_factor);
461- } else {
462- return 0 ;
455+ else
456+ {
457+ FT_Vector delta;
458+ return get_kerning (left, right, mode, delta);
463459 }
464460}
465461
@@ -497,13 +493,14 @@ void FT2Font::set_text(
497493 matrix.yx = (FT_Fixed)(sin (angle) * 0x10000L );
498494 matrix.yy = (FT_Fixed)(cos (angle) * 0x10000L );
499495
500- FT_UInt previous = 0 ;
501-
502496 clear ();
503497
504498 bbox.xMin = bbox.yMin = 32000 ;
505499 bbox.xMax = bbox.yMax = -32000 ;
506500
501+ FT_UInt previous = 0 ;
502+ FT2Font *previous_ft_object = NULL ;
503+
507504 for (size_t n = 0 ; n < N; n++) {
508505 FT_UInt glyph_index = 0 ;
509506 FT_BBox glyph_bbox;
@@ -526,7 +523,11 @@ void FT2Font::set_text(
526523 }
527524
528525 // retrieve kerning distance and move pen position
529- if (ft_object_with_glyph->has_kerning () && previous && glyph_index) {
526+ if ((ft_object_with_glyph == previous_ft_object) && // if both fonts are the same
527+ ft_object_with_glyph->has_kerning () && // if the font knows how to kern
528+ previous && glyph_index // and we really have 2 glyphs
529+ ) {
530+
530531 FT_Vector delta;
531532 pen.x += ft_object_with_glyph->get_kerning (previous, glyph_index, FT_KERNING_DEFAULT, delta);
532533 }
@@ -550,6 +551,8 @@ void FT2Font::set_text(
550551 pen.x += last_advance;
551552
552553 previous = glyph_index;
554+ previous_ft_object = ft_object_with_glyph;
555+
553556 }
554557
555558 FT_Vector_Transform (&pen, &matrix);
0 commit comments