Skip to content

Commit

Permalink
为 Rocky Linux 9 系统设置 Noto 字体
Browse files Browse the repository at this point in the history
  • Loading branch information
XiangyunHuang committed Dec 10, 2023
1 parent 02b9500 commit 43dc120
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions _common.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ knitr::opts_chunk$set(
comment = "#>"
)

if (xfun::is_macos()) {
if (grepl(x = sessionInfo()$running, pattern = "macOS")) {
# 准备 Noto 中英文字体
sysfonts::font_paths(new = "~/Library/Fonts/")
## 宋体
Expand All @@ -19,17 +19,39 @@ if (xfun::is_macos()) {
regular = "NotoSerifCJKsc-Regular.otf",
bold = "NotoSerifCJKsc-Bold.otf"
)
## 黑体
sysfonts::font_add(
family = "Noto Sans CJK SC",
regular = "NotoSansCJKsc-Regular.otf",
bold = "NotoSansCJKsc-Bold.otf"
)
} else if (grepl(x = sessionInfo()$running, pattern = "Fedora")) { # Github Action custom Docker Container Based on Fedora
sysfonts::font_paths(new = c(
"/usr/share/fonts/google-noto-serif-cjk-fonts" # Fedora 38
"/usr/share/fonts/google-noto-serif-cjk-fonts" # Fedora 39
))
## 宋体
sysfonts::font_add(
family = "Noto Serif CJK SC",
regular = "NotoSerifCJK-Regular.ttc",
bold = "NotoSerifCJK-Bold.ttc"
)
} else if (grepl(x = sessionInfo()$running, pattern = "Rocky")) {
sysfonts::font_paths(new = c(
"/usr/share/fonts/google-noto-cjk/" # Rocky Linux 9
))
## 宋体
sysfonts::font_add(
family = "Noto Serif CJK SC",
regular = "NotoSerifCJK-Regular.ttc",
bold = "NotoSerifCJK-Bold.ttc"
)
} else {
## 黑体
sysfonts::font_add(
family = "Noto Sans CJK SC",
regular = "NotoSansCJK-Regular.ttc",
bold = "NotoSansCJK-Bold.ttc"
)
} else { # Ubuntu
sysfonts::font_paths(new = c(
"/usr/share/fonts/opentype/noto/",
"/usr/share/fonts/truetype/noto/"
Expand Down

1 comment on commit 43dc120

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.