多语言字体顺序问题请教

系统字体配置、中文显示和输入法问题
回复
头像
52Hz
帖子: 3
注册时间: 2016-05-16 9:18
系统: debian 8

多语言字体顺序问题请教

#1

帖子 52Hz » 2016-05-16 10:17

我配置了字体文件,想现实当浏览日文网页的时候使用日文的字体,当我浏览的是中文或是其它语言网站时就用使用中文和其实语言的正字写法字体显示。保持sans的最高优先级字体为noto sans serif的字体noto serif,目的是要避免非英文字体显示英文字母 。
以下是我的配置文件。请忽略noto cjk字体英文部分相同这一点!
现在如果浏览日文wiki使用的是noto sans sc跟我想要的效果不一样。
请大神指点一下是哪里错了 谢谢大神

日文语言字体选择60-lang-ja-jp.conf

代码: 全选

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  
 <match target="pattern">
  <test name="lang" compare="contains">
   <string>ja</string>
  </test>
  <test qual="any" name="family">
   <string>sans-serif</string>
  </test>
  <edit name="family" mode="append" binding="same">
   <string>Noto Sans JP</string>
  </edit>
 </match>
 
</fontconfig>
mode=append 是为了不要替换掉第一优先的字体。现实英文字体总是在第一位

中文语言字体选择60-lang-zh-cn.conf

代码: 全选

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  
  <match target="pattern">
  <test name="lang" compare="contains">
   <string>zh-cn</string>
  </test>
  <test qual="any" name="family">
   <string>sans-serif</string>
  </test>
  <edit name="family" mode="append" binding="same">
   <string>Noto Sans SC</string>
  </edit>
 </match>
 
</fontconfig>
font.conf

代码: 全选

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="pattern">
  <edit name="dpi" mode="assign" >
   <double>102</double>
  </edit>
 </match>
 <match target="font">
  <edit name="embeddedbitmap">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="autohint">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <test compare="more" name="weight">
   <const>medium</const>
  </test>
  <edit mode="assign" name="autohint">
   <bool>false</bool>
  </edit>
 </match>
 
<!-- Default sans-serif font -->
 <match target="pattern">
  <test qual="any" name="family">
   <string>sans-serif</string>
  </test>
  <edit name="family" mode="prepend" binding="strong">
   <string>Source Sans Pro</string>  
  </edit>
 </match>

<!-- Default serif font -->
 <match target="pattern">
  <test qual="any" name="family">
   <string>serif</string>
  </test>
  <edit name="family" mode="prepend" binding="strong">
   <string>Source Serif Pro</string>
  </edit>
 </match>
 
<!-- Default monospace font -->
 <match target="pattern">
  <test qual="any" name="family">
   <string>monospace</string>
  </test>
  <edit name="family" mode="prepend" binding="strong">
   <string>Source Code Pro</string>
  </edit>
 </match>
 
 <dir>~/.fonts</dir>
 
</fontconfig>
头像
52Hz
帖子: 3
注册时间: 2016-05-16 9:18
系统: debian 8

Re: 多语言字体顺序问题请教

#2

帖子 52Hz » 2016-05-16 20:48

:Cry 没有人吗?这个问题好困挠我。
简单点讲就是想实现在浏览网页的时候根据lang的属性让网页优先显示该地区的正字写法的字体。


大神帮帮忙。 :Cry :Cry :Cry :Cry
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 多语言字体顺序问题请教

#3

帖子 poloshiao » 2016-05-16 22:14

Ubuntu 的 作業系統字型設定 是一個繁雜且細心的程序
每個登入的桌面進程 有自己的字型設定
每個瀏覽器 也有自己的字型設定
每個網頁 也有自己的字型設定
通常
網頁的字型設定 會覆蓋 瀏覽器 的字型設定
瀏覽器 的字型設定 會覆蓋 桌面進程 的字型設定
桌面進程 的字型設定 會覆蓋 作業系統 的字型設定
所以想要一個公式 就達到你的期望 不容易
另一個說法 這是多元的選擇

網頁的字型設定 除非網頁是你自己寫的 否則你無法影響 網頁的字型設定
但是 你可以試試在 瀏覽器 設定你的字型

1. 請提供你使用的瀏覽器
2. 終端機
locale
把結果複製貼上來
头像
52Hz
帖子: 3
注册时间: 2016-05-16 9:18
系统: debian 8

Re: 多语言字体顺序问题请教

#4

帖子 52Hz » 2016-05-16 22:51

poloshiao 写了:Ubuntu 的 作業系統字型設定 是一個繁雜且細心的程序
每個登入的桌面進程 有自己的字型設定
每個瀏覽器 也有自己的字型設定
每個網頁 也有自己的字型設定
通常
網頁的字型設定 會覆蓋 瀏覽器 的字型設定
瀏覽器 的字型設定 會覆蓋 桌面進程 的字型設定
桌面進程 的字型設定 會覆蓋 作業系統 的字型設定
所以想要一個公式 就達到你的期望 不容易
另一個說法 這是多元的選擇

網頁的字型設定 除非網頁是你自己寫的 否則你無法影響 網頁的字型設定
但是 你可以試試在 瀏覽器 設定你的字型

1. 請提供你使用的瀏覽器
2. 終端機
locale
把結果複製貼上來
系统版本 debian 8.4
浏览器 版本 iceweasel 38.8.0(debian下的firefox浏览器 只是名字不一样)

locale设置

代码: 全选

love@debian:~$ locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
fc-match 匹配结果

代码: 全选

love@debian:~$ fc-match -s "sans:lang=ja"  
SourceSansPro-Regular.otf: "Source Sans Pro" "Regular"
NotoSansSC-Medium.otf: "Noto Sans SC" "Medium"
NotoSansJP-Medium.otf: "Noto Sans JP" "Medium"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"
DejaVuSans-Oblique.ttf: "DejaVu Sans" "Oblique"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
n019003l.pfb: "Nimbus Sans L" "Regular"
wqy-zenhei.ttc: "文泉驿正黑" "Regular"
VL-Gothic-Regular.ttf: "VL Gothic" "regular"
NanumGothic.ttf: "NanumGothic" "Regular"
UnDotum.ttf: "UnDotum" "Regular"
wqy-microhei.ttc: "文泉驿微米黑" "Regular"
DroidSansFallbackFull.ttf: "Droid Sans Fallback" "Regular"
FreeSans.ttf: "FreeSans" "нормален"
SourceCodePro-Medium.otf: "Source Code Pro" "Medium"
mplus-1c-medium.ttf: "M+ 1c" "medium"
NotoSansTC-Medium.otf: "Noto Sans TC" "Medium"
NotoSansKR-Medium.otf: "Noto Sans KR" "Medium"
HanaMinA.ttf: "HanaMinA" "Regular"
HanaMinB.ttf: "HanaMinB" "Regular"
wqy-zenhei.ttc: "文泉驿等宽正黑" "Regular"
FreeMono.ttf: "FreeMono" "нормален"
FreeSerif.ttf: "FreeSerif" "нормален"
opens___.ttf: "OpenSymbol" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
NanumMyeongjo.ttf: "NanumMyeongjo" "Regular"
LexiGulim.ttf: "LexiGulim" "Regular"
TibetanMachineUni.ttf: "Tibetan Machine Uni" "Regular"
Tinos-Regular.ttf: "Tinos" "Regular"
GenBasR.ttf: "Gentium Basic" "Regular"
NotoEmoji-Regular.ttf: "Noto Emoji" "Regular"
DroidSansEthiopic-Regular.ttf: "Droid Sans Ethiopic" "Regular"
GenR102.ttf: "Gentium" "Regular"
wasy10.ttf: "wasy10" "Normal"
MathJax_AMS-Regular.otf: "MathJax_AMS" "Regular"
MathJax_Fraktur-Regular.otf: "MathJax_Fraktur" "Regular"
MathJax_Main-Regular.otf: "MathJax_Main" "Regular"
MathJax_Size1-Regular.otf: "MathJax_Size1" "Regular"
MathJax_Size4-Regular.otf: "MathJax_Size4" "Regular"
MathJax_WinChrome-Regular.otf: "MathJax_WinChrome" "Regular"
MathJax_WinIE6-Regular.otf: "MathJax_WinIE6" "Regular"
cmmi10.ttf: "cmmi10" "Regular"
NanumBarunGothic.ttf: "NanumBarunGothic" "Regular"
ukai.ttc: "AR PL UKai CN" "Book"
ukai.ttc: "AR PL UKai HK" "Book"
ukai.ttc: "AR PL UKai TW MBE" "Book"
UnGraphic.ttf: "UnGraphic" "Regular"
s050000l.pfb: "Standard Symbols L" "Regular"
LiberationSansNarrow-Regular.ttf: "Liberation Sans Narrow" "Regular"
uming.ttc: "AR PL UMing CN" "Light"
UnGraphicBold.ttf: "UnGraphic" "Bold"
LiberationSans-Italic.ttf: "Liberation Sans" "Italic"
LiberationSansNarrow-Italic.ttf: "Liberation Sans Narrow" "Italic"
测试用的是wikipedia的网站 切换不同语言进行测试的
系统的字体配置就是我发上来的那三个。
我是在$XDG_CONFIG_HOME/fontconfig/conf.d 和 $XDG_CONFIG_HOME/fontconfig/fonts.conf 下配置的字体文件
/etc/fonts/下的文件都没动过。
浏览器的默认字体分别是sans-serif serif mono
感谢大神回复 :em63
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 多语言字体顺序问题请教

#5

帖子 poloshiao » 2016-05-17 5:43

浏览器 版本 iceweasel 38.8.0(debian下的firefox浏览器 只是名字不一样)
1. http://www.pcworld.com/article/3036509/ ... -thaw.html
'Iceweasel' will be renamed 'Firefox' as relations between Debian and Mozilla thaw
it looks like the next release of Debian will use the name “Mozilla Firefox” for its browser, as well as the logo.
下一個 Debian 版本將恢復稱 Iceweasel 為 firefox 並且使用 firefox 的圖示
wikipedia

2. 網頁使用 UTF-8
頁面開發者 / 頁面原始碼
2-1. 英文
https://en.wikipedia.org/wiki/Main_Page
<html lang="en" dir="ltr" class="client-nojs">
<meta charset="UTF-8"/>
2-2. 日本語
https://ja.wikipedia.org/wiki/%E3%83%A1 ... C%E3%82%B8
<html lang="ja" dir="ltr" class="client-nojs">
<meta charset="UTF-8"/>
2-3. 中文
https://zh.wikipedia.org/wiki/Wikipedia ... 6%E9%A1%B5
<html lang="zh" dir="ltr" class="client-nojs">
<meta charset="UTF-8"/>

3. Ubuntu 預設 UTF-8
locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
3-1. 你的電腦 作業系統 Locale 使用 zh_CN.UTF-8
日文语言字体选择60-lang-ja-jp.conf
中文语言字体选择60-lang-zh-cn.conf
font.conf
系统的字体配置就是我发上来的那三个。
/etc/fonts/下的文件都没动过。
/etc/fonts/下的文件都没动过。
3-2. 查證一下 這些是不是 systemwide 的設定 ?
3-2-1. 查證一下 會不會 被 3-1 locale / 3-3 設定 覆蓋
我是在$XDG_CONFIG_HOME/fontconfig/conf.d 和 $XDG_CONFIG_HOME/fontconfig/fonts.conf 下配置的字体文件
3-3. 這是 桌面進程設定
3-3-1. 查證一下 這會不會 覆蓋 3-1 locale / 3-2 的設定
浏览器的默认字体分别是sans-serif serif mono
3-4. 這通常是浏览器的 <html lang="en"> 的設定
3-4-1. 查證一下 這會不會 覆蓋 3-1 locale / 3-2 / 3-3 的設定
3-4-2. 這裡所謂的覆蓋 是指同一個環境變數的變數值 被變更
想实现在浏览网页的时候根据lang的属性让网页优先显示该地区的正字写法的字体。
瀏覽器 的字型設定 會覆蓋 桌面進程 的字型設定
3. 試試 在不更改 systemwide 的設定 / 桌面進程設定 前提下
根據 lang 屬性 更換瀏覽器 iceweasel 的字型設定
3-1. 你可以先試試
根據 <html lang="en"> / <html lang="ja"> / <html lang="zh">
手動設定 iceweasel 字型設定
首選項 / 內容 / 語言 / 字體及顏色
3-2. 有疑問 歡迎再貼文
回复