-
-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support CSS font size keywords #3242
base: main
Are you sure you want to change the base?
Conversation
Add: CSS keyword constants to Travertino and update core style component #17 Update: testbed to handle CSS keywords and improve coverage #24 Add: CSS font size keywords and tests for iOS #5 #10 (#18) Add: windows CSS keyword support and tests #6 #11 (#22) Add: Cocoa CSS keywords support and tests #3 #8 (#23) Add: Gtk css keywords support and tests #4 #9 (#27) Fix: remove xxxl keywords #29 Docs: add css keywords to style reference (#33) Add: Android support for CSS font keywords and tests #2 #7 (#28) ---------- Co-authored-by: Phoebe Schwartz <[email protected]> Co-authored-by: KlaraLindemalm <[email protected]> Co-authored-by: Jacmol <[email protected]> Co-authored-by: carltestar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks very thorough.
fix: remove all relative_font_size instances and update documentation --------- Co-authored-by: phoebe <[email protected]>
Hello! We've made the changes to remove the xxxl size and the relative sizes. It passes all of the CI checks but for some reason, it is not passing the docs build. Any ideas as to why? |
It looks like it might be related to RTD's recent switchover to their new management UI. Your original docs builds seems to have fallen into a crack somewhere; I've manually restarted the build, and it seems to have worked. Apologies for the confusion! |
try: | ||
Font("Comic Sans", None) | ||
assert False, "Should have raised TypeError" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use pytest.raises
here as well?
|
||
**Initial value:** System default | ||
|
||
The size of the font to be used, in :ref:`CSS points <css-units>`. | ||
The size of the font to be used. Can be specified in three ways: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better not to include a number: it's easy for it to become incorrect if the list is edited in the future.
The size of the font to be used. Can be specified in three ways: | |
The size of the font to be used. Can be specified in the following ways: |
else ( | ||
f"{self.size}" if self.size in ABSOLUTE_FONT_SIZES else f"{self.size}pt" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else ( | |
f"{self.size}" if self.size in ABSOLUTE_FONT_SIZES else f"{self.size}pt" | |
) | |
else f"{self.size}" if self.size in ABSOLUTE_FONT_SIZES | |
else f"{self.size}pt" |
@@ -93,6 +97,13 @@ def __init__(self, interface): | |||
|
|||
if self.interface.size == SYSTEM_DEFAULT_FONT_SIZE: | |||
font_size = NSFont.systemFontSize | |||
elif ( | |||
isinstance(self.interface.size, str) | |||
and self.interface.size in ABSOLUTE_FONT_SIZES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ABSOLUTE_FONT_SIZES
check is unnecessary:
- The string must already be in
ABSOLUTE_FONT_SIZES
, because it was validated when thefont_size
property was assigned. - Even the string wasn't in
ABSOLUTE_FONT_SIZES
, we still wouldn't want to format it as{self.font_size}pt
.
This also applies to the similar checks in several other backends, and in pack.py.
and self.interface.size in ABSOLUTE_FONT_SIZES | ||
): | ||
base_size = NSFont.systemFontSize | ||
font_size = base_size * FONT_SIZE_SCALE.get(self.interface.size, 1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string was validated when the font_size
property was assigned, so it must be in FONT_SIZE_SCALE
. We can therefore use []
rather than get
.
This also applies to all the other uses of get
in this PR.
} | ||
|
||
LARGER = "larger" | ||
SMALLER = "smaller" | ||
FONT_SIZE_SCALE_FACTOR = 1.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This factor isn't being used anymore.
Added backend support for CSS font-size keywords to Android, Cocoa, iOS, GTK, and Windows and updated the core and travertino testing suites. Includes updated documentation.
Fixes #1814
PR Checklist: