Giter Site home page Giter Site logo

unicode-text-decorator's Introduction

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 name Example Capital Letters Small Letters Numbers
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
๐Ÿ…ฃ๐Ÿ…ž๐Ÿ…š๐Ÿ…จ๐Ÿ…ž ๐Ÿ…ฃ๐Ÿ…ž๐Ÿ…ฆ๐Ÿ…”๐Ÿ…ก
๐Ÿ…ฃ๐Ÿ…ž๐Ÿ…ก๐Ÿ…ก๐Ÿ…” ๐Ÿ…“๐Ÿ…” ๐Ÿ…ฃรณ๐Ÿ… ๐Ÿ…ค๐Ÿ…˜๐Ÿ…ž

unicode-text-decorator's People

Contributors

ryo-a avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.