macOS: Fix a character that cannot be rendered in any font causing font fallback for all subsequent characters that cannot be rendered in the main font to fail

Fixes #799
This commit is contained in:
Kovid Goyal
2018-09-04 14:21:36 +05:30
parent f5cc2fd8ad
commit 55f457caf4
4 changed files with 31 additions and 2 deletions

View File

@@ -2,10 +2,13 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import sys
import unittest
from kitty.constants import is_macos
from kitty.fast_data_types import (
DECAWM, sprite_map_set_layout, sprite_map_set_limits, test_render_line,
test_sprite_position_for, wcwidth
DECAWM, get_fallback_font, sprite_map_set_layout, sprite_map_set_limits,
test_render_line, test_sprite_position_for, wcwidth
)
from kitty.fonts.box_drawing import box_chars
from kitty.fonts.render import render_string, setup_for_testing, shape_string
@@ -106,3 +109,16 @@ class Rendering(BaseTest):
s.draw('\ufe0f')
self.ae((s.cursor.x, s.cursor.y), (2, 4))
self.ae(str(s.line(s.cursor.y)), '\u2716\ufe0f')
@unittest.skipUnless(is_macos, 'Only macOS has a Last Resort font')
def test_fallback_font_not_last_resort(self):
# Ensure that the LastResort font is not reported as a fallback font on
# macOS. See https://github.com/kovidgoyal/kitty/issues/799
from io import StringIO
orig, buf = sys.stderr, StringIO()
sys.stderr = buf
try:
self.assertRaises(ValueError, get_fallback_font, '\U0010FFFF', False, False)
finally:
sys.stderr = orig
self.assertIn('LastResort', buf.getvalue())