@@ -445,21 +445,17 @@ int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_UInt mode, bool fallbac
445
445
FT2Font *left_ft_object = glyph_to_font[left];
446
446
FT2Font *right_ft_object = glyph_to_font[right];
447
447
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 ;
449
450
}
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,
451
452
// do the exact same thing which set_text does.
452
453
return right_ft_object->get_kerning (left, right, mode, false );
453
454
}
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);
463
459
}
464
460
}
465
461
@@ -497,13 +493,14 @@ void FT2Font::set_text(
497
493
matrix.yx = (FT_Fixed)(sin (angle) * 0x10000L );
498
494
matrix.yy = (FT_Fixed)(cos (angle) * 0x10000L );
499
495
500
- FT_UInt previous = 0 ;
501
-
502
496
clear ();
503
497
504
498
bbox.xMin = bbox.yMin = 32000 ;
505
499
bbox.xMax = bbox.yMax = -32000 ;
506
500
501
+ FT_UInt previous = 0 ;
502
+ FT2Font *previous_ft_object = NULL ;
503
+
507
504
for (size_t n = 0 ; n < N; n++) {
508
505
FT_UInt glyph_index = 0 ;
509
506
FT_BBox glyph_bbox;
@@ -526,7 +523,11 @@ void FT2Font::set_text(
526
523
}
527
524
528
525
// 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
+
530
531
FT_Vector delta;
531
532
pen.x += ft_object_with_glyph->get_kerning (previous, glyph_index, FT_KERNING_DEFAULT, delta);
532
533
}
@@ -550,6 +551,8 @@ void FT2Font::set_text(
550
551
pen.x += last_advance;
551
552
552
553
previous = glyph_index;
554
+ previous_ft_object = ft_object_with_glyph;
555
+
553
556
}
554
557
555
558
FT_Vector_Transform (&pen, &matrix);
0 commit comments