@@ -184,11 +184,13 @@ FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1,
184
184
m_dirty = true ;
185
185
}
186
186
187
- static void ft_glyph_warn (FT_ULong charcode)
187
+ static void ft_glyph_warn (FT_ULong charcode, FT_String *family_name )
188
188
{
189
+ const char * name = (family_name != NULL )?family_name:" UNAVAILABLE" ;
189
190
PyObject *text_helpers = NULL , *tmp = NULL ;
191
+
190
192
if (!(text_helpers = PyImport_ImportModule (" matplotlib._text_helpers" )) ||
191
- !(tmp = PyObject_CallMethod (text_helpers, " warn_on_missing_glyph" , " k " , charcode))) {
193
+ !(tmp = PyObject_CallMethod (text_helpers, " warn_on_missing_glyph" , " (k, s) " , charcode, name ))) {
192
194
goto exit ;
193
195
}
194
196
exit :
@@ -207,7 +209,7 @@ ft_get_char_index_or_warn(FT_Face face, FT_ULong charcode, bool warn = true)
207
209
return glyph_index;
208
210
}
209
211
if (warn) {
210
- ft_glyph_warn (charcode);
212
+ ft_glyph_warn (charcode, face-> family_name );
211
213
}
212
214
return 0 ;
213
215
}
@@ -515,8 +517,6 @@ void FT2Font::set_text(
515
517
char_to_font, glyph_to_font, codepoints[n], flags,
516
518
charcode_error, glyph_error, false );
517
519
if (!was_found) {
518
- ft_glyph_warn ((FT_ULong)codepoints[n]);
519
-
520
520
// render missing glyph tofu
521
521
// come back to top-most font
522
522
ft_object_with_glyph = this ;
@@ -582,7 +582,6 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
582
582
bool was_found = load_char_with_fallback (ft_object_with_glyph, final_glyph_index, glyphs, char_to_font,
583
583
glyph_to_font, charcode, flags, charcode_error, glyph_error, true );
584
584
if (!was_found) {
585
- ft_glyph_warn (charcode);
586
585
if (charcode_error) {
587
586
throw_ft_error (" Could not load charcode" , charcode_error);
588
587
}
@@ -609,7 +608,7 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
609
608
610
609
bool FT2Font::get_char_fallback_index (FT_ULong charcode, int & index ) const
611
610
{
612
- FT_UInt glyph_index = FT_Get_Char_Index (face, charcode);
611
+ FT_UInt glyph_index = ft_get_char_index_or_warn (face, charcode);
613
612
if (glyph_index) {
614
613
// -1 means the host has the char and we do not need to fallback
615
614
index = -1 ;
@@ -642,17 +641,15 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
642
641
FT_Error &glyph_error,
643
642
bool override = false )
644
643
{
645
- FT_UInt glyph_index = FT_Get_Char_Index (face, charcode);
646
-
644
+ FT_UInt glyph_index = ft_get_char_index_or_warn (face, charcode, false );
645
+ family_names. push_back (face-> family_name );
647
646
if (glyph_index || override ) {
648
- charcode_error = FT_Load_Glyph (face, glyph_index, flags);
649
- if (charcode_error) {
647
+ if ((charcode_error=FT_Load_Glyph (face, glyph_index, flags))) {
650
648
return false ;
651
649
}
652
650
653
651
FT_Glyph thisGlyph;
654
- glyph_error = FT_Get_Glyph (face->glyph , &thisGlyph);
655
- if (glyph_error) {
652
+ if ((glyph_error= FT_Get_Glyph (face->glyph , &thisGlyph))){
656
653
return false ;
657
654
}
658
655
@@ -667,7 +664,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
667
664
parent_glyphs.push_back (thisGlyph);
668
665
return true ;
669
666
}
670
-
671
667
else {
672
668
for (size_t i = 0 ; i < fallbacks.size (); ++i) {
673
669
bool was_found = fallbacks[i]->load_char_with_fallback (
@@ -677,6 +673,9 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
677
673
return true ;
678
674
}
679
675
}
676
+ for (size_t j=family_names.size ()-1 ; j>0 ; --j){
677
+ ft_glyph_warn (charcode, family_names[j]);
678
+ }
680
679
return false ;
681
680
}
682
681
}
0 commit comments