富文本中添加字体选项功能_扑中的字体功能

富文本中添加字体选项功能

A little extra help for styling your text

样式设置方面的一些额外帮助

I recently learned about a little known corner of the Flutter world: Font Features. I’ll share that with you today. Keep it in the back of your mind and when you need it, just do a search for Flutter Font Features. You’ll probably end up back here because there isn’t much out there about Font Features except for the documentation, and even that is a little sparse.

我最近了解了Flutter世界的一个鲜为人知的角落:字体功能。 今天我将与您分享。 记住它,当您需要时,只需搜索Flutter Font Features即可 。 您可能最终会回到这里,因为除文档外,关于Font Features的内容并不多,甚至还很少。

更改字体 (Changing the font)

This article isn’t primarily about changing the font family, but since it is related to fonts, I’ll start by briefly reviewing how to use different fonts in your app.

本文主要不是改变字体,但由于关系到字体,我将简要回顾如何在你的应用程序中使用不同的字体启动。

系统字体 (System fonts)

The default font on Android is Roboto and on iOS it is .SF UI Display or .SF UI Text (SF meaning San Francisco). If you want to use a different font, then you will need to add it to your app.

Android上的默认字体是Roboto ,而iOS上的默认字体是.SF UI Display.SF UI Text (SF表示旧金山)。 如果要使用其他字体,则需要将其添加到您的应用程序中。

Image for post
Roboto font on Android
Android上的Roboto字体
Image for post
.SF UI Text font on iOS
iOS上的.SF UI文本字体

They look the same to me.

他们对我来说看起来一样。

您自己的自定义字体 (Your own custom fonts)

I’ve written before about how to add your own custom font to your project, so I won’t go into detail, but the basic process is the following:

之前我已经写过关于如何向您的项目中添加自己的自定义字体的文章,因此我将不做详细介绍,但是其基本过程如下:

  1. Add a font to your assets folder.

    将字体添加到资产文件夹。

2. Register the font in pubspec.yaml.

2.在pubspec.yaml中注册字体。

flutter:
fonts:
- family: MyFont
fonts:
- asset: assets/my_font.ttf

3. Use the font in your code by specifying the fontFamily.

3.通过指定fontFamily在代码中使用字体。

Text(
'Hello world',
style: TextStyle(
fontFamily: 'MyFont',
),
)
Image for post
Satisfy font
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值