0.1.1 โ€ข Published 2 years ago

unicode-text-decorator v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

unicode-text-decorator

Node.js CI

unicode-text-decorator is a simple library to convert ASCII text to decorated text.

๐šž๐š—๐š’๐šŒ๐š˜๐š๐šŽ-๐š๐šŽ๐šก๐š-๐š๐šŽ๐šŒ๐š˜๐š›๐šŠ๐š๐š˜๐š› is ๐—ฎ ๐˜€๐—ถ๐—บ๐—ฝ๐—น๐—ฒ ๐—น๐—ถ๐—ฏ๐—ฟ๐—ฎ๐—ฟ๐˜† to ๐•”๐• ๐•Ÿ๐•ง๐•–๐•ฃ๐•ฅ โ’ถโ“ˆโ’ธโ’พโ’พ text to ๐Ÿ‡ฉ๐Ÿ‡ช๐Ÿ‡จ๐Ÿ‡ด๐Ÿ‡ท๐Ÿ‡ฆ๐Ÿ‡น๐Ÿ‡ช๐Ÿ‡ฉ text.

Notice

These Unicode characters are basically symbols provided for expressing mathematical formulae and so on. Hence they are not recongnised as Latin alphabet characters and have accessibility problems like text-to-speech. Not only this library but also these "decorated Unicode fonts" are just for hobby and playing use.

Install

npm i unicode-text-decorator

Usage

utd.decorate(targetText, fontName)

const utd = require('unicode-text-decorator');

let wildScreen = utd.decorate('wi(l)d-screen', 'bold_italic_serif');
let baroque = utd.decorate('baroque', 'bold_sans_serif');

console.log(wildScreen + ' ' + baroque);

let nanaDaiba = utd.decorate('Nana Daiba / ๅคงๅ ดใชใช (CV: Moeka Koizumi / ๅฐๆณ‰่Œ้ฆ™)', 'bold_script');
console.log(nanaDaiba);

expected output

๐’˜๐’Š(๐’)๐’…-๐’”๐’„๐’“๐’†๐’†๐’ ๐—ฏ๐—ฎ๐—ฟ๐—ผ๐—พ๐˜‚๐—ฒ
๐“๐“ช๐“ท๐“ช ๐““๐“ช๐“ฒ๐“ซ๐“ช / ๅคงๅ ดใชใช (๐“’๐“ฅ: ๐“œ๐“ธ๐“ฎ๐“ด๐“ช ๐“š๐“ธ๐“ฒ๐”ƒ๐“พ๐“ถ๐“ฒ / ๅฐๆณ‰่Œ้ฆ™)

Symbols (like space and /) and non-ASCII characters are ignored.

FYI: wi(l)d-screen baroque is the song appeard in the movie of Revue Starlight. The title of the song is displayed in a mixture of serif and sans-serif in the scene.

Supported Font

font nameExampleCapital LettersSmall LettersNumbers
bold_serif๐”๐ง๐ข๐œ๐จ๐๐žโœ…โœ…โœ…
italic_serif๐‘ˆ๐‘›๐‘–๐‘๐‘œ๐‘‘๐‘’โœ…โœ…
bold_italic_serif๐‘ผ๐’๐’Š๐’„๐’๐’…๐’†โœ…โœ…
script๐’ฐ๐“ƒ๐’พ๐’ธโ„ด๐’นโ„ฏโœ…โœ…
bold_script๐“ค๐“ท๐“ฒ๐“ฌ๐“ธ๐“ญ๐“ฎโœ…โœ…
fraktur๐”˜๐”ซ๐”ฆ๐” ๐”ฌ๐”ก๐”ขโœ…โœ…
bold_fraktur๐–€๐–“๐–Ž๐–ˆ๐–”๐–‰๐–Šโœ…โœ…
double_struck๐•Œ๐•Ÿ๐•š๐•”๐• ๐••๐•–โœ…โœ…โœ…
sans_serif๐–ด๐—‡๐—‚๐–ผ๐—ˆ๐–ฝ๐–พโœ…โœ…โœ…
bold_sans_serif๐—จ๐—ป๐—ถ๐—ฐ๐—ผ๐—ฑ๐—ฒโœ…โœ…โœ…
italic_sans_serif๐˜œ๐˜ฏ๐˜ช๐˜ค๐˜ฐ๐˜ฅ๐˜ฆโœ…โœ…
bold_italic_sans_serif๐™๐™ฃ๐™ž๐™˜๐™ค๐™™๐™šโœ…โœ…
monospace๐š„๐š—๐š’๐šŒ๐š˜๐š๐šŽโœ…โœ…
regional_indicator๐Ÿ‡บ๐Ÿ‡ณ๐Ÿ‡ฎ๐Ÿ‡จ๐Ÿ‡ด๐Ÿ‡ฉ๐Ÿ‡ชโœ…
circleโ“Šโ“โ“˜โ“’โ“žโ““โ“”โœ…โœ…โœ…
black_circle๐Ÿ…ค๐Ÿ…๐Ÿ…˜๐Ÿ…’๐Ÿ…ž๐Ÿ…“๐Ÿ…”โœ…
square๐Ÿ…„๐Ÿ„ฝ๐Ÿ„ธ๐Ÿ„ฒ๐Ÿ„พ๐Ÿ„ณ๐Ÿ„ดโœ…
parenthesized๐Ÿ„คโ’ฉโ’คโ’žโ’ชโ’Ÿโ’ โœ…โœ…
fullwidth๏ผต๏ฝŽ๏ฝ‰๏ฝƒ๏ฝ๏ฝ„๏ฝ…โœ…โœ…โœ…

Notice

regional_indicator is the characters that represents national/regional flags. In some environment (like Discord), these characters are basically interpreted as flags emoji. For example, JOIN US will be shown as JO (Jordan) IN (India) US (United States) like below. This is not a bug of this library.

national flags

Fallback Option

Some fonts don't have characters for small letters. In that case, if you turn on the fallback option, this returns existing capital letters instead of (unexisting) small ones.

let tokyoTower1 = utd.decorate('Tokyo Tower', 'black_circle'); // default is false
let tokyoTower2 = utd.decorate('Tokyo Tower', 'black_circle', { fallback: true });
let tokyoTower3 = utd.decorate('Torre de Tรณquio','black_circle', { fallback: true });

console.log(tokyoTower1);
console.log(tokyoTower2);
console.log(tokyoTower3);

expected output

Even with the fallback mode, unexisting characters (non-ASCII like รณ ) will be ignored.

๐Ÿ…ฃokyo ๐Ÿ…ฃower
๐Ÿ…ฃ๐Ÿ…ž๐Ÿ…š๐Ÿ…จ๐Ÿ…ž ๐Ÿ…ฃ๐Ÿ…ž๐Ÿ…ฆ๐Ÿ…”๐Ÿ…ก
๐Ÿ…ฃ๐Ÿ…ž๐Ÿ…ก๐Ÿ…ก๐Ÿ…” ๐Ÿ…“๐Ÿ…” ๐Ÿ…ฃรณ๐Ÿ… ๐Ÿ…ค๐Ÿ…˜๐Ÿ…ž
0.1.1

2 years ago

0.1.0

2 years ago