mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-07-10 09:43:26 +00:00
Merge branch 'color-emoji-test-robust' of https://github.com/Strykar/kitty
Some checks are pending
CI / Linux (python=3.13 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.11 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.13 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.11 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
This commit is contained in:
commit
ba6b652850
1 changed files with 18 additions and 19 deletions
|
|
@ -392,28 +392,27 @@ class Rendering(FontBaseTest):
|
|||
|
||||
def test_color_emoji_not_shrunk(self):
|
||||
# Regression test for https://github.com/kovidgoyal/kitty/issues/10144.
|
||||
# fontconfig encodes the pixel-size fixup of fixed-size color faces (such
|
||||
# as Noto Color Emoji, a ~109px bitmap strike) as FC_MATRIX. That scale
|
||||
# must not reach the cairo font matrix, where glyph size is owned by
|
||||
# cairo_set_font_size() + fit_cairo_glyph(); applying it there shrinks the
|
||||
# glyph by the fixup factor (requested_px / strike_px), and fit_cairo_glyph()
|
||||
# only shrinks so it never grows it back (ee937bdd1b). The shrink ranges
|
||||
# from ~9x at tiny cells to ~1x near the strike; at 48pt/96dpi (~64px) the
|
||||
# bug gives ~0.28 coverage versus ~0.84 when correct.
|
||||
# fontconfig gives fixed-size color faces (e.g. Noto Color Emoji) a
|
||||
# pixel-size fixup encoded as FC_MATRIX. That scale must not reach the
|
||||
# cairo font matrix used for color glyphs; applying it shrinks color emoji
|
||||
# to a dot (ee937bdd1b). Render the same font two ways at the same size:
|
||||
# from its fontconfig descriptor, which carries the fixup matrix, and from
|
||||
# its file path, which does not. A correct build renders both at the same
|
||||
# size; the bug shrinks the descriptor one. Comparing the two is
|
||||
# environment-independent since only the matrix differs.
|
||||
if is_macos:
|
||||
self.skipTest('this is a fontconfig FC_MATRIX issue, not present on macOS')
|
||||
self.skipTest('FC_MATRIX is a fontconfig feature, not used on macOS')
|
||||
from kitty.fonts.fontconfig import fc_match
|
||||
emoji = fc_match('emoji', False, False, 0)
|
||||
if not (emoji.get('color') and emoji.get('matrix')):
|
||||
# Only a fixed-size color face that fontconfig gives a fixup matrix can
|
||||
# trigger this. A scalable COLR emoji font has none, so a pass there
|
||||
# would be a false negative rather than a real check.
|
||||
desc = dict(fc_match('emoji', False, False, 0))
|
||||
if not (desc.get('color') and desc.get('matrix')):
|
||||
self.skipTest('no fixed-size color emoji font with a fontconfig fixup matrix')
|
||||
cells = render_string('\U0001F40D', 'monospace', 48.0, 96.0)[2]
|
||||
pixels = array.array('I', b''.join(cells))
|
||||
coverage = sum(1 for p in pixels if p) / max(len(pixels), 1)
|
||||
del cells, pixels
|
||||
self.assertGreater(coverage, 0.3, f'color emoji coverage {coverage:.2f} too low, likely shrunk (#10144)')
|
||||
with_matrix = face_from_descriptor(desc)
|
||||
with_matrix.set_size(64, 96, 96)
|
||||
without_matrix = create_face(desc['path'])
|
||||
without_matrix.set_size(64, 96, 96)
|
||||
_, mw, mh = with_matrix.render_codepoint(0x1F40D)
|
||||
_, rw, rh = without_matrix.render_codepoint(0x1F40D)
|
||||
self.assertGreater(mh, 0.5 * rh, f'color emoji shrunk by FC_MATRIX: {mh}px vs {rh}px (#10144)')
|
||||
|
||||
def test_shaping(self):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue