redhat 6下node-canvas中文乱码解决方法。乱码主要是在安装系统时没有相应的中文字体和freetype支持。只要我们安装这两项即可。
我们实用光盘做为yum源这样方便安装依赖库
//创建光盘挂载目录
1
2
|
mkdir
/yum
mount
/dev/cdrom
/yum
|
//创建本地yum源
1
|
cd
/etc/yum
.repos.d/
|
//备份旧文件
1
|
mv
rhel-
source
.repo rhel-
source
.repo.bak
|
//创建本地源文件
1
|
vi
/etc/yum
.repos.d
/local
.repo
|
//写以下内容到local.repo
1
2
3
4
5
|
[base]
name=linux 6
baseurl=
file
:
///yum
gpgcheck=0
enable
=1
|
//修改yum源的地址
1
|
vi
/usr/lib/python2
.6
/site-packages/yum/yumRepo
.py
|
在上面的文件中找到下面这行
1
|
remote = url +
'/'
+ relative
|
将其改为
1
|
remote =
'/yum'
+ relative
|
配置到这里就完成了
//清理yum,可能会报错,不用管错误
1
|
yum clean
|
//安装中文支持
1
|
yum groupinstall
"Chinese Support"
|
//安装字休
1
|
yum groupinstall Fonts
|
//安装字体支持库
1
2
3
4
|
cd
/yum/Packages
rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm
rpm -ivh freetype-devel-2.3.11-6.el6_2.9.x86_64.rpm
rpm -ivh fontconfig-devel-2.8.0-3.el6.x86_64.rpm
|
//创建中文字体目录
1
|
mkdir
-p
/usr/share/fonts/chinese/TrueType
|
//复制字体文件到刚才创建的目录
1
2
|
cp
SimSun.ttf
/usr/share/fonts/chinese/TrueType
cd
/usr/share/fonts/chinese/TrueType
|
//运行下面三个指令,更新字体
1
2
3
|
mkfontscale
mkfontdir
fc-cache -f -
v
|
//重新编译node-canvas绘图库
补充:
node-canvas在6.3系统上需要使用指定字体时要求字体必须存在而在6.4发现可以使用不存在的字体。