Skip to content

Commit ff86e1e

Browse files
authored
fix: copyright symbol rendering (diegomura#2496)
* fix: copyright symbol rendering * chore: add changeset * chore: examples minor bump
1 parent 9fe1f76 commit ff86e1e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@react-pdf/textkit": "^4.2.1",
2828
"@react-pdf/types": "^2.3.5",
2929
"cross-fetch": "^3.1.5",
30-
"emoji-regex": "^10.2.1",
30+
"emoji-regex": "^10.3.0",
3131
"queue": "^6.0.1",
3232
"yoga-layout": "^2.0.1"
3333
},

src/text/emoji.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export const fetchEmojis = (string, source) => {
6767
return promises;
6868
};
6969

70+
const specialCases = ['©️', '®']; // Do not treat these as emojis if emoji not present
71+
7072
export const embedEmojis = fragments => {
7173
const result = [];
7274

@@ -78,6 +80,8 @@ export const embedEmojis = fragments => {
7880
Array.from(fragment.string.matchAll(regex)).forEach(match => {
7981
const { index } = match;
8082
const emoji = match[0];
83+
const isSpecialCase = specialCases.includes(emoji);
84+
8185
const emojiSize = fragment.attributes.fontSize;
8286
const chunk = fragment.string.slice(lastIndex, index + match[0].length);
8387

@@ -96,6 +100,8 @@ export const embedEmojis = fragments => {
96100
},
97101
},
98102
});
103+
} else if (isSpecialCase) {
104+
result.push({ string: emoji, attributes: fragment.attributes });
99105
} else {
100106
// If no emoji data, we just replace the emoji with a nodef char
101107
result.push({

0 commit comments

Comments
 (0)