google 字体包是否下载设备上的字体?
Does google font package download the fonts on the device?
在我的 flutter Android 应用程序中,首次启动时,该应用程序显示默认字体,然后一秒钟后它更改为我使用的 google 字体 flutter 包中的字体。我想我的问题是,字体会在应用程序首次启动时立即下载吗?如果可以,字体是否可以与应用程序一起编译,因此不需要在设备上下载。
是的,google_fonts 在运行时通过 HTTP 获取它们。这对于开发目的来说真的很好,但是当你选择你想要坚持使用的字体时,按照他们的建议去做,就是下载字体并将它放在资产文件夹中,这样,包不会下载任何东西,而是从您的资产文件夹中取出它。
更多信息:read this.
The google_fonts package will automatically use matching font files in
your pubspec.yaml's assets (rather than fetching them at runtime via
HTTP). Once you've settled on the fonts you want to use:
Download the font files from https://fonts.google.com. You only need
to download the weights and styles you are using for any given family.
Move those fonts to a top-level app
directory (e.g. google_fonts).
Ensure that you have listed the folder (e.g. google_fonts/) in your
pubspec.yaml under assets.
Note: Since these files are listed as assets, there is no need to list
them in the fonts section of the pubspec.yaml. This can be done
because the files are consistently named from the Google Fonts API (so
be sure not to rename them!)
在我的 flutter Android 应用程序中,首次启动时,该应用程序显示默认字体,然后一秒钟后它更改为我使用的 google 字体 flutter 包中的字体。我想我的问题是,字体会在应用程序首次启动时立即下载吗?如果可以,字体是否可以与应用程序一起编译,因此不需要在设备上下载。
是的,google_fonts 在运行时通过 HTTP 获取它们。这对于开发目的来说真的很好,但是当你选择你想要坚持使用的字体时,按照他们的建议去做,就是下载字体并将它放在资产文件夹中,这样,包不会下载任何东西,而是从您的资产文件夹中取出它。
更多信息:read this.
The google_fonts package will automatically use matching font files in your pubspec.yaml's assets (rather than fetching them at runtime via HTTP). Once you've settled on the fonts you want to use:
Download the font files from https://fonts.google.com. You only need to download the weights and styles you are using for any given family. Move those fonts to a top-level app directory (e.g. google_fonts).
Ensure that you have listed the folder (e.g. google_fonts/) in your pubspec.yaml under assets.
Note: Since these files are listed as assets, there is no need to list them in the fonts section of the pubspec.yaml. This can be done because the files are consistently named from the Google Fonts API (so be sure not to rename them!)