Font_family does not work in Browser #4121
Unanswered
ClearSafety
asked this question in
Q&A
Replies: 2 comments 2 replies
-
The "Failed to parse font family 'internal'" error should go away if you specify the
note the differing path to your sample. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Hi. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Duplicate Check
Describe the bug
Trying to customize the font in the Text control, but the font_family property does not work if one opens the app in browser. However, opening it with a normal window, the font_family is applied normally.
The same issue was analysed in #1794. But different from there, I'm not using a font from web, but from the system and from the folder assets/fonts.
It doesn't work even if I set web_renderer=ft.WebRenderer.HTML.
It's interesting that analysing the Console in the Inspection, I found two errors (vide attached)
I attached some pictures to showing the problem and the app working properly outside the WEB mode.
Code sample
Code
Version 2
import flet as ft
def main(page: ft.Page):
page.fonts = {'internal': 'assets/fonts/ELEPHNT.ttf'}
page.add(
ft.Text('Hello World!', font_family='Arial', size=50),
ft.Text('Hello World!', font_family='Verdana', size=50),
ft.Text('Hello World!', font_family='Tahoma', size=50),
ft.Text('Hello World!', font_family='Elephant', size=50),
ft.Text('Hello World!', style=ft.TextStyle(font_family='Elephant', size=50)),
ft.Text('Hello World!', style=ft.TextStyle(font_family='internal', size=50)),
)
ft.app(target=main, view=ft.AppView.WEB_BROWSER, web_renderer=ft.WebRenderer.HTML)
To reproduce
Expected behavior
Display the text according to the font applied to it.
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
Windows 11 Pro
Flet version
0.24.1
Regression
No, it isn't
Suggestions
No response
Logs
Logs
Additional details
No response
Beta Was this translation helpful? Give feedback.
All reactions