@@ -742,6 +742,7 @@ Canvas::ResolveFontDescription(const PangoFontDescription *desc) {
742
742
// if someone registered two different fonts under the same family name.
743
743
// https://drafts.csswg.org/css-fonts-3/#font-style-matching
744
744
char **families = g_strsplit (pango_font_description_get_family (desc), " ," , -1 );
745
+ GHashTable *seen_families = g_hash_table_new (g_str_hash, g_str_equal);
745
746
GString *resolved_families = g_string_new (" " );
746
747
747
748
for (int i = 0 ; families[i]; ++i) {
@@ -750,8 +751,14 @@ Canvas::ResolveFontDescription(const PangoFontDescription *desc) {
750
751
751
752
for (; it != _font_face_list.end (); ++it) {
752
753
if (g_ascii_strcasecmp (families[i], pango_font_description_get_family (it->user_desc )) == 0 ) {
753
- if (renamed_families->len ) g_string_append (renamed_families, " ," );
754
- g_string_append (renamed_families, pango_font_description_get_family (it->sys_desc ));
754
+ char *name = g_strdup (pango_font_description_get_family (it->sys_desc ));
755
+
756
+ // Avoid sending duplicate SFNT font names due to a bug in Pango for macOS:
757
+ // https://bugzilla.gnome.org/show_bug.cgi?id=762873
758
+ if (g_hash_table_add (seen_families, name)) {
759
+ if (renamed_families->len ) g_string_append (renamed_families, " ," );
760
+ g_string_append (renamed_families, name);
761
+ }
755
762
756
763
if (i == 0 && (best.user_desc == NULL || pango_font_description_better_match (desc, best.user_desc , it->user_desc ))) {
757
764
best = *it;
@@ -769,6 +776,7 @@ Canvas::ResolveFontDescription(const PangoFontDescription *desc) {
769
776
770
777
g_strfreev (families);
771
778
g_string_free (resolved_families, false );
779
+ g_hash_table_destroy (seen_families);
772
780
773
781
return ret;
774
782
}
0 commit comments