@@ -157,6 +157,9 @@ def _get_composed_font(cls, base_font, size=None):
157157 try :
158158 # Do not mutate builtin font fallback: builtins may live in readonly memory.
159159 emoji_font .fallback = base_font
160+ emoji_font .base_line = cls ._font_base_line (base_font )
161+ emoji_font .underline_position = cls ._font_underline_position (base_font )
162+ emoji_font .underline_thickness = cls ._font_underline_thickness (base_font )
160163 except Exception as err :
161164 cls ._debug ("compose fallback set failed: " + repr (err ))
162165 return base_font
@@ -308,13 +311,14 @@ def _safe_getcwd(cls):
308311
309312 @classmethod
310313 def _imgfont_path_cb (cls , font , unicode_cp , unicode_next , offset_y , user_data ):
314+ baseline = cls ._font_base_line (font )
311315 if unicode_cp == CP_VARIATION_SELECTOR_TEXT or unicode_cp == CP_VARIATION_SELECTOR_EMOJI :
312- offset_y .__dereference__ (0 )
316+ offset_y .__dereference__ (- baseline )
313317 return cls ._get_empty_imgfont_src (cls ._font_pixel_height (font ))
314318
315319 src = cls ._get_emoji_src (unicode_cp , cls ._font_pixel_height (font ))
316320 if src is not None :
317- offset_y .__dereference__ (0 )
321+ offset_y .__dereference__ (- baseline )
318322 return cls ._get_scaled_imgfont_src (src , cls ._font_pixel_height (font ))
319323
320324 cls ._log_unknown_emoji_codepoint (unicode_cp )
@@ -380,6 +384,27 @@ def _font_pixel_height(cls, font):
380384 except Exception :
381385 return 1
382386
387+ @classmethod
388+ def _font_base_line (cls , font ):
389+ try :
390+ return int (font .base_line )
391+ except Exception :
392+ return 0
393+
394+ @classmethod
395+ def _font_underline_position (cls , font ):
396+ try :
397+ return int (font .underline_position )
398+ except Exception :
399+ return 0
400+
401+ @classmethod
402+ def _font_underline_thickness (cls , font ):
403+ try :
404+ return int (font .underline_thickness )
405+ except Exception :
406+ return 0
407+
383408 @classmethod
384409 def _get_scaled_imgfont_src (cls , src , target_height ):
385410 key = (src , target_height )
0 commit comments