@@ -184,11 +184,13 @@ FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1,
184184 m_dirty = true ;
185185}
186186
187- static void ft_glyph_warn (FT_ULong charcode)
187+ static void ft_glyph_warn (FT_ULong charcode, FT_String *family_name )
188188{
189+ const char * name = (family_name != NULL )?family_name:" UNAVAILABLE" ;
189190 PyObject *text_helpers = NULL , *tmp = NULL ;
191+
190192 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 ))) {
192194 goto exit;
193195 }
194196exit:
@@ -207,7 +209,7 @@ ft_get_char_index_or_warn(FT_Face face, FT_ULong charcode, bool warn = true)
207209 return glyph_index;
208210 }
209211 if (warn) {
210- ft_glyph_warn (charcode);
212+ ft_glyph_warn (charcode, face-> family_name );
211213 }
212214 return 0 ;
213215}
@@ -515,8 +517,6 @@ void FT2Font::set_text(
515517 char_to_font, glyph_to_font, codepoints[n], flags,
516518 charcode_error, glyph_error, false );
517519 if (!was_found) {
518- ft_glyph_warn ((FT_ULong)codepoints[n]);
519-
520520 // render missing glyph tofu
521521 // come back to top-most font
522522 ft_object_with_glyph = this ;
@@ -582,7 +582,6 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
582582 bool was_found = load_char_with_fallback (ft_object_with_glyph, final_glyph_index, glyphs, char_to_font,
583583 glyph_to_font, charcode, flags, charcode_error, glyph_error, true );
584584 if (!was_found) {
585- ft_glyph_warn (charcode);
586585 if (charcode_error) {
587586 throw_ft_error (" Could not load charcode" , charcode_error);
588587 }
@@ -609,7 +608,7 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
609608
610609bool FT2Font::get_char_fallback_index (FT_ULong charcode, int & index) const
611610{
612- FT_UInt glyph_index = FT_Get_Char_Index (face, charcode);
611+ FT_UInt glyph_index = ft_get_char_index_or_warn (face, charcode);
613612 if (glyph_index) {
614613 // -1 means the host has the char and we do not need to fallback
615614 index = -1 ;
@@ -642,17 +641,15 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
642641 FT_Error &glyph_error,
643642 bool override = false )
644643{
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 );
647646 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))) {
650648 return false ;
651649 }
652650
653651 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))){
656653 return false ;
657654 }
658655
@@ -667,7 +664,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
667664 parent_glyphs.push_back (thisGlyph);
668665 return true ;
669666 }
670-
671667 else {
672668 for (size_t i = 0 ; i < fallbacks.size (); ++i) {
673669 bool was_found = fallbacks[i]->load_char_with_fallback (
@@ -677,6 +673,9 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
677673 return true ;
678674 }
679675 }
676+ for (size_t j=family_names.size ()-1 ; j>0 ; --j){
677+ ft_glyph_warn (charcode, family_names[j]);
678+ }
680679 return false ;
681680 }
682681}
0 commit comments