設定預設字型和 WebKitGTK+ 問題 - Linux

Skylar DavisLinda avatar
By Skylar DavisLinda
at 2015-10-06T17:30

Table of Contents


我想要使用的字型是:

sans-serif: Cantarell -> Source Han Sans TW -> Noto Sans CJK TC
monospace: DejaVu Sans Mono -> Source Han Sans TW -> Noto Sans CJK TC

希望能優先使用最左邊的字型,找不到字才往右邊找。


-----------------------------------------------------------------------------
於是我在 ~/.config/fontconfig/fonts.conf 加了這些來設定 sans-serif:

<match target="pattern">
<test name="family" compare="eq">
<string>sans-serif</string>
</test>
<edit name="family" mode="assign" binding="strong">
<string>Cantarell</string>
<string>Source Han Sans TW</string>
<string>Noto Sans CJK TC</string>
</edit>
</match>

加了之後在 GNOME Shell、GTK+、Qt 裡看起來效果都很好,都有照我想要的順序使用。
-----------------------------------------------------------------------------


-----------------------------------------------------------------------------
結果在 WebKitGTK+ 中,遇到用類似這樣 CSS 設定字形的網頁(例如 GitHub):

font-family: Consolas, monospace;

會直接把 Consolas 對應到 Cantarell 而用 Cantarell 顯示。

目前我的做法是:

<match target="pattern">
<test name="family" compare="eq">
<string>Consolas</string>
</test>
<edit name="family" mode="assign" binding="strong">
<string>monospace</string>
</edit>
</match>

可是如果要對每個在網頁上可能用到的字型都寫這段感覺很麻煩,請問有更好的做法嗎?
-----------------------------------------------------------------------------


-----------------------------------------------------------------------------
後來我也想用一樣的方法設定 monospace:

<match target="pattern">
<test name="family" compare="eq">
<string>monospace</string>
</test>
<edit name="family" mode="assign" binding="strong">
<string>DejaVu Sans Mono</string>
<string>Source Han Sans TW</string>
<string>Noto Sans CJK TC</string>
</edit>
</match>

可是 WebKitGTK+ 遇到網頁要使用 monospace 字型(例如用 <code>)還是繼續用
AR PL UMing TW 之類的字型當中文字型,請問這有辦法修改嗎?

這段我用 pango-view 測試是有用的,但是 WebKitGTK+ 卻好像完全把它忽略了。
-----------------------------------------------------------------------------

WebKit Inspector 現在也是用 Cantarell 顯示各種原始碼 ......


--
Tags: Linux

All Comments

請問嵌入式系統新手推薦書籍?

Iris avatar
By Iris
at 2015-10-06T07:24
大家好: 因為跳槽到BSP的開發 對很多底層的開發不太了解 但又不得其門而入atatand#34; 請問有推薦的書籍提供一些基本的常識嗎? 像是UART.SPI等BUS的基本運作行為這類的書籍嗎? 謝謝 - ...

有人真的拿 raspberry pi 當伺服器嗎?

Frederic avatar
By Frederic
at 2015-10-05T21:51
※ 引述《suyuan (碩源)》之銘言: : 一個有18650備用電力的電源供應器 這個我找不到 Made by wolflord/ NCR18650B*4+BMS+Booster+20W5V Adpter=1000NTD : USB-SATA RAID控制器 我查到的一組要3300 Board Only ...

Git 刪除檔案

Mia avatar
By Mia
at 2015-10-05T18:46
不好意思 想請問一下 我最近需要把一個檔案數很多的project push進git中 因為local端的檔案更動非常多 因此我們決定先切一個branch再把code push進去 我切好branch之後 因為更動檔案過多 也不是全部都是我改的 加上其實我並沒有太多使用git 的經驗 所以就沒想太多直接用 ...

有人真的拿 raspberry pi 當伺服器嗎?

Agnes avatar
By Agnes
at 2015-10-05T16:24
: → kenduest: pi 這類認真說不大適合外接硬碟,個人誠心建議不要這樣 10/04 13:43 : → kenduest: 拿當作 NAS 這類用途真是令人冒冷汗 10/04 13:43 : → kenduest: 這樣搞根本就是不穩定更別說效能.. ...

Bind9 delegation子網域 forwarders

Necoo avatar
By Necoo
at 2015-10-05T14:34
因為正在學習Bind9,所以練習架子網域,要設定一個子網域給另一台伺服器管理 結果是有架成功 不過有個疑問 就是我的zone要設定forwarders { };才能ping通子網域內的A zone and#34;test.comand#34; { type master; ...