在android中使用外部字体 [英] Use external fonts in android

查看:26
本文介绍了在android中使用外部字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用中使用外部字体.我曾尝试使用 AssetManager 添加新的 fonts 但它不起作用.下面是我的代码:

I want to use external fonts in my app. I have tried adding new fonts using AssetManager but it did not work. Below is my code:

Typeface face;

face = Typeface.createFromAsset(getAssets(), "font.otf");

textview.setTypeface(face);

但它没有显示文本...

but its not showing the text...

请帮我解决这个问题.

推荐答案

AFAIK,Android 不支持 OpenType.改用 TrueType 字体.

AFAIK, Android does not support OpenType. Use a TrueType font instead.

更新: 显然现在支持 OpenType,至少在某种程度上是支持的.它最初不受支持,因此您需要在您的应用支持的任何 Android 版本上彻底测试您的字体.

UPDATE: Apparently OpenType is now supported, at least somewhat. It was not supported originally, so you will want to test your font thoroughly on whatever versions of Android your app will support.

这篇关于在android中使用外部字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆