Skip to content

Commit 98df571

Browse files
Added Cocoa CSS keyword tests #8
1 parent 6abfd9b commit 98df571

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Diff for: changes/1814.misc.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Support for CSS keywords in Windows.
2-
1+
Support for CSS keywords in Windows & Cocoa.

Diff for: cocoa/tests_backend/fonts.py

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from travertino.constants import (
2+
FONT_SIZE_SCALE,
3+
RELATIVE_FONT_SIZE_SCALE,
4+
RELATIVE_FONT_SIZES,
5+
)
6+
17
from toga.fonts import (
28
BOLD,
39
CURSIVE,
@@ -48,6 +54,16 @@ def assert_font_options(self, weight=NORMAL, style=NORMAL, variant=NORMAL):
4854
def assert_font_size(self, expected):
4955
if expected == SYSTEM_DEFAULT_FONT_SIZE:
5056
assert self.font.pointSize == 13
57+
elif isinstance(expected, str):
58+
base_size = 13
59+
if expected in RELATIVE_FONT_SIZES:
60+
parent_size = getattr(self, "_parent_size", base_size)
61+
expected_size = parent_size * RELATIVE_FONT_SIZE_SCALE.get(
62+
expected, 1.0
63+
)
64+
else:
65+
expected_size = base_size * FONT_SIZE_SCALE.get(expected, 1.0)
66+
assert abs(self.font.pointSize - expected_size) < 0.01
5167
else:
5268
assert self.font.pointSize == expected * 96 / 72
5369

0 commit comments

Comments
 (0)