Skip to content

Commit 6462cba

Browse files
committed
fix(xl-pdf-exporter): fix emoji rendering for ZWJ sequences in PDF export
Switch from archived Twemoji 14.0.2 CDN to jdecked/twemoji v17.0.3 and use a builder function that correctly handles variation selectors (fe0f) in ZWJ emoji sequences like 🚶‍♀️ and 🏃‍♀️. Fixes #1978
1 parent 47f5a3b commit 6462cba

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

packages/xl-pdf-exporter/src/pdf/pdfExporter.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const PIXELS_PER_POINT = 0.75;
3232
type Options = ExporterOptions & {
3333
/**
3434
*
35-
* @default uses the remote emoji source hosted on cloudflare (https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/)
35+
* @default uses Twemoji images from jdecked/twemoji on jsDelivr CDN
3636
*/
3737
emojiSource: false | ReturnType<typeof Font.getEmojiSource>;
3838
};
@@ -97,8 +97,15 @@ export class PDFExporter<
9797
) {
9898
const defaults = {
9999
emojiSource: {
100-
format: "png",
101-
url: "https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/",
100+
builder: (code: string) => {
101+
// Twemoji filenames include fe0f in ZWJ sequences but not in
102+
// standalone emojis, so strip it only when there's no ZWJ (200d).
103+
const resolved = code.includes("200d")
104+
? code
105+
: code.replace(/-fe0f/g, "");
106+
return `https://cdn.jsdelivr.net/gh/jdecked/twemoji@v17.0.3/assets/72x72/${resolved}.png`;
107+
},
108+
withVariationSelectors: true,
102109
},
103110
resolveFileUrl: corsProxyResolveFileUrl,
104111
colors: COLORS_DEFAULT,

0 commit comments

Comments
 (0)