EnsembleUI / ensemble-react

BSD 3-Clause "New" or "Revised" License
15 stars 1 forks source link

Support custom fonts #762

Open evshi opened 1 month ago

evshi commented 1 month ago

Is your feature request related to a problem? Please describe. Fonts are important part of branding and UX. Customers have the ability to upload their own fonts or reference open source fonts like google fonts.

Describe the solution you'd like https://docs.ensembleui.com/theme-and-styling/custom-fonts

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here. EDL implemented in Flutter runtime: https://github.com/EnsembleUI/ensemble/issues/1505

sagardspeed2 commented 2 weeks ago

@evshi

Based on the solution mentioned in https://stackoverflow.com/questions/41676054/how-to-add-fonts-to-create-react-app-based-projects and the way Flutter Ensemble registers fonts in the pubspec.yaml file, we can simplify the process of adding custom fonts to our project.

If we place our index.css file in the public folder and add our fonts to the public folder as well, then register the fonts in index.css using the @font-face rule, we won’t need to make any additional changes to our implementation. The custom font family will automatically be supported in the theme file.

In index.css ( this will be moved to public folder, so fonts src path will also change according to that )

image

In theme.yaml

image

I added fonts in public folder

image

and here is the output

image

where the button us using the custom font family

give your thoughts on this and if I am doing anything wrong here or missed anything ?

evshi commented 2 weeks ago

@sagardspeed2 in ensemble fonts are fetched from firebase they aren't always built into the project. So you need to find a way to load fonts at runtime. Please discuss with @justEhmadSaeed