0

I made many different approaches, I read many topics here as Stack Overflow and no matter what I do, this will not work. This, so far at least just apply to iOS. I did't teste on Android yet. I just followed the official doc at https://flutter.dev/docs/cookbook/design/fonts

I've this on my pubspec

enter image description here

My directory structure looks like this:

enter image description here

and my code looks like this:


child: Text('HELLO',
            style: TextStyle(
            fontSize: 20, color: Colors.black, fontFamily: 'Handel')

This is my 1st time using custom fonts on Flutter.

I made several attemps like...

  • flutter clean
  • flutter run --enable-software-rendering
  • Reinstall
  • Execute on simulator and on a real device

Any suggestion about more steps that I can try ? Or maybe I forgot some important step ?

The most curios is that this project has a web version 100% done and I just copied/pasted the sniped of pubspec and copied/pasted the fonts folder. The web version works pretty good.

Marco Jr
  • 6,496
  • 11
  • 47
  • 86
  • Does this answer your question? [How to change the default font family in Flutter](https://stackoverflow.com/questions/64237031/how-to-change-the-default-font-family-in-flutter) – OMi Shah Nov 03 '22 at 10:55

2 Answers2

0

I found the issue... The font file has something that Mac OS calls "Minor Issues". Such issues with the font is okay if you are using Flutter Web, however on Flutter on iOS, this is not not work.

enter image description here

So, basically it's necessary to fix the font file. I will keep the answer here to avoid to see someone lost 14H of your life on it.

Download and install CR8 Software Solutions free font editor for Mac (or Windows) called Type Light from here:

https://www.cr8software.net/typelight.html

  1. Open your problem ttf or otf font in the editor (choose File then Open).
  2. Choose Font then Rename Font then click RENAME button (without making any changes).
  3. Save your font (choose File then Save As).

Now it's done ! Just close your app from the simulator and run it again.

Marco Jr
  • 6,496
  • 11
  • 47
  • 86
0

You can set pubspac set font path like this:

 fonts:
    - family:Minion
      fonts:
        - asset: assets/fonts/Minion.otf
keyur
  • 151
  • 13