Skip to content

Commit

Permalink
feat: Use monochrome emojis contained in the font if no emoji source …
Browse files Browse the repository at this point in the history
…available

Signed-off-by: Naoki Ikeguchi <[email protected]>
  • Loading branch information
siketyan committed May 1, 2024
1 parent 8df6811 commit 1c60497
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/layout/src/text/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export const fetchEmojis = (string, source) => {
return promises;
};

const specialCases = ['©️', '®', '™']; // Do not treat these as emojis if emoji not present

export const embedEmojis = (fragments) => {
const result = [];

Expand All @@ -82,8 +80,6 @@ export const embedEmojis = (fragments) => {
Array.from(fragment.string.matchAll(regex)).forEach((match) => {
const { index } = match;
const emoji = match[0];
const isSpecialCase = specialCases.includes(emoji);

const emojiSize = fragment.attributes.fontSize;
const chunk = fragment.string.slice(lastIndex, index + match[0].length);

Expand All @@ -102,12 +98,10 @@ export const embedEmojis = (fragments) => {
},
},
});
} else if (isSpecialCase) {
result.push({ string: chunk, attributes: fragment.attributes });
} else {
// If no emoji data, we just replace the emoji with a nodef char
// If no emoji data, we try to use emojis in the font
result.push({
string: chunk.replace(match, String.fromCharCode(0)),
string: chunk,
attributes: fragment.attributes,
});
}
Expand Down

0 comments on commit 1c60497

Please sign in to comment.