如何在 Alpine Linux 上安装 Microsoft True Type 字体?

saw*_*303 9 ttf alpine-linux

我想使用 Alpine Linux 和 LibreOffice 创建一个 Docker 图像来呈现 PDF 文档。LibreOffice 源文件使用微软的 Times New Roman 字体。

如何apk在 Alpine Linux 上安装 Microsoft 字体?是否有与 Ubuntus 等效的数据包apt install ttf-mscorefonts-installer

更新 1:

同时,我找到了一个名为的包[msttcorefonts-installer][1],它似乎提供了我正在寻找的东西。当我尝试使用 Alpine Linux 3.7 安装它时,apk add msttcorefonts-installer-3.6-r2出现以下错误:

ERROR: unsatisfiable constraints:
  msttcorefonts-installer-3.6-r2 (missing):
    required by: world[msttcorefonts-installer-3.6-r2]
Run Code Online (Sandbox Code Playgroud)

Mik*_*jær 29

正如您发现自己的那样,该软件包在 Alpine 3.7 中称为msstcorefonts-installer

安装后,您会收到警告:

  • 使用 root 权限运行“update-ms-fonts”并完成
  • 运行“fc-cache -f”以更新字体缓存

这是一个有效的 Dockerfile 示例:

FROM alpine:3.7
RUN apk --no-cache add msttcorefonts-installer fontconfig && \
    update-ms-fonts && \
    fc-cache -f
Run Code Online (Sandbox Code Playgroud)

安装 fc-cache 需要 fontconfig 包。我不确定这是否是绝对必要的。