Skip to content
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

Web backend font fixes #3035

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Web backend font fixes #3035

merged 2 commits into from
Dec 9, 2024

Conversation

mhsmith
Copy link
Member

@mhsmith mhsmith commented Dec 9, 2024

This fixes the issue mentioned at beeware/briefcase-web-static-template#16 (comment):

Style appears to have been lost from dialogs. The about dialog in Tutorial 0 displays in "browser default serif", not the Shoelace sans-serif default.

It looks like the style sheet simply never set a font on the top-level element, so the browser default was used on any elements which didn't specify their own font. This affected not only dialogs, but also Toga labels.

Also added a dummy Font implementation class, to fix the following error, which I guess may have been introduced by #2937:

  File "/lib/python3.12/site-packages/tutorial/app.py", line 9, in build
    box = toga.Box()
          ^^^^^^^^^^
  File "/lib/python3.12/site-packages/toga/widgets/box.py", line 25, in __init__
    super().__init__(id=id, style=style)
  File "/lib/python3.12/site-packages/toga/widgets/base.py", line 83, in __init__
    self.style.reapply()
  File "/lib/python3.12/site-packages/travertino/declaration.py", line 96, in reapply
    self.apply(style, getattr(self, style))
  File "/lib/python3.12/site-packages/toga/style/pack.py", line 131, in apply
    Font(
  File "/lib/python3.12/site-packages/toga/fonts.py", line 59, in __init__
    self._impl = self.factory.Font(self)
                 ^^^^^^^^^^^^^^^^^
  File "/lib/python3.12/site-packages/toga_web/factory.py", line 91, in __getattr__
    raise NotImplementedError(f"Toga's Web backend doesn't implement {name}")
NotImplementedError: Toga's Web backend doesn't implement Font

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@mhsmith mhsmith requested a review from freakboy3742 December 9, 2024 21:47
@HalfWhitt
Copy link
Contributor

HalfWhitt commented Dec 9, 2024

Also added a dummy Font implementation class, to fix the following error, which I guess may have been introduced by #2937:

Ah, yeah that looks like it is indeed from #2942, because style.reapply() is actually getting called now. I encountered the same issue in Textual and fixed it the same way.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@freakboy3742 freakboy3742 merged commit e9f5760 into beeware:main Dec 9, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants