在 CentOS 上使用 LibreOffice 时遇到字体缺失(比如打开 Word/PDF 显示方块、字体不对、排版错乱),一般可以从下面几方面解决。
系统是纯命令行还是带桌面?
缺失的是哪种字体?
sudo yum install -y wqy-zenhei-fonts wqy-microhei-fonts
或
sudo yum install -y cjkuni-uming-fonts cjkuni-ukai-fonts
安装后刷新字体缓存:
fc-cache -fv
如果 LibreOffice 打开 .docx 字体不对:
从 Windows 复制:
C:\Windows\Fonts
常用:
上传到 CentOS:
sudo mkdir -p /usr/share/fonts/windows
sudo cp *.ttf *.ttc /usr/share/fonts/windows/
sudo chmod 644 /usr/share/fonts/windows/*
fc-cache -fv
sudo yum install -y liberation-fonts
LibreOffice 会自动用:
fc-list | grep -i "yahei"
fc-list :lang=zh
在 LibreOffice 中:
如果你用:
libreoffice --headless --convert-to pdf file.docx
确保:
evince / okular 测试❌ 只装了字体但没 fc-cache
❌ 字体权限不是 644
❌ 用 root 装字体但普通用户运行 LibreOffice
❌ 服务器没中文字体导致中文变方块
如果你能告诉我:
我可以给你更精确的命令。