Skip to content

Commit 38057e1

Browse files
committed
tryfixputt
1 parent c26f59c commit 38057e1

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

.github/workflows/generate_release_pdf.yml

+41-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,44 @@ jobs:
2222
- name: Set up Git repository
2323
uses: actions/checkout@v4
2424

25+
- name: Cache Fonts
26+
uses: actions/cache@v4
27+
id: cache-fonts
28+
with:
29+
path: fonts
30+
key: ${{ runner.os }}-fonts-noto_sans_sc-lxgwwenkai
31+
32+
- name: Download Fonts
33+
if: steps.cache-fonts.outputs.cache-hit != 'true'
34+
run: |
35+
if [ -f "${{ env.TYPST_FONT_PATH }}/NotoSansSC-Regular.ttf" ]; then
36+
echo "Font already existed."
37+
else
38+
# Download font metadata
39+
mkdir -p cv
40+
curl -sL "https://fonts.google.com/download/list?family=Noto%20Sans%20SC" > cv/noto_sans_sc_raw.txt
41+
42+
# Remove ")]}'" from the beginning of the file
43+
tail -c +5 cv/noto_sans_sc_raw.txt > cv/noto_sans_sc_metadata.json
44+
45+
# Extract the necessary information from the JSON file
46+
file_refs=$(jq -rc '.manifest.fileRefs[]' cv/noto_sans_sc_metadata.json)
47+
48+
# Download, save the font file to /fonts
49+
mkdir -p ${{ env.TYPST_FONT_PATH }}
50+
while IFS= read -r file_ref; do
51+
filename=$(echo "$file_ref" | jq -r '.filename')
52+
url=$(echo "$file_ref" | jq -r '.url')
53+
fontname=$(basename "$filename")
54+
echo $url $fontname
55+
curl -L "$url" -o "${{ env.TYPST_FONT_PATH }}/$fontname"
56+
done <<< "$file_refs"
57+
ls -l ${{ env.TYPST_FONT_PATH }}
58+
fi
59+
for form in Light Regular Bold; do
60+
curl -L "https://github.com/lxgw/LxgwWenKai/releases/download/v1.330/LXGWWenKai-$form.ttf" -o "${{ env.TYPST_FONT_PATH }}/LXGWWenKai-$form.ttf"
61+
done
62+
2563
- name: Prepare Mkdocs environment
2664
run: |
2765
pip install mkdocs
@@ -77,9 +115,9 @@ jobs:
77115
> GitHub 卡顿,无法下载?访问 [小彭老师自己维护的镜像](${{ env.MIRROR_SITE_URL }}/cppguidebook.pdf)。
78116
> 喜欢在线阅读?访问 [GitHub Pages](https://parallel101.github.io/cppguidebook)
79117
tag_name: ${{ steps.tag.outputs.release_tag }}
80-
files:
81-
- cppguidebook.pdf
82-
- cppguidebook-site.zip
118+
files: |
119+
cppguidebook.pdf
120+
cppguidebook-site.zip
83121
84122
- name: Publish to mirror site
85123
continue-on-error: true

misc/export_to_pdf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ footerHtml = ` `;
2323
const browser = await puppeteer.launch({
2424
headless: true,
2525
executablePath: process.env.CHROME_BIN || null,
26-
args: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage']
26+
args: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-dev-shm-usage', '--lang=zh-CN']
2727
});
2828

2929
const page = await browser.newPage();

0 commit comments

Comments
 (0)