字体图标库font-awesome出现了一些奇怪的图标

3

我在 Android 应用程序中使用了 Font Awesome,但它没有显示真正的图标。相反,我得到了一些奇怪的文本。例如,我期望看到arrow-left,但实际上得到的是下面图片所示的内容。

enter image description here

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中,<string name="fa_arrow_left">&#xf060;</string>

fa.ttf文件位于 main > assets > fonts

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

无论如何,请保持愉快☺

1个回答

1

啊!解决了。实际上,我使用的版本中没有那个字符的代码。从fontawesome网站下载了最新的字体,问题得到了解决。解决这个问题花了整整一天的时间。感谢所有在背景中努力帮助我的人。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接