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

Custom Fonts Not Working in Flet Web Apps Using CanvasKit #4521

Open
1 task done
nssnaresh5 opened this issue Dec 7, 2024 · 0 comments
Open
1 task done

Custom Fonts Not Working in Flet Web Apps Using CanvasKit #4521

nssnaresh5 opened this issue Dec 7, 2024 · 0 comments
Labels
bug Something isn't working platform: web Specific to the web platform

Comments

@nssnaresh5
Copy link

Duplicate Check

Describe the bug

Custom fonts defined using page.fonts and Theme.font_family are not applied correctly in web apps when rendered with CanvasKit. Instead, the default sans-serif font is used.

Code sample

Code
page.fonts = {
    "CustomFont": "/assets/fonts/YourFont-Regular.ttf"
}
page.theme = ft.Theme(font_family="CustomFont")
page.add(ft.Text("This is a test", font_family="CustomFont"))

To reproduce

  1. Define a custom font in the page.fonts property
    page.fonts = {
    "CustomFont": "/assets/fonts/YourFont-Regular.ttf"
    }
    page.theme = ft.Theme(font_family="CustomFont")

  2. Add a Text widget with the custom font:
    page.add(ft.Text("This is a test", font_family="CustomFont"))

  3. Run the app in the web browser
    ft.app(main, assets_dir="assets", view=ft.AppView.WEB_BROWSER)

Expected behavior

The Text widget should display the specified custom font.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

11

Flet version

Name: flet Version: 0.24.1 Summary: Flet for Python - easily build interactive multi-platform apps in Python Home-page: https://flet.dev Author: Appveyor Systems Inc. Author-email: [email protected] License: Apache-2.0 Location: C:\Users\NS1\PycharmProjects\EPC3X.venv\Lib\site-packages Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog Required-by: flet-web

Regression

No, it isn't

Suggestions

Expected Behavior: The Text widget should display the specified custom font.

Actual Behavior: The Text widget displays the default sans-serif font.

Additional Context:

The issue occurs when running the app with ft.AppView.WEB_BROWSER.
The font works correctly in desktop apps.

Logs

Logs
[Paste your logs here]

Additional details

No response

@ndonkoHenri ndonkoHenri added bug Something isn't working platform: web Specific to the web platform labels Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform: web Specific to the web platform
Projects
None yet
Development

No branches or pull requests

2 participants