linux系统添加中文字体后不生效

CentOS7.5—7.9 中文字体匹配错误问题 fontconfig-2.13.0
CentOS7.5—7.9系统fontconfig默认版本为2.13.0,这个版本字体服务会导致中文字体匹配错误,系统上即使添加中文字体成功,也无法使用中文字体
/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-2.13.0不输出中文字体名字啊
解决方法(降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(fontconfig-2.10.95下载,可安装CentOS7.0—7.2系统,通过该系统的yum源来下载fontconfig-2.10.95的rpm包)
#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

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

原文地址:http://www.manongjc.com/detail/25-aetcdrhmtiauyin.html

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值