diff --git a/make-pdf/src/print-css.ts b/make-pdf/src/print-css.ts index 2366f42b99..e0b4ec7edf 100644 --- a/make-pdf/src/print-css.ts +++ b/make-pdf/src/print-css.ts @@ -35,8 +35,8 @@ // Metric-compatible sans stack: Helvetica (macOS), Liberation Sans (Linux, // ships via fonts-liberation), Arial (Windows). Shared by every text surface. const SANS_STACK = `Helvetica, "Liberation Sans", Arial`; -// CJK fallback families, appended to the body stack only. -const CJK_STACK = `"Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Microsoft YaHei"`; +// CJK fallback families (Simplified-Chinese first), appended to the body stack only. +const CJK_STACK = `"PingFang SC", "Heiti SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP"`; // Color-emoji families: Apple (macOS), Segoe (Windows), Noto (Linux). const EMOJI_FAMILIES = `"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji"`; diff --git a/make-pdf/src/smartypants.ts b/make-pdf/src/smartypants.ts index 2dfe097e09..5f794a2aa7 100644 --- a/make-pdf/src/smartypants.ts +++ b/make-pdf/src/smartypants.ts @@ -20,7 +20,7 @@ const CODE_ZONE_RE = /<(pre|code|script|style)\b[^>]*>[\s\S]*?<\/\1>/gi; const TAG_RE = /<[^>]+>/g; -const URL_RE = /\bhttps?:\/\/\S+/g; +const URL_RE = /\bhttps?:\/\/[^\s\u0000]+/g; /** * Apply smartypants to an HTML string. Zones that should not be touched: @@ -44,7 +44,7 @@ export function smartypants(html: string): string { }); }; - let s = html; + let s = html.replace(/\u0000/g, ""); // drop stray input NUL (can't forge a placeholder) s = carve(s, CODE_ZONE_RE); s = carve(s, TAG_RE); s = carve(s, URL_RE); @@ -89,11 +89,11 @@ function transformText(text: string): string { // Double quotes: open if preceded by whitespace/bol, close if preceded // by word char or punctuation. - s = s.replace(/(^|[\s\(\[\{\-])"/g, "$1\u201c"); // opening " + s = s.replace(/(^|[\s\(\[\{\-:(【「『〈《])"/g, "$1\u201c"); // opening " s = s.replace(/"/g, "\u201d"); // remaining " are closing // Single quotes (after apostrophe pass): - s = s.replace(/(^|[\s\(\[\{\-])'/g, "$1\u2018"); // opening ' + s = s.replace(/(^|[\s\(\[\{\-:(【「『〈《])'/g, "$1\u2018"); // opening ' s = s.replace(/'/g, "\u2019"); // remaining ' are closing return s;