git: 6a430fe152 - main - documentation/pdf: Improve zh-cn|zh-tw font issues
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 21 Jan 2023 00:20:25 UTC
The branch main has been updated by dbaio: URL: https://cgit.FreeBSD.org/doc/commit/?id=6a430fe152e6374caf0851d253819293522fcdb4 commit 6a430fe152e6374caf0851d253819293522fcdb4 Author: Yan Hao Wang <bses30074@gmail.com> AuthorDate: 2023-01-20 19:50:45 +0000 Commit: Danilo G. Baio <dbaio@FreeBSD.org> CommitDate: 2023-01-21 00:14:53 +0000 documentation/pdf: Improve zh-cn|zh-tw font issues The build script now uses fonts installed by the port/pkg docproj-fonts-cjk. Differential Revision: https://reviews.freebsd.org/D36623 Differential Revision: https://reviews.freebsd.org/D37447 Co-authored-by: Danilo G. Baio <dbaio@FreeBSD.org> --- documentation/tools/asciidoctor.sh | 25 ++++++++++++++++++++++++- shared/zh-cn/zh-cn-theme.yml | 16 ++++++++++++++++ shared/zh-tw/zh-tw-theme.yml | 16 ++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/documentation/tools/asciidoctor.sh b/documentation/tools/asciidoctor.sh index 27ce3f790c..ab5125bc0f 100755 --- a/documentation/tools/asciidoctor.sh +++ b/documentation/tools/asciidoctor.sh @@ -49,6 +49,8 @@ build_pdf() { local cur_dir_source="content/$doc_lang/$doc_type/$doc_name/" local cur_dir_output="public/$doc_lang/$doc_type/$doc_name/" + local theme_font="" + if [ ! -d "$cur_dir_output" ]; then mkdir -p "$cur_dir_output" fi @@ -68,6 +70,27 @@ build_pdf() { local asciidoctor_file_name="_index.adoc" fi + # Check non default fonts + case "$doc_lang" in + zh-cn) + if [ ! -f "$LOCALBASE/share/docproj-fonts-cjk/NotoSansSC-Medium.otf" ]; then + echo " font not found, skipping pdf build" + return + fi + theme_font="-a scripts=cjk -a pdf-theme=./shared/zh-cn/zh-cn-theme.yml -a pdf-fontsdir=$LOCALBASE/share/docproj-fonts-cjk" + ;; + zh-tw) + if [ ! -f "$LOCALBASE/share/docproj-fonts-cjk/NotoSansTC-Medium.otf" ]; then + echo " font not found, skipping pdf build" + return + fi + theme_font="-a pdf-theme=./shared/zh-tw/zh-tw-theme.yml -a pdf-fontsdir=$LOCALBASE/share/docproj-fonts-cjk/" + ;; + *) + theme_font="-a pdf-theme=default-with-fallback-font" + ;; + esac + $ASCIIDOCTORPDF_CMD \ -r ./shared/lib/man-macro.rb \ -r ./shared/lib/git-macro.rb \ @@ -80,7 +103,7 @@ build_pdf() { -a lang="$doc_lang" \ -a isonline=1 \ -a env-beastie=1 \ - -a pdf-theme=default-with-fallback-font \ + ${theme_font} \ -o "${cur_dir_output}${doc_name}_${doc_lang}.pdf" \ "${cur_dir_source}${asciidoctor_file_name}" } diff --git a/shared/zh-cn/zh-cn-theme.yml b/shared/zh-cn/zh-cn-theme.yml new file mode 100644 index 0000000000..8e1c288aad --- /dev/null +++ b/shared/zh-cn/zh-cn-theme.yml @@ -0,0 +1,16 @@ +extends: default +font: + catalog: + merge: true + Noto Sans SC: NotoSansSC-Medium.otf + fallbacks: + - Noto Serif +base: + text-align: left + font-family: Noto Sans SC +codespan: + font-family: Noto Sans SC +kbd: + font-family: $codespan-font-family +code: + font-family: $codespan-font-family diff --git a/shared/zh-tw/zh-tw-theme.yml b/shared/zh-tw/zh-tw-theme.yml new file mode 100644 index 0000000000..b4ce1d6f05 --- /dev/null +++ b/shared/zh-tw/zh-tw-theme.yml @@ -0,0 +1,16 @@ +extends: default +font: + catalog: + merge: true + Noto Sans TC: NotoSansTC-Medium.otf + fallbacks: + - Noto Serif +base: + text-align: left + font-family: Noto Sans TC +codespan: + font-family: Noto Sans TC +kbd: + font-family: $codespan-font-family +code: + font-family: $codespan-font-family