Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
fonts-wqy-microhei \
fonts-arphic-ukai \
fonts-arphic-uming \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

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

# Install VTracer binary
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
Expand All @@ -101,4 +111,6 @@ EXPOSE 3000/tcp
# used for calibre
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
ENV NODE_ENV=production
ENV LANG=zh_CN.UTF-8
ENV LC_ALL=zh_CN.UTF-8
ENTRYPOINT [ "bun", "run", "dist/src/index.js" ]
4 changes: 4 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
# dockerfile: Debian.Dockerfile
volumes:
- ./data:/app/data
# - /usr/share/fonts/truetype/chinese:/usr/share/fonts/truetype/chinese:ro # mount Chinese fonts from host (optional)
environment: # Defaults are listed below. All are optional.
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account)
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
Expand All @@ -16,5 +17,8 @@ services:
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
- 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 in container (mount fonts via volumes above)
# - PANDOC_CHINESE_FONT_FAMILY=NotoSansCJK # Chinese font family name
ports:
- 3000:3000
23 changes: 23 additions & 0 deletions src/converters/pandoc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { execFile as execFileOriginal } from "node:child_process";
import { ExecFileFn } from "./types";
import {
PANDOC_ENABLE_CHINESE_FONT,
PANDOC_CHINESE_FONT_PATH,
PANDOC_CHINESE_FONT_FAMILY
} from "../helpers/env";

export const properties = {
from: {
Expand Down Expand Up @@ -136,6 +141,24 @@ export function convert(

if (xelatex.includes(convertTo)) {
args.push("--pdf-engine=xelatex");

// Add Chinese font support if enabled
if (PANDOC_ENABLE_CHINESE_FONT) {
// Create a custom LaTeX template for Chinese font support
const chineseFontArgs = [
"-V", `mainfont=${PANDOC_CHINESE_FONT_FAMILY}`,
"-V", "CJKmainfont=" + PANDOC_CHINESE_FONT_FAMILY,
"--variable", "geometry:margin=1in",
"--variable", "fontsize=11pt"
];

// Add font path if specified
if (PANDOC_CHINESE_FONT_PATH) {
chineseFontArgs.push("--variable", `fontdir:${PANDOC_CHINESE_FONT_PATH}`);
}

args.push(...chineseFontArgs);
}
}

args.push(filePath);
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ export const MAX_CONVERT_PROCESS =

export const UNAUTHENTICATED_USER_SHARING =
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;

export const PANDOC_ENABLE_CHINESE_FONT =
process.env.PANDOC_ENABLE_CHINESE_FONT?.toLowerCase() === "true" || false;

export const PANDOC_CHINESE_FONT_PATH = process.env.PANDOC_CHINESE_FONT_PATH || "";

export const PANDOC_CHINESE_FONT_FAMILY = process.env.PANDOC_CHINESE_FONT_FAMILY || "SimSun";
Loading