mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Add basic colrv1 rendering test
This commit is contained in:
@@ -36,6 +36,9 @@ if is_macos:
|
||||
else:
|
||||
from .fontconfig import font_for_family as font_for_family_fontconfig
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.fast_data_types import CTFace, Face
|
||||
|
||||
FontObject = Union[CoreTextFont, FontConfigPattern]
|
||||
current_faces: list[tuple[FontObject, bool, bool]] = []
|
||||
builtin_nerd_font_descriptor: FontObject | None = None
|
||||
@@ -354,15 +357,15 @@ def showcase() -> None:
|
||||
test_render_string('A=>>B!=C', family='Fira Code')
|
||||
|
||||
|
||||
def create_face(path: str) -> 'Union[CTFace, Face]':
|
||||
if is_macos:
|
||||
from kitty.fast_data_types import CTFace
|
||||
return CTFace(path=path)
|
||||
from kitty.fast_data_types import Face
|
||||
return Face(path=path)
|
||||
|
||||
|
||||
def test_render_codepoint(char: str = '😺', path: str = '/t/Noto-COLRv1.ttf', font_size: float = 160.0) -> None:
|
||||
if TYPE_CHECKING:
|
||||
from kitty.fast_data_types import CTFace, Face
|
||||
def create_face(path: str) -> 'Union[CTFace, Face]':
|
||||
if is_macos:
|
||||
from kitty.fast_data_types import CTFace
|
||||
return CTFace(path=path)
|
||||
from kitty.fast_data_types import Face
|
||||
return Face(path=path)
|
||||
f = create_face(path=path)
|
||||
f.set_size(font_size, 96, 96)
|
||||
bitmap, w, h = f.render_codepoint(ord(char))
|
||||
|
||||
@@ -25,7 +25,7 @@ from kitty.fast_data_types import (
|
||||
)
|
||||
from kitty.fonts import family_name_to_key
|
||||
from kitty.fonts.common import FontSpec, all_fonts_map, face_from_descriptor, get_font_files, get_named_style, spec_for_face
|
||||
from kitty.fonts.render import coalesce_symbol_maps, render_string, setup_for_testing, shape_string
|
||||
from kitty.fonts.render import coalesce_symbol_maps, create_face, render_string, setup_for_testing, shape_string
|
||||
from kitty.options.types import Options
|
||||
|
||||
from . import BaseTest, draw_multicell
|
||||
@@ -340,6 +340,14 @@ class Rendering(FontBaseTest):
|
||||
cells = render_string(text)[-1]
|
||||
self.ae(len(cells), sz)
|
||||
|
||||
def test_rendering_colrv1(self):
|
||||
f = create_face(self.path_for_font('twemoji_smiley-cff2_colr_1.otf'))
|
||||
f.set_size(64, 96, 96)
|
||||
for char in '😁😇😈':
|
||||
_, w, h = f.render_codepoint(ord(char))
|
||||
self.assertGreater(w, 64)
|
||||
self.assertGreater(h, 64)
|
||||
|
||||
def test_shaping(self):
|
||||
|
||||
def ss(text, font=None):
|
||||
|
||||
BIN
kitty_tests/twemoji_smiley-cff2_colr_1.otf
Normal file
BIN
kitty_tests/twemoji_smiley-cff2_colr_1.otf
Normal file
Binary file not shown.
Reference in New Issue
Block a user