如何检索机器人提供/安装的字体列表?机器人、字体、列表

2023-09-12 02:02:28 作者:ゝ*‵敗類氾濫

在Java中我会做这样的事情:

In Java I would do something like:

java.awt.GraphicsEnvironment ge = 
                      java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts(); 

有一个Android等同?

is there an Android equivalent?

推荐答案

马克·墨菲的回答两者的Andr​​oid开发者邮件列表:

Taken from Mark Murphy's answer on the Android Developers mailing list:

http://developer.android.com/reference/android/graphics/Typeface.html

有只有三种字体:正常   (德罗伊德桑),衬线(Droid的衬线),和   等宽(德罗伊德桑单声道)。

There are only three fonts: normal (Droid Sans), serif (Droid Serif), and monospace (Droid Sans Mono).

虽然可能有其他字体   埋在WebKit的地方,他们   似乎是不可访问   WebKit的外部开发者。 : - (

While there may be additional fonts buried in WebKit somewhere, they appear to be inaccessible to developers outside of WebKit. :-(

其他唯一的字体是任何一个TrueType那些你捆绑你的应用程序。

The only other fonts are any TrueType ones you bundle with your application.

编辑:Roboto是排在了Android 4.0的新字体。你可以使用这个库项目在所有版本中使用该回API级别4 https://github.com/mcalliph/roboto-text-view

Roboto is a new font which came in with Android 4.0. You can use this library project to use it in all versions back to API level 4 https://github.com/mcalliph/roboto-text-view