css - 无法在 NativeScript 中使用字体图标

标签 css fonts nativescript

我从 fontello 下载了一个 tff 图标 - 我将其重命名为 discard - 并将其放在 app 文件夹内的 fonts 文件夹中一个 Vanilla ts nativescript 元素:

enter image description here

在我的 xml 中有这个标签:

<Label id="label" text="1U+F1F8" class="discard" />

app.css 像这样:

.btn {
    font-size: 18;
}

.discard {
    font-family: "discard";
    font-weight: bold;
}

标签在应该显示图标时显示文本?

enter image description here

文本是unicode tff 文件,我认为这是 docs 中所见的要求- 从 Mac 上的字体书中获得:

enter image description here

到目前为止,我也只在 android 上尝试过 - 因为我只需要正确设置文件名。

可能是什么问题?

我在我的原始元素中使用 react-nativescript - 但希望首先让它在 vanilla ts 中工作。最好有一种方法可以在 后面的代码中实现,然后我可以在 react-nativescript 中使用。

最佳答案

应用程序将 Unicode 解释为文本,您需要将其设置为 Unicode 文字,如下所示:

<Label text="{{ trashGlyph }}" class="discard"/>

并在您的 ViewModel 中定义 trashGlyph:

trashGlyph = "\uf1f8"

或者,如果使用 Angular - 这应该可以完成工作:

<Label id="label" [text]="'\uf1f8'" class="discard" />

关于css - 无法在 NativeScript 中使用字体图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57976473/

相关文章:

javascript - NativeScript 1.7 中的 UIActionSheet

html - Chrome 中的悬停不透明度问题

css - 只是想给输入文本加粗字体

html - 使用 CSS 将单一字体应用于整个网站

html 特殊字符 UTF-8

css - Nativescript 如何溢出文本?

css - 响应图像背景

javascript - 滚动时如何制作视差侧边栏

php - Wordpress 标题 PHP 中有 2 种不同的字体?

javascript - 如何在nativescript中动态加载自定义组件?