playwright服务器截图出现中文乱码
datehoer 8/25/2022 playwright
截图发现出现的问题是一堆小方块。
这里其实显而易见的就是中文乱码。
出现这个问题就是因为服务器没有安装中文字体,所以无法解析。
所以只需要在服务器上安装上对应的中文字体就可以了,首先从本地Windows上随便找一个中文字体。
然后上传到服务器的/usr/share/fonts
文件夹中,之后输入
fc-cache -fv
1
即可
[root@c7 fonts]# fc-cache -fv
/usr/share/fonts: 正在生成缓存,新增缓存内容:0 个字体,2 个目录
/usr/share/fonts/dsa: 正在生成缓存,新增缓存内容:9 个字体,0 个目录
/usr/share/fonts/fonts: 正在生成缓存,新增缓存内容:2 个字体,0 个目录
/usr/share/X11/fonts/Type1: 跳过,无此目录
/usr/share/X11/fonts/TTF: 跳过,无此目录
/usr/local/share/fonts: 跳过,无此目录
/root/.local/share/fonts: 跳过,无此目录
/root/.fonts: 跳过,无此目录
/usr/share/fonts/dsa: 跳过,探测到循环目录
/usr/share/fonts/fonts: 跳过,探测到循环目录
/usr/lib/fontconfig/cache: cleaning cache directory
/root/.cache/fontconfig: not cleaning non-existent cache directory
/root/.fontconfig: not cleaning non-existent cache directory
/usr/bin/fc-cache-64: 缓存生成成功
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
再次尝试截图会发现出现正常的文字了。