CentOS7.5---7.9 中文字體匹配錯誤 fontconfig-2.13.0


wps 顯示方正字體錯誤,已經按照如下步驟添加方正字體和windows上的字體:

/usr/share/fonts/目錄下創建FangZheng、Windows文件夾,將相應的ttf、ttc文件放入文件夾中

$ fc-cache && mkfontscale && mkfontdir

 

查看字體支持的中文字體的文件

$ fc-list :lang=zh
    /usr/share/fonts/wps-office/FZXBSJW.TTF: FZXiaoBiaoSong\-B05S:style=Regular
    ......
    /usr/share/fonts/wps-office/FZKANGFW.TTF: FZKangTi\-S07T:style=Regular

正常匹配到中文字體的顯示(其他系統)
$ fc-list :lang=zh
    /usr/share/fonts/wps-office/FZXBSJW.TTF: 方正小標宋簡體,FZXiaoBiaoSong\-B05S:style=Regular
    /usr/share/fonts/wps-office/FZHTK.TTF: 方正黑體_GBK,FZHei\-B01:style=Regular
    /usr/share/fonts/wps-office/FZXBSK.TTF: 方正小標宋_GBK,FZXiaoBiaoSong\-B05:style=Regular
    ......
    /usr/share/fonts/wps-office/FZSSK.TTF: 方正書宋_GBK,FZShuSong\-Z01:style=Regular

看出區別了吧!!! 正常輸出有中文字體名

 

根據中文字體名匹配相應的字體文件

$ fc-match -a <字體名> | head

$ fc-match -a 方正仿宋簡體 | head
$ fc-match -a 方正小標宋簡體 | head
$ fc-match -a 方正仿宋_GBK | head

下面 方正仿宋簡體 沒有匹配到
$ fc-match -a 方正仿宋簡體 | head
    NotoSansCJK-Regular.ttc: "Noto Sans CJK SC" "Regular"
    NotoSansCJK-Medium.ttc: "Noto Sans CJK SC" "Medium"

正常匹配到中文字體的顯示(其他系統)
$ fc-match -a 方正小標宋簡體 | head
    FZXBSJW.TTF: "方正小標宋簡體" "Regular"
    NotoSansCJK-Regular.ttc: "Noto Sans CJK SC" "Regular"
$ fc-match -a 方正仿宋_GBK | head
    FZFSK.TTF: "方正仿宋_GBK" "Regular"
    NotoSansCJK-Regular.ttc: "Noto Sans CJK SC" "Regular"

 

查詢字體文件的相關信息,字體文件中不顯示中文名稱等信息

$ fc-query /usr/share/fonts/wps-office/FZXBSJW.TTF
Pattern has 24 elts (size 32)
    family: "FZXiaoBiaoSong-B05S"(s)
    familylang: "en"(s)
    style: "Regular"(s)
    stylelang: "en"(s)
    fullname: "FZXiaoBiaoSong-B05S"(s)
    fullnamelang: "en"(s)
    slant: 0(i)(s)
    weight: 80(f)(s)
    width: 100(f)(s)
    foundry: "BDFZ"(s)
    file: "/usr/share/fonts/wps-office/FZXBSJW.TTF"(s)
    index: 0(i)(s)
    outline: True(s)
    scalable: True(s)
    charset: 
    ......
    lang: bg|fj|ho|ia|ie|io|kum|nr|om|os|ru|sel|so|ss|st|sw|ts|uz|xh|zh-cn|zh-sg|zu|kj|kwm|ms|ng|rn|rw|sn|za(s)
    fontversion: 0(i)(s)
    capability: "otlayout:hani"(s)
    fontformat: "TrueType"(s)
    decorative: False(s)
    postscriptname: "FZXBSJW--GB1-0"(s)
    color: False(s)
    symbol: False(s)
    variable: False(s)

正常匹配到中文字體的顯示(其他系統)
$ fc-query /usr/share/fonts/wps-office/FZXBSJW.TTF
Pattern has 24 elts (size 32)
    family: "FZXiaoBiaoSong-B05S"(s) "方正小標宋簡體"(s)
    familylang: "en"(s) "zh-cn"(s)
    style: "Regular"(s)
    stylelang: "en"(s)
    fullname: "FZXiaoBiaoSong-B05S"(s) "方正小標宋簡體"(s)
    fullnamelang: "en"(s) "zh-cn"(s)
    slant: 0(i)(s)
    weight: 80(f)(s)
    width: 100(f)(s)
    foundry: "BDFZ"(s)
    file: "/usr/share/fonts/wps-office/FZXBSJW.TTF"(s)
    index: 0(i)(s)
    outline: True(s)
    scalable: True(s)
    charset: 
    ......
    lang: bg|fj|ho|ia|ie|io|kum|nr|om|os|ru|sel|so|ss|st|sw|ts|uz|xh|zh-cn|zh-sg|zu|kj|kwm|ms|ng|rn|rw|sn|za(s)
    fontversion: 0(i)(s)
    capability: "otlayout:hani"(s)
    fontformat: "TrueType"(s)
    decorative: False(s)
    postscriptname: "FZXBSJW--GB1-0"(s)
    color: False(s)
    symbol: False(s)
    variable: False(s)

同樣的查詢,同樣的字體文件,為啥你不輸出中文字體名字啊! 垃圾啊!

 

解決方法(降fontconfig版本):

1.卸載fontconfig-2.13.0

# yum list installed | grep fontconfig
# rpm -e --nodeps fontconfig
# yum list installed | grep fontconfig

 

2.安裝fontconfig-2.10.95

# rpm -ivh fontconfig-2.10.95-11.el7.aarch64.rpm
# rpm -qi fontconfig

 

3.更新字體緩存和索引

# fc-cache && mkfontscale && mkfontdir

 

4.查看字體是否包含中文

# fc-query /usr/share/fonts/wps-office/FZXBSJW.TTF

 

5.查看是否可以匹配到字體

# fc-match -a 方正仿宋簡體 | head
# fc-match -a 方正小標宋簡體 | head
# fc-match -a 方正仿宋_GBK | head

 

6.wps進行查看

# wps 1.doc

 

fontconfig-2.13.1 應該也解決這個問題了,升級過程碰到了其他問題,沒操作成功。 

 

fontconfig降版本的后遺症

/sbin/ldconfig: /lib64/libstdc++.so.6 不是符號鏈接

$ sudo ldconfig -v
$ sudo ln -sf /path/source.so.x.xxx /path/source.so.x

$ ll /lib64/libstdc++.so*
$ sudo ln -sf /lib64/libstdc++.so.6.0.19 /lib64/libstdc++.so.6

 

修改了這個庫啊?  /usr/lib64/libfontconfig.so

ll /usr/lib64/libfontconfig.so*
lrwxrwxrwx. 1 root root     23 Jul 13 23:31 /usr/lib64/libfontconfig.so -> libfontconfig.so.1.11.1
lrwxrwxrwx. 1 root root     22 Aug 20 06:41 /usr/lib64/libfontconfig.so.1 -> libfontconfig.so.1.7.0
-rwxr-xr-x. 1 root root 272064 Aug 24  2018 /usr/lib64/libfontconfig.so.1.7.0

 

關於x86_64平台fontconfig-2.10.95下載

安裝CentOS7.0---7.2系統,通過該系統的yum源來下載fontconfig-2.10.95的rpm包

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM