【问题标题】:Font-awesome is showing some weird iconsFont-awesome 显示一些奇怪的图标
【发布时间】:2018-06-05 02:09:34
【问题描述】:

我在 Android 应用中使用了很棒的字体。它没有显示真正的图标。相反,我得到了一些奇怪的文字。例如,我期待看到arrow-left,而我得到的是这个(如图所示)。

android:text="@string/fa_arrow_left"

userTV.setTypeface(TypeFaces.get(this.getApplicationContext(), "fa"));

这里是 TypeFaces 类。

public class TypeFaces {
    private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();

    public static Typeface get(Context c, String name) {
        synchronized (cache) {
            if (!cache.containsKey(name)) {
                Typeface t = Typeface.createFromAsset(
                        c.getAssets(),
                        String.format("fonts/%s.ttf", name)
                );
                cache.put(name, t);
            }
            return cache.get(name);
        }
    }
}

在strings.xml中&lt;string name="fa_arrow_left"&gt;&amp;#xf060;&lt;/string&gt;

fa.ttf 放在main &gt; assets &gt; fonts

https://github.com/FortAwesome/Font-Awesome/blob/master/fonts/fontawesome-webfont.ttf下载字体

不管怎样

【问题讨论】:

    标签: android encoding font-awesome android-typeface


    【解决方案1】:

    啊!解决了。实际上,该字符的代码在我使用的版本中不可用。从 fontawesome 网站下载了最新的字体,它工作正常。解决这个问题花了一整天的时间。感谢所有在后台尝试帮助我的人。

    【讨论】:

      猜你喜欢
      • 2022-12-25
      • 1970-01-01
      • 1970-01-01
      • 2019-10-24
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多