From 7500b2498b64e8d3580692df5b7463de58f34df7 Mon Sep 17 00:00:00 2001 From: syxanash Date: Sun, 1 Dec 2024 10:34:42 +0000 Subject: [PATCH] improved emojis segmentation --- assets/js/bluerain.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/js/bluerain.js b/assets/js/bluerain.js index 3c6ffbe..6d75287 100644 --- a/assets/js/bluerain.js +++ b/assets/js/bluerain.js @@ -48,6 +48,8 @@ for (let i = 0; i < columns; i++) { skeetsIndex[i] = 0; } +const sanitizeForEmojis = (string) => [...new Intl.Segmenter().segment(string)].map(x => x.segment) + function loop() { if (pauseAnimation) return; @@ -56,7 +58,7 @@ function loop() { for (let i = 0; i < drops.length; i++) { if (i < skeets.length) { - const characters = Array.from(skeets[i]); // used to fix emoji encoding + const characters = sanitizeForEmojis(skeets[i]); const text = characters[skeetsIndex[i]]; let oldText = ''; @@ -165,4 +167,4 @@ F - change rain font ` console.log(helpText, "font-size: small") -console.log('%chttps://github.com/syxanash/bluerain', "font-size: medium"); \ No newline at end of file +console.log("%chttps://github.com/syxanash/bluerain", "font-size: medium"); \ No newline at end of file