Android P Preview 1 中的字體變化
先來一則去年的舊聞。去年的文章開頭,我就期望 Google 能將 Noto Color Emoji(blob 樣式)和 Android O emoji 分開來維護。然而不久後,Google 就將新設計的 Android O emoji 提交到 Noto Color Emoji 的 GitHub 倉庫了。Blob 黨眞的是可以放棄了,因爲我已轉用 Emoji One。
fonts.xml
is still alive
Google 在 Android O 的 fonts.xml
裏面註釋到
The file, and the font files it refers to, will be renamed and/or moved out from their respective location in the next Android release, and/or the format or syntax of the file may change significantly.
但看起來在 Android P Preview 1,fonts.xml
的並沒有甚麼巨大的改版。
內建 Noto Serif CJK
也許你已經用安裝 Android P 的 Pixel 電話瀏覽過維基百科了。是的,Android P 內建了思源宋體的 Google 發行版本 — — Noto Serif CJK 的 Regular 字重。
但是 Google,你爲甚麼不把 Noto Serif CJK 的全字重都放進系統鏡像,又爲甚麼遲遲不把 Noto Sans CJK(思源黑體的 Google 發行版本)的字重補全呢?
新增 fallbackFor
屬性
Android P 中的 Noto Serif CJK 支援,實際上就是利用新增的 fallbackFor
屬性實現的。一直以來,Android 的回退字型都是無法標註字體風格的,這導致「Roboto 回退到 Noto Sans CJK、Noto Serif 回退到 Noto Serif CJK」這類需求是無法實現的,因爲 serif 字型衹有一個槽位,到底是要 Noto Serif 還是 Noto Serif CJK,還請你自行斟酌。
但新增的 fallbackFor
屬性很好地解決了這個問題(Google Git)。請看系統 serif 字型設定:
再看中日韓文回退 serif 字型的設定:
這樣,在使用 serif 風格字型的情形下,系統就會回退到標註爲 serif 風格的字型,而不受 Noto Sans CJK 等缺省風格的字型的影響。
Android P 利用新增的 fallbackFor
屬性,爲十多種語言新增了 serif 風格的字型。
多個語言共用同一字型設定
Android P 的 fonts.xml
中顯示出,lang
屬性已經可以指向多個 locale,包括萬年 TODO 的 Bopo(Bopomofo,即注音符號)也已合併至繁體中文的字型設定中(Google Git):
寫在末尾
Google 還在 Android P Preview 1(Pixel 鏡像)的 UI 上大幅使用其自家品牌字體 — — Google Sans(前 Product Sans)。不過考慮到 Google Sans 的授權類型,Google 不可能把這個字體提交到 AOSP 社區。因此本文不對這個字體的情況作進一步介紹。