Android 版 Google Fonts 使用入门

此页面由 Cloud Translation API 翻译。

首页

产品

Google Fonts

支持

Android 版 Google Fonts 使用入门

使用集合让一切井井有条

根据您的偏好保存内容并对其进行分类。

Android O 和 AndroidX 库增加了对

可下载字体。

Google Fonts 是 Google Play 服务中的一个字体提供程序。这意味着

Google Fonts 可用于 Android 设备上的原生应用!

我可以使用哪些字体?

整个 Google Fonts 开源集合!请访问

前往 https://fonts.google.com 进行浏览。

支持哪些 Android 版本?

我们的提供商支持 Jelly Bean(API 级别 16)及更高版本。这代表了 95%以上的

的野外 Android 设备

(平台信息中心)。

可使用 AndroidX 库中的 API 进行访问

(androidx.core)

或 Android O(API 级别 26)。

该从何处入手!

请查看

演示版应用。

在 Android Studio 3.0 中试用(屏幕截图演示)

以声明方式或程序化方式使用 Google Fonts,如

可下载字体。

查询格式

如需向 Google Fonts 提供程序请求字体,请使用以下查询格式:

参数

是否必需?

Range

数据类型

默认值

name

来自 Fonts.google.com 的任何系列

字符串

width

> 0

float

100

重量

(0, 1000) 不包括

int

400

斜体

[0, 1](含)

float

0

尽力而为

true/false

布尔值

true

如果 besteffort 为 true,并且您的查询指定了一个有效的系列名称,但

不支持所请求的宽度/重量/斜体值,我们将返回最佳尺寸

匹配。例如,

权重为 900 的 Oswald 会返回

奥斯瓦尔德的体重为 700 分。

示例查询:

name=Lobster # Lobster, 400 weight

name=Lato&weight=100 # Lato, 100 weight

name=Open Sans&weight=800&italic=1 # Open Sans, 800 weight, italic

安全

出于安全考虑,您必须指定公开

请求字体的提供程序Android Studio 会将

正确签名。请参阅

添加证书。

如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。

最后更新时间 (UTC):2025-07-25。

[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eAndroid now supports downloadable fonts, including the entire Google Fonts collection, via Android O and AndroidX Library.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Fonts are readily available for native Android apps through a Font Provider in Google Play Services, supporting Android Jelly Bean (API level 16) and above.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access Google Fonts declaratively or programmatically and easily customize font attributes like width, weight, and italic style.\u003c/p\u003e\n"],["\u003cp\u003eA built-in "best effort" feature ensures the closest font match if the specific requested style is unavailable within the chosen font family.\u003c/p\u003e\n"],["\u003cp\u003eFor security, applications utilizing the Google Fonts provider must specify the provider's signature, a process simplified within Android Studio.\u003c/p\u003e\n"]]],[],null,["Android O and AndroidX Library add support for\n[Downloadable Fonts](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts.html).\n\nGoogle Fonts is shipping a Font Provider in Google Play Services. This means\nGoogle Fonts are available to native apps on Android devices!\n\nWhich fonts can I use?\n\nThe entire Google Fonts Open Source collection! Visit\n\u003chttps://fonts.google.com\u003e to browse.\n\nWhat versions of Android are supported?\n\nOur provider supports Jelly Bean (API level 16) and up. This represents 95%+ of\nof Android devices in the wild\n([platform dashboard](https://developer.android.com/about/dashboards/index.html#Platform)).\nIt can be accessed using APIs in AndroidX Library\n([androidx.core](https://developer.android.com/jetpack/androidx/releases/core))\nor Android O (API level 26).\n\nHow can I get started!\n\n- Check out the [demo app](https://github.com/android/user-interface-samples/tree/main/DownloadableFonts).\n- Try it in Android Studio 3.0 ([walkthrough with screenshots](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts.html#via-android-studio))\n- Use Google Fonts declaratively or programmatically as shown in [Downloadable Fonts](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts.html).\n\nQuery Format\n\nTo request a font from the Google Fonts provider use the following query format:\n\n| Parameter | Required? | Range | Data Type | Default value |\n|------------|-----------|----------------------------------|-----------|---------------|\n| name | Yes | Any family from fonts.google.com | string | |\n| width | No | \\\u003e 0 | float | 100 |\n| weight | No | (0, 1000) exclusive | int | 400 |\n| italic | No | \\[0, 1\\] inclusive | float | 0 |\n| besteffort | No | true/false | boolean | true |\n\nIf besteffort is true and your query specifies a valid family name but the\nrequested width/weight/italic value is not supported we will return the best\nmatch we can find within the family. For example, a request for\n[Oswald](https://fonts.google.com/specimen/Oswald) at weight 900 would return\nOswald at weight 700.\n\nSample queries: \n\n name=Lobster # Lobster, 400 weight\n name=Lato&weight=100 # Lato, 100 weight\n name=Open Sans&weight=800&italic=1 # Open Sans, 800 weight, italic\n\nSecurity\n\nFor security you must specify the signature of the application exposing the\nprovider you want to request fonts from. Android Studio will add\nthe correct signature for you. See\n[adding certificates](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts.html#adding-certificates)."]]