Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Chinese Font Support for Pandoc#471

Open
ivanzhangwb wants to merge 5 commits intoC4illin:mainfrom
ivanzhangwb:main
Open

Add Chinese Font Support for Pandoc#471
ivanzhangwb wants to merge 5 commits intoC4illin:mainfrom
ivanzhangwb:main

Conversation

Copy link

ivanzhangwb commented Dec 14, 2025 *
edited by cubic-dev-ai bot
Loading

Summary
Added optional Chinese font support for the Pandoc converter, enabling proper rendering of Chinese characters in
Markdown to PDF conversions.

Changes

Environment Variables (src/helpers/env.ts)

  • PANDOC_ENABLE_CHINESE_FONT: Enable/disable Chinese font support
  • PANDOC_CHINESE_FONT_PATH: Path to Chinese font files
  • PANDOC_CHINESE_FONT_FAMILY: Chinese font family name (default: SimSun)

Pandoc Converter Enhancement (src/converters/pandoc.ts)

  • Automatically detects and applies Chinese font configuration when converting to PDF/LaTeX formats
  • Adds Chinese font parameters when using XeLaTeX engine
  • Supports custom font paths and font families

Docker Configuration Example (compose.yaml)

  • Added Chinese font-related environment variable examples
  • Provided font file mounting configuration template

Usage

  1. Enable Chinese font support:
    1 environment:
    2 - PANDOC_ENABLE_CHINESE_FONT=true
    3 - PANDOC_CHINESE_FONT_FAMILY=NotoSansCJK

  2. Mount host font files:
    1 volumes:
    2 - /usr/share/fonts/truetype/chinese:/usr/share/fonts/truetype/chinese:ro

Testing Recommendations
Test the following scenarios:

  • Chinese Markdown to PDF conversion
  • Rendering effects of different Chinese fonts
  • Correctness of environment variable configuration
  • Test source file: markdown TestChinese.md and pdf TestChinese.pdf

This improvement enhances ConvertX's friendliness for Chinese users while maintaining code simplicity and
maintainability.


Summary by cubic

Added optional Chinese font support for Pandoc PDF/LaTeX conversions so Chinese text renders correctly. Controlled via environment variables and disabled by default.

  • New Features

    • Pandoc adds XeLaTeX font settings when enabled.
    • Env vars: PANDOC_ENABLE_CHINESE_FONT, PANDOC_CHINESE_FONT_PATH, PANDOC_CHINESE_FONT_FAMILY (default: SimSun).
    • Dockerfile installs common Chinese font packages, initializes font cache, and sets zh_CN.UTF-8 locale; compose examples show font volume mount and env usage.
  • Migration

    • Set PANDOC_ENABLE_CHINESE_FONT=true.
    • Optionally set PANDOC_CHINESE_FONT_FAMILY and PANDOC_CHINESE_FONT_PATH.
    • Mount host fonts into the container if needed (read-only).

Written for commit 498a35b. Summary will update automatically on new commits.

cubic-dev-ai bot reviewed Dec 14, 2025
Copy link
Contributor

cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 5 files

Prompt for AI agents (all 4 issues)

Check if these issues are valid -- if so, understand the root cause of each and fix them.





P1: Hardcoded JWT_SECRET with a real-looking value is a security risk. Users may copy this directly into production. Use a clearly-marked placeholder like the existing `compose.yaml` uses (`aLongAndSecretStringUsedToSignTheJSONWebToken1234`) or reference an external secret.






P3: The comment is misleading - this environment variable specifies the font path inside the container, not on the host. The volume mount (line above) handles mapping host fonts to the container path. Consider changing the comment to clarify this is the container path.






P2: Trailing whitespace after backslash line continuation characters. While this may work in many shells, it's considered bad practice and can cause issues. Remove trailing spaces after the `\` characters.



P1: Incorrect font path: `fonts-noto-cjk` installs to `/usr/share/fonts/opentype/noto/`, not `/usr/share/fonts/truetype/noto/`. The symlink will point to a non-existent directory.



Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

ports:
- "3001:3000"
environment:
- JWT_SECRET=ivanzhangwb # will use randomUUID() if unset
Copy link
Contributor

cubic-dev-ai bot Dec 14, 2025 *
edited
Loading

Choose a reason for hiding this comment

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

P1: Hardcoded JWT_SECRET with a real-looking value is a security risk. Users may copy this directly into production. Use a clearly-marked placeholder like the existing compose.yaml uses (aLongAndSecretStringUsedToSignTheJSONWebToken1234) or reference an external secret.

Prompt for AI agents
Check if this issue is valid -- if so, understand the root cause and fix it. At docker-compose.yml, line 9:

Hardcoded JWT_SECRET with a real-looking value is a security risk. Users may copy this directly into production. Use a clearly-marked placeholder like the existing `compose.yaml` uses (`aLongAndSecretStringUsedToSignTheJSONWebToken1234`) or reference an external secret.


@@ -0,0 +1,16 @@
+ ports:
+ - "3001:3000"
+ environment:
+ - JWT_SECRET=ivanzhangwb # will use randomUUID() if unset
+ - HTTP_ALLOWED=true # uncomment this if accessing it over a non-https connection
+ - PANDOC_ENABLE_CHINESE_FONT=true

Addressed in 695a17a

compose.yaml Outdated
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
# - PANDOC_ENABLE_CHINESE_FONT=true # enable Chinese font support for Pandoc PDF/LaTeX conversion
# - PANDOC_CHINESE_FONT_PATH=/usr/share/fonts/truetype/chinese # path to Chinese font directory on host
Copy link
Contributor

cubic-dev-ai bot Dec 14, 2025 *
edited
Loading

Choose a reason for hiding this comment

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

P3: The comment is misleading - this environment variable specifies the font path inside the container, not on the host. The volume mount (line above) handles mapping host fonts to the container path. Consider changing the comment to clarify this is the container path.

Prompt for AI agents
Check if this issue is valid -- if so, understand the root cause and fix it. At compose.yaml, line 21:

The comment is misleading - this environment variable specifies the font path inside the container, not on the host. The volume mount (line above) handles mapping host fonts to the container path. Consider changing the comment to clarify this is the container path.


@@ -16,5 +17,8 @@ services:
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
+ # - PANDOC_ENABLE_CHINESE_FONT=true # enable Chinese font support for Pandoc PDF/LaTeX conversion
+ # - PANDOC_CHINESE_FONT_PATH=/usr/share/fonts/truetype/chinese # path to Chinese font directory on host
+ # - PANDOC_CHINESE_FONT_FAMILY=NotoSansCJK # Chinese font family name
ports:

Suggested change
# - PANDOC_CHINESE_FONT_PATH=/usr/share/fonts/truetype/chinese # path to Chinese font directory on host
# - PANDOC_CHINESE_FONT_PATH=/usr/share/fonts/truetype/chinese # path to Chinese font directory in container (mount fonts via volumes above)

Addressed in 695a17a

Dockerfile Outdated
texlive-latex-extra \
texlive-latex-recommended \
texlive-xetex \
texlive-lang-chinese \
Copy link
Contributor

cubic-dev-ai bot Dec 14, 2025 *
edited
Loading

Choose a reason for hiding this comment

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

P2: Trailing whitespace after backslash line continuation characters. While this may work in many shells, it's considered bad practice and can cause issues. Remove trailing spaces after the \ characters.

Prompt for AI agents
Check if this issue is valid -- if so, understand the root cause and fix it. At Dockerfile, line 77:

Trailing whitespace after backslash line continuation characters. While this may work in many shells, it's considered bad practice and can cause issues. Remove trailing spaces after the `\` characters.


@@ -74,9 +74,19 @@ RUN apt-get update && apt-get install -y \
texlive-latex-extra \
texlive-latex-recommended \
texlive-xetex \
+ texlive-lang-chinese \
+ fonts-noto-cjk \
+ fonts-wqy-zenhei \

Suggested change
texlive-lang-chinese \
texlive-lang-chinese \

Addressed in 695a17a

Dockerfile Outdated
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /usr/share/fonts/truetype/chinese && \
ln -sf /usr/share/fonts/truetype/noto /usr/share/fonts/truetype/chinese/noto && \
Copy link
Contributor

cubic-dev-ai bot Dec 14, 2025 *
edited
Loading

Choose a reason for hiding this comment

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

P1: Incorrect font path: fonts-noto-cjk installs to /usr/share/fonts/opentype/noto/, not /usr/share/fonts/truetype/noto/. The symlink will point to a non-existent directory.

Prompt for AI agents
Check if this issue is valid -- if so, understand the root cause and fix it. At Dockerfile, line 87:

Incorrect font path: `fonts-noto-cjk` installs to `/usr/share/fonts/opentype/noto/`, not `/usr/share/fonts/truetype/noto/`. The symlink will point to a non-existent directory.


@@ -74,9 +74,19 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

+RUN mkdir -p /usr/share/fonts/truetype/chinese && \
+ ln -sf /usr/share/fonts/truetype/noto /usr/share/fonts/truetype/chinese/noto && \
+ fc-cache -f -v
+

Suggested change
ln -sf /usr/share/fonts/truetype/noto /usr/share/fonts/truetype/chinese/noto && \
ln -sf /usr/share/fonts/opentype/noto /usr/share/fonts/truetype/chinese/noto && \

Addressed in 695a17a

Copy link
Owner

C4illin commented Dec 14, 2025

Nice! Is it possible to configure it in any way so that it automatically uses a CJK font when needed, so not everyone have to configure it? I think that would be extremely nice, but no worries if not :)

Copy link
Author

ivanzhangwb commented Dec 15, 2025

Nice! Is it possible to configure it in any way so that it automatically uses a CJK font when needed, so not everyone have to configure it? I think that would be extremely nice, but no worries if not :)

Thanks for the feedback! Auto-switching for CJK fonts would be very convenient. Currently, it still needs to be manually enabled, as I haven't yet implemented reliable detection for CJK content in source files. . I'll keep this in mind for future improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

cubic-dev-ai[bot] cubic-dev-ai[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants