Skip to content

Commit dfdc1a9

Browse files
authored
tr/emoji fix (#3545)
1 parent aa6c3b1 commit dfdc1a9

2 files changed

Lines changed: 5 additions & 26 deletions

File tree

Aptfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ postgresql-client-16
2525
# Chromium and dependencies for pubstash (HTML-to-PDF via Playwright + paged.js)
2626
chromium
2727
fonts-liberation
28+
fonts-dejavu-core
29+
fonts-freefont-ttf
30+
fonts-kacst
31+
fonts-noto-cjk
2832
fonts-noto-color-emoji
33+
fonts-thai-tlwg
2934
libnss3
3035
libatk-bridge2.0-0
3136
libdrm2

pubstash/server.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,32 +199,6 @@ async function convertHtmlToPdf(html: string): Promise<Buffer> {
199199
() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))),
200200
);
201201

202-
// Chromium 146+ renders certain Unicode characters (e.g. ↩ U+21A9 in
203-
// footnote back-links) as color emoji instead of simple text glyphs.
204-
// Fix at the Unicode level by appending U+FE0E (Variation Selector 15 =
205-
// "text presentation") to every affected character in text nodes.
206-
// This is more reliable than CSS font-variant-emoji because page.pdf()
207-
// uses Chromium's internal print path which may ignore that property.
208-
await page.evaluate(() => {
209-
const VS15 = '\uFE0E';
210-
// Characters with dual text/emoji presentation that commonly appear
211-
// in academic documents and should remain as simple text glyphs.
212-
const EMOJI_CAPABLE =
213-
/[\u2139\u21A9\u21AA\u2194-\u2199\u23CF\u23ED-\u23EF\u23F1\u23F2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D]/;
214-
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
215-
let node: Text | null;
216-
while ((node = walker.nextNode() as Text | null)) {
217-
const text = node.nodeValue;
218-
if (text && EMOJI_CAPABLE.test(text)) {
219-
// Append VS15 after each matching char (skip if already followed by VS15)
220-
node.nodeValue = text.replace(
221-
/([\u2139\u21A9\u21AA\u2194-\u2199\u23CF\u23ED-\u23EF\u23F1\u23F2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D])(?!\uFE0E)/g,
222-
`$1${VS15}`,
223-
);
224-
}
225-
}
226-
});
227-
228202
// Extract <meta> tags for PDF metadata
229203
const meta: PdfMeta = await page.evaluate(() => {
230204
const m: Record<string, string> = {};

0 commit comments

Comments
 (0)