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
Can't use fonts #87
Comments
This could definitely be issue with nativeshell build. Given that some flutter targets litter the root project structure with ephemeral files as a workaround nativeshell runs the actual flutter build in a subfolder inside build folder. It does create symlinks for assets, but there might be cases where it doesn't work correctly. Is there a repository I can reproduce this with? |
Not that I have publicly available, but I think trying to add a custom font to the nativeshell examples might produce the same error. I'll try and see immediately |
Trying to add a custom font to the example project produces this error:
|
That seems like a flutter tool error. Are you sure the pubspec.yaml is correct? Can you post it here? |
My bad, the pubspec.yaml file was not correctly formatted. Trying again on the app template yielded the same error:
|
Can you post the whole pubspec.yaml? Just in case. I'll try to reproduce this tomorrow. |
Sure! name: app_template
description: NativeShell application template
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.12.0-214.0.dev <3.0.0"
dependencies:
flutter:
sdk: flutter
pedantic: ^1.9.2
path: ^1.7.0
cupertino_icons: ^1.0.0
nativeshell:
version: ^0.1.9
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
fonts:
- family: Inter
fonts:
- asset: fonts/Inter/Inter-Regular.ttf
- asset: fonts/Inter/Inter-Bold.ttf
weight: 700
- asset: fonts/Inter/Inter-Black.ttf
weight: 900 |
I can upload the project to a temporary repository if that helps |
Here's the app template with fonts included: https://github.com/wilsonowilson/app_template |
Sure, it won't harm :) Or at least the fonts folder. But I think the problem is that nativeshell only recognizes |
I initially tried with an assets folder. Let me update the example and see if that works. |
I think for now you can manually add the fonts in |
In the flutter sdk? |
No, I meant specifying the font files as flutter assets in pubspec.yaml (https://flutter.dev/docs/development/ui/assets-and-images) |
Something like this should work:
It should force nativeshell build to link the fonts folder. |
Ah, gotcha. I guess if I wanted to use fonts that way, I'd have to use the FontLoader, correct? |
Oh I think I misunderstood. It just helps nativeshell create a link, right? |
No, you should be able to have both in pubspec.yaml
I haven't test this but it should work. The In any case, this is a bug and it should be fixed properly. |
Right. |
Works like a charm! Thanks for the help! |
I can't seem to add a custom font to my project built with nativeshell. Trying to add a font to the pubspec.yaml causes the build to fail with this error:
I have confirmed the path to the asset is correct, and I have used the exact same configuration on another project to be sure.
The text was updated successfully, but these errors were encountered: