Android 上的默认字体设置 [英] Default font set on Android

查看:82
本文介绍了Android 上的默认字体设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我大多数 Android 设备上的捆绑字体是什么,特别是网页?

就像 :DroidSans.ttf ->Roboto-Regular.ttf, DroidSans-Bold.ttf ->Roboto-Bold.ttf

我是否引用姓氏似乎并不重要(http://jsfiddle.net/9z3tD/9/ 呈现相同).CSS 区分了诸如 serif 和引用的 "serif" 之类的通用关键字,后者指的是名称恰好是serif"的字体;但是 xml 配置没有区别,所以我 猜测 在 android 中的任何一种语法都指的是名称为serif"的字体.但是如果您创建自定义 WebView 并将其配置为将通用关键字映射到其他字体(setSerifFontFamily() 和朋友们.

然后是 fallback_fonts.xml.这些没有名字;例如你不能说font-family:Droid Sans Fallback".
但是所有这些都应该针对其他字体中每个缺失的字形进行尝试.据推测,人们甚至可以使用 "elegant""compact"font-variant 并通过设置文本 lang="ja"?
但是,我根本没有看到 Droid Sans 回退被使用,所以回退可能在 WebKit 中不起作用:-(

<小时>

免责声明:以上适用于使用股票浏览器和/或 Chrome 的股票 Android.我相信它也适用于 WebView(使用默认配置)但尚未测试.

理论上制造商可能会使用其他字体,例如我听说有传言说三星做到了.在实践中所有Android设备上的屏幕截图BrowserStack都有 - 包括三星 - 看着我未经训练的眼睛Roboto 或 Droid,区别只是 android 版本...然而,这里是 Galaxy S3 没有发现别名 Georgiaserif 所以 something 不同.

Firefox 是浏览器以不同方式处理的一个很好的例子 - 他们切换到 打开 Sans and Charis SIL Compact,然后 用 Clear Sans 替换 Open Sans.
完整的配置在 libpref/init/all.js 并且依赖于语言.
据我所知,Firefox 无视 system_fonts.xml 的别名,例如Georgia 生成无字体.
OTOH,旧版本(已测试 30、34)允许字体引用按名称,即使是 Droid Sans Fallback 但这doesn在 FF 36、37 上工作(这 2 个结果用于 http://codepen.io/cben/pen/VYgPEE,使用 Adob​​eBlank 意味着当您看到字符时,使用的是该字体).

<小时>

另请参阅有关应用可用字体的相关答案.

Can anyone tell me what are the bundled fonts on most Android devices, specifically for web pages?

Just like Windows has their bundled fonts or Mac font lists, what are the fonts that come with most Android phones and tablets? Can anyone point to a list on the web?

I'm making web pages and want to set up my CSS to degrade gracefully from using newer fonts to just plain ol' "sans-serif" and "serif" font families. Thx.

解决方案

Expanding upon Grstmo's answer:

system_fonts.xml defines mapping from font-family to actual font files. So let's try these:

<div style="font-family: sans-serif; font-style: normal">Regular</div>
<div style="font-family: sans-serif; font-style: italic">Italic</div>
<div style="font-family: sans-serif; font-weight: bold">Bold</div>
<div style="font-family: sans-serif; font-weight: bold; font-style: italic">Bold-italic</div>

<div style="font-family: sans-serif-light; font-style: normal">Light</div>
<div style="font-family: sans-serif-light; font-style: italic">Light-italic</div>

<div style="font-family: sans-serif-thin; font-style: normal">Thin</div>
<div style="font-family: sans-serif-thin; font-style: italic">Thin-italic</div>

<div style="font-family: sans-serif-condensed; font-style: normal">Condensed regular</div>
<div style="font-family: sans-serif-condensed; font-style: italic">Condensed italic</div>
<div style="font-family: sans-serif-condensed; font-weight: bold">Condensed bold</div>
<div style="font-family: sans-serif-condensed; font-weight: bold; font-style: italic">Condensed bold-italic</div>

<div style="font-family: serif; font-style: normal">Serif Regular</div>
<div style="font-family: serif; font-style: italic">Serif Italic</div>
<div style="font-family: serif; font-weight: bold">Serif Bold</div>
<div style="font-family: serif; font-weight: bold; font-style: italic">Serif Bold-italic</div>

<!-- "Droid Sans" actually gives you Roboto. -->
<div style="font-family: &quot;Droid Sans&quot;; font-style: normal">Droid Sans Regular</div>
<div style="font-family: &quot;Droid Sans&quot;; font-weight: bold">Droid Sans Bold</div>

<div style="font-family: monospace; font-style: normal">Monospace Regular</div>

http://jsfiddle.net/9z3tD/4/ => (tested on android 4.2)

EDIT: "Droid Sans" in the screenshot is clearly Roboto. The config supports it but turns out the underlying file is a simlink: DroidSans.ttf -> Roboto-Regular.ttf, DroidSans-Bold.ttf -> Roboto-Bold.ttf

EDIT: It doesn't seem to matter whether I quote the family names (http://jsfiddle.net/9z3tD/9/ renders the same). CSS distinguishes between generic keywords like serif and quoted "serif" which refers to a font whose name happens to be "serif"; but the xml config makes no distinction so I guess in android either syntax refers to a font whose name is "serif". But there may be a difference if you create a custom WebView and configure it to map generic keywords to other fonts (setSerifFontFamily() and friends).

Then there are fallback_fonts.xml. These have no names; e.g. you CAN'T say font-family: "Droid Sans Fallback".
But all of them are suppossed to be tried for every missing glyph in other fonts. Presumably one can even choose a subset using font-variant of "elegant" or "compact" and by setting text lang="ja"?
However I don't see Droid Sans Fallback being used at all so perhaps fallbacks don't work in WebKit :-(


Disclaimer: The above applies to stock Android, using stock browser and/or Chrome. I believe it also applies to WebView (with default config) but haven't tested.

In theory manufacturers may use other fonts, e.g. I heard rumors Samsung does it. In practice screenshots on all android devices BrowserStack had all — including Samsungs — look to my untrained eyes to be Roboto or Droid, the differences being just android releases... However here is Galaxy S3 caught not aliasing Georgia to serif so something differs.

Firefox is a good example of a browser doing it differently — they switched to Open Sans and Charis SIL Compact, then replaced Open Sans with Clear Sans.
The full config is in libpref/init/all.js and is language-dependent.
As far as I can tell, Firefox disregards the system_fonts.xml's aliases, e.g. Georgia results in a sans font.
OTOH, older versions (tested 30, 34) allowed you to refer to system fonts by name, even to Droid Sans Fallback but this doesn't work on FF 36, 37 (these 2 results are for http://codepen.io/cben/pen/VYgPEE, use of AdobeBlank means that when you see chars, that font was used).


See also relevant answer about fonts available to apps.

这篇关于Android 上的默认字体设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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