【问题标题】:difficulties to "fontFamily" with regard to the wordpress plugin ACF (Advanced Custom Fields) in Flutter App ...(newbie)关于 Flutter App 中 wordpress 插件 ACF(高级自定义字段)的“fontFamily”困难......(新手)
【发布时间】:2021-03-12 05:41:34
【问题描述】:

不幸的是,我无法在我的颤振应用程序中以所需的字体显示 wordpress 插件 ACF (https://www.advancedcustomfields.com/) + (https://de.wordpress.org/plugins/acf-to-rest-api/) 的文本行,不幸的是我也不知道如何解决这个问题。不幸的是,在论坛中只发现了对我没有真正帮助的东西,也许有人知道你的建议?

这是api与对应文字样式集成的方式,貌似不行

  factory PostModel.fromJson(Map<String, dynamic> json, CategoryModel category, { List bookmarks = const [] }) {
    int id = int.parse(json['id'].toString());
    final postAuthor = json['author_info']['display_name'].toString();
    String secondTitle = json['acf']['second_title'].toString();
    final postTitle = _getTitle(json['title']['rendered']);
    final postExcerpt = json['excerpt']['rendered'].toString();
    String header =
        '<h4 id="second_title" fontFamily: "Storopia" >$secondTitle</h4>' +
            '<h3 fontFamily: "Storopia">$postTitle</h3>' +
            postExcerpt.replaceAll(
                '</p>', '<h5 fontFamily: "Storopia">Von $postAuthor</h5></p>');

这是我在页面显示中包含它的方式,在这种情况下也是文本样式,但这也不起作用:-(,即使我在两个地方都有它,不幸的是没有成功...... .

          /// ACF Fields (HTML)
          Html(
            data: widget.post.header,
            style: {
              "p": Style(
                fontFamily: "Storopia",
                fontSize: FontSize(14),
                color: isDark ? Colors.white : Colors.black,
                fontWeight: FontWeight.normal,
              ),
            },
          ),

很遗憾,上述acf字段没有以所需的字体显示,如果我对问题或类似的问题有小错误,请耐心等待,希望您了解问题可能出在哪里,希望可以解决。 ..感谢您的阅读...

【问题讨论】:

    标签: wordpress flutter advanced-custom-fields


    【解决方案1】:

    检查您是否安装了fontFamily: 安装在您的pubspec.yaml 文件中。它应该看起来像这样。这是一个示例,而不是您的确切字体,因此请注意可能因您而异

      fonts:
        - family: Amaranth // In Your Case this should be Storopia
          fonts:
            - asset: assets/fonts/Amaranth-Regular.ttf
            - asset: assets/fonts/Amaranth-Bold.ttf
            - asset: assets/fonts/Amaranth-BoldItalic.ttf
            - asset: assets/fonts/Amaranth-Italic.ttf
    

    如果你有它,请确保你的工作区中有字体的 .ttf 文件。如果也存在,请检查您是否在fonts: 下使用了正确的拼写和大写以及正确的路径和扩展名。 如果这也不能解决问题,请检查您是否在尝试包含字体系列的 Wordpress 文件中输入了正确的拼写。

    【讨论】:

    • 它已正确集成在 pubspec 中,因为该字体在应用程序的其余部分中正确工作?‍♂️,我不得不写 ^^,但感谢您指出可能的错误来源..
    【解决方案2】:

    已找到解决方案...只需将其添加到 MaterialApp

        theme: ThemeData(
          textTheme: TextTheme(
            bodyText2: TextStyle(color: Colors.black,fontFamily: "your font"),
    

    【讨论】:

      猜你喜欢
      • 2018-07-11
      • 1970-01-01
      • 2018-08-15
      • 2019-04-11
      • 2018-03-25
      • 1970-01-01
      • 2012-08-10
      • 1970-01-01
      • 2012-11-26
      相关资源
      最近更新 更多