目录
字体文件下载地址:https:fonts.google.com
1.首先设置 pubspec.yaml 文件:C:\Users\user\StudioProjects\myflutter\pubspec.yaml
2.入口程序:C:\Users\user\StudioProjects\myflutter\lib\main.dart
3.局部字体的代码在每个组件中也是只有一条:fontFamily: 'Zhi_Mang_Xing',
示意图:
字体文件下载地址:https://fonts.google.com
1.首先设置 pubspec.yaml 文件:C:\Users\user\StudioProjects\myflutter\pubspec.yaml
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
fonts:
- family: Zhi_Mang_Xing
fonts:
- asset: fonts/Zhi_Mang_Xing/ZhimangXing-Regular.ttf
style: normal
weight: 700 # 100 的整数