Flutter-如何获得默认系统字体?

发布于 2025-01-23 17:34:19 字数 612 浏览 6 评论 0原文

我在flutter应用程序中使用自定义字体:

return MaterialApp (
      theme: ThemeData(
        fontFamily: "MyFont" 
      ) 
   )

但是在一个应用程序中,我需要使用“系统字体”。这对于iOS(SF Pro)尤其重要。如果我正确理解,这是iOS的系统字体。但是,如果我已经在应用程序级别使用“自定义字体”,我该如何使用“系统字体”?

我尝试了:

final fontFamily = DefaultTextStyle.of(context).style!.fontFamily;

但是此代码返回“ myfont”。

另外,我尝试从苹果网站。但是图像中只有一个大SF-pro.ttf(8MB)文件。不-sfpro-regular.ttf,sfpro-semibold.ttf ... flutter不支持.otf文件。

如何解决这个问题?我会感激的任何建议

I using custom font for my Flutter app:

return MaterialApp (
      theme: ThemeData(
        fontFamily: "MyFont" 
      ) 
   )

but in one place of application I need to use "system font". this is especially important for iOS (Sf Pro). If I understand correctly, this is the system font for iOS. But how can I use "system font" if I already use "custom font" at application level?

I tried:

final fontFamily = DefaultTextStyle.of(context).style!.fontFamily;

But this code return "MyFont".

also I tried importing from apple site. but there is only one big SF-Pro.ttf(8Mb) file inside the image. Not - SFPro-Regular.ttf, SFPro-SemiBold.ttf ... Flutter does not support .otf files.

How to solve this problem? any advice I will be grateful

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文