温馨提示×

centos liboffice字体缺失咋办

小樊
40
2026-09-15 12:02:14
栏目: 智能运维

在 CentOS 上使用 LibreOffice 时遇到字体缺失(比如打开 Word/PDF 显示方块、字体不对、排版错乱),一般可以从下面几方面解决。


一、先确认问题类型

  1. 系统是纯命令行还是带桌面?

    • 有桌面(GNOME / KDE):可直接装字体
    • 无桌面(服务器):只影响文件转换,不影响系统
  2. 缺失的是哪种字体?

    • 常见缺失:
      • Windows 字体(宋体、微软雅黑、Times New Roman)
      • 中文字体(黑体、楷体)
      • PDF 嵌入字体但未带

二、安装常用字体(最常见解法)

1️⃣ 安装中文字体(推荐)

sudo yum install -y wqy-zenhei-fonts wqy-microhei-fonts

sudo yum install -y cjkuni-uming-fonts cjkuni-ukai-fonts

安装后刷新字体缓存:

fc-cache -fv

2️⃣ 安装 Windows 字体(解决 Word 排版问题)

如果 LibreOffice 打开 .docx 字体不对:

方法一:复制 Windows 字体

从 Windows 复制:

C:\Windows\Fonts

常用:

  • simsun.ttc(宋体)
  • msyh.ttf(微软雅黑)
  • times.ttf(Times New Roman)

上传到 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

3️⃣ 安装 Liberation 字体(替代 Windows 字体)

sudo yum install -y liberation-fonts

LibreOffice 会自动用:

  • Liberation Sans → Arial
  • Liberation Serif → Times New Roman

三、验证字体是否生效

fc-list | grep -i "yahei"
fc-list :lang=zh

在 LibreOffice 中:

  • 工具 → 选项 → 字体
  • 查看是否识别新字体

四、LibreOffice 无界面转换时字体缺失

如果你用:

libreoffice --headless --convert-to pdf file.docx

确保:

  • 字体已安装
  • 执行用户有字体访问权限
  • 重启一次 LibreOffice 或系统

五、PDF 打开字体缺失

  • 建议源文件嵌入字体
  • 或在 CentOS 安装对应字体
  • 可用 evince / okular 测试

六、常见坑总结

❌ 只装了字体但没 fc-cache
❌ 字体权限不是 644
❌ 用 root 装字体但普通用户运行 LibreOffice
❌ 服务器没中文字体导致中文变方块


如果你能告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 是否有桌面
  • 缺失的是哪种字体(截图或字体名)

我可以给你更精确的命令

0