An open API service indexing awesome lists of open source software.

https://github.com/bric3/jufmt

Java Unicode formatter
https://github.com/bric3/jufmt

cli figlet graalvm java micronaut unicode

Last synced: 6 months ago
JSON representation

Java Unicode formatter

Awesome Lists containing this project

README

          

// suppress inspection "GrazieInspection" for whole file
// suppress inspection "SpellCheckingInspection" for whole file
= Java Unicode Formatter (jufmt)

image:https://github.com/bric3/jufmt/actions/workflows/gradle.yml/badge.svg["Build", link="https://github.com/bric3/jufmt/actions/workflows/gradle.yml"]
image:https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg["License: MPL 2.0", link="https://opensource.org/licenses/MPL-2.0"]

Simple Java and GraalVM toy to play with unicode formatting.

There are many websites that perform fancy Unicode text transformation.
For fun, I wanted to try to implement these features in Java.

[source, shell]
----
$ java -jar build/libs/jufmt-all.jar -h
░░▒█░█▒█▒█▀░█▄▒▄█░▀█▀
░▀▄█░▀▄█░█▀░█▒▀▒█░▒█▒
Usage: jufmt [-dhrV] [--strip-diacritic-marks] [-c=CONVERTER] [-n=FORM]
[-o=ORNAMENT] [-s=STYLE] [STR] [COMMAND]
Format input latin string with fancy unicode chars
[STR] The string to process
-c, --converter=CONVERTER Converter, valid converters: none, normal, sans,
sansBold, sansItalic, sansBoldItalic, monospace,
fullwidth, fraktur, boldFraktur, serifBold,
serifItalic, serifBoldItalic, doubleStruck,
script, boldScript, circled, circledNegative,
squared, squaredNegative, parenthesized,
smallCaps, subscript, superscript, inverted,
mirrored, rounded, greek, japanese,
fauxEthiopian, ogham, asciiBrailleGrade1, morse
-d, --describe Describe characters, or more precisely codepoints
-h, --help Show this help message and exit.
-o, --ornament=ORNAMENT Ornaments, valid ornaments: curvedAngleBracket,
blackLenticularBracket, whiteLenticularBracket,
tortoiseBracket, whiteTortoiseBracket,
angleBracket, doubleAngleBracket, cornerBracket,
whiteCornerBracket, lightShade, mediumShade,
darkShade, wave, tibetanKuRuKhaBzhiMigCan,
ethiopicSectionMark
-r, --reversed Reverse string
-s, --style=STYLE Styles, valid styles: strikethrough, macron,
macronBelow, lowline, doubleLowline, overline,
doubleOverline, shadow, upwardArrowBelow,
hotFumes, doubleArrow, electric, snow, smeared
-V, --version Print version information and exit.
Commands:
figlet Renders input string as a text banner (FIGlet)
normalize Normalize input string using the given Unicode Normalization Forms
zalgo Renders input with Zalgo
----

If using GraalVM, micronaut offers the `nativeImage` task :

[source, shell]
----
$ asdf local java java graalvm-community-20.0.1
$ java --version
openjdk 20.0.1 2023-04-18
OpenJDK Runtime Environment GraalVM CE 20.0.1+9.1 (build 20.0.1+9-jvmci-23.0-b12)
OpenJDK 64-Bit Server VM GraalVM CE 20.0.1+9.1 (build 20.0.1+9-jvmci-23.0-b12, mixed mode, sharing)
$ ./gradlew nativeCompile
...
$ ./jufmt-cli/build/native/nativeCompile/jufmt figlet -r bric3
___. .__ ________
\_ |__ _______ |__| ____ \_____ \
| __ \\_ __ \| |_/ ___\ _(__ <
| \_\ \| | \/| |\ \___ / \
|___ /|__| |__| \___ >/______ /
\/ \/ \/

----

The tool supports the following charset:

.Fonts
|===
| Font | Character Set

| Normal | "\ !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{\|}~
| Sans bold | "\ !#$%&'()*+,-./𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵:;<=>?@𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭[]^_`𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇{\|}~
| Sans italic | "\ !#$%&'()*+,-./0123456789:;<=>?@𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡[]^_`𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻{}~
| Bold italic | "\ !#$%&'()*+,-./0123456789:;<=>?@𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙒𝙓𝙔𝙕[]^_`𝙖𝙗𝙘𝙙𝙚𝙛𝙜𝙝𝙞𝙟𝙠𝙡𝙢𝙣𝙤𝙥𝙦𝙧𝙨𝙩𝙪𝙫𝙬𝙭𝙮𝙯{\|}~
| Monospace | "\ !#$%&'()*+,-./𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿:;<=>?@𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉[]^_`𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣{\|}~
| Fullwidth | "\ !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
| Math Fraktur | "\ !#$%&'()*+,-./0123456789:;<=>?@𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ[]^_`𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷{\|}~
| Math Fraktur bold | "\ !#$%&'()*+,-./0123456789:;<=>?@𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅[]^_`𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟{\|}~
| Serif bold | "\ !#$%&'()*+,-./𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗:;<=>?@𝐀𝐁𝐂𝐃𝐄𝐅𝐆𝐇𝐈𝐉𝐊𝐋𝐌𝐍𝐎𝐏𝐐𝐑𝐒𝐓𝐔𝐕𝐖𝐗𝐘𝐙[]^_`𝐚𝐛𝐜𝐝𝐞𝐟𝐠𝐡𝐢𝐣𝐤𝐥𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐭𝐮𝐯𝐰𝐱𝐲𝐳{\|}~
| Serif italic | "\ !#$%&'()*+,-./0123456789:;<=>?@𝐴𝐵𝐶𝐷𝐸𝐹𝐺𝐻𝐼𝐽𝐾𝐿𝑀𝑁𝑂𝑃𝑄𝑅𝑆𝑇𝑈𝑉𝑊𝑋𝑌𝑍[]^_`𝑎𝑏𝑐𝑑𝑒𝑓𝑔ℎ𝑖𝑗𝑘𝑙𝑚𝑛𝑜𝑝𝑞𝑟𝑠𝑡𝑢𝑣𝑤𝑥𝑦𝑧{}~
| Serif bold italic | "\ !#$%&'()*+,-./0123456789:;<=>?@𝑨𝑩𝑪𝑫𝑬𝑭𝑮𝑯𝑰𝑱𝑲𝑳𝑴𝑵𝑶𝑷𝑸𝑹𝑺𝑻𝑼𝑽𝑾𝑿𝒀𝒁[]^_`𝒂𝒃𝒄𝒅𝒆𝒇𝒈𝒉𝒊𝒋𝒌𝒍𝒎𝒏𝒐𝒑𝒒𝒓𝒔𝒕𝒖𝒗𝒘𝒙𝒚𝒛{\|}~
| Math double-struck | "\ !#$%&'()*+,-./𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡:;<=>?@𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ[]^_`𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫{\|}~
| Script | "\ !#$%&'()*+,-./0123456789:;<=>?@𝒜ℬ𝒞𝒟ℰℱ𝒢ℋℐ𝒥𝒦ℒℳ𝒩𝒪𝒫𝒬ℛ𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵[]^_`𝒶𝒷𝒸𝒹ℯ𝒻ℊ𝒽𝒾𝒿𝓀𝓁𝓂𝓃ℴ𝓅𝓆𝓇𝓈𝓉𝓊𝓋𝓌𝓍𝓎𝓏{\|}~
| Bold script | "\ !#$%&'()*+,-./0123456789:;<=>?@𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩[]^_`𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃{\|}~
| Circled | "⦸ !#$%&'()⊛⊕,⊖⨀⊘⓪①②③④⑤⑥⑦⑧⑨:;⧀⊜⧁?@ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ[]^_`ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ{⦶}~
| Circled negative | "\ !#$%&'()*+,-./⓿❶❷❸❹❺❻❼❽❾:;<=>?@🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩[]^_`🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩{}~
| Squared | "\ !#$%&'()*+,-./0123456789:;<=>?@🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉[]^_`🄰🄱🄲🄳🄴🄵🄶🄷🄸🄹🄺🄻🄼🄽🄾🄿🅀🅁🅂🅃🅄🅅🅆🅇🅈🅉{}~
| Squared negative | "⧅ !#$%&'()⧆⊞,⊟⊡⧄0123456789:;<=>?@🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉[]^_`🅰🅱🅲🅳🅴🅵🅶🅷🅸🅹🅺🅻🅼🅽🅾🅿🆀🆁🆂🆃🆄🆅🆆🆇🆈🆉{}~
| Parenthesized | "\ !#$%&'()*+,-./0⑴⑵⑶⑷⑸⑹⑺⑻⑼:;<=>?@⒜⒝⒞⒟⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵[]^_`⒜⒝⒞⒟⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵{}~
| Small caps | "\ !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴩꞯʀꜱᴛᴜᴠᴡxʏᴢ{}~
| Subscript | "\ !#$%&'()*₊,₋./₀₁₂₃₄₅₆₇₈₉:;<₌>?@ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘ🇶ʀꜱᴛᴜᴠᴡxʏᴢ[]^_`ₐᵦ𝒸𝒹ₑ𝒻𝓰ₕᵢⱼₖₗₘₙₒₚᵩᵣₛₜᵤᵥ𝓌ₓᵧ𝓏{}~
| Superscript | "\ !#$%&'()*⁺,⁻./⁰¹²³⁴⁵⁶⁷⁸⁹:;<⁼>?@ᴬᴮᶜᴰᴱᶠᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᵠᴿˢᵀᵁⱽᵂˣʸᶻ[]^_`ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵠʳˢᵗᵘᵛʷˣʸᶻ{}~
| Inverted | „\ ¡#$%⅋,)(*+‘-˙/0ƖՇƐᔭϛ9Ɫ86:;<=>¿@∀ꓭↃꓷƎℲ⅁HIſꓘ⅂WNOԀῸꓤS⊥∩ꓥMX⅄Z][^‾`ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz}\|{~
| Mirrored | "/ !#$%&')(*+,-.\0߁ςƐ߂टმ٢8୧:;<=>⸮@AꓭↃꓷƎꟻӘHIႱꓘ⅃MИOꟼϘЯꙄTUVWXYZ][^_`ɒdↄbɘʇϱʜiįʞlmᴎoqpᴙꙅɈυvwxγz}\|{~
| Rounded | "\ !#$%&'()*+,-./0123456789:;<=>?@ᗩᗷᑕᗪEᖴGᕼIᒍKᒪᗰᑎOᑭᑫᖇᔕTᑌᐯᗯ᙭Yᘔ[]^_`ᗩᗷᑕᗪEᖴGᕼIᒍKᒪᗰᑎOᑭᑫᖇᔕTᑌᐯᗯ᙭Yᘔ{\|}~
| Greek | "\ !#$%&'()*+,-./0123456789:;<=>?@ΛBᑕDΣFGΉIJKᒪMПӨPQЯƧƬЦVЩXYZ[]^_`ΛBᑕDΣFGΉIJKᒪMПӨPQЯƧƬЦVЩXYZ{\|}~
| Japanese | "\ !#$%&'()*+,-./0123456789:;<=>?@卂乃匚ᗪ乇千Ꮆ卄丨フҜㄥ爪几ㄖ卩Ɋ尺丂ㄒㄩᐯ山乂ㄚ乙[]^_`卂乃匚ᗪ乇千Ꮆ卄丨フҜㄥ爪几ㄖ卩Ɋ尺丂ㄒㄩᐯ山乂ㄚ乙{\|}~
| Faux Ethiopian | "\ !#$%&'()*+,-./0123456789:;<=>?@ልጌርዕቿቻኗዘጎጋጕረጠክዐየዒዪነፕሁሀሠሸሃጊ[]^_`ልጌርዕቿቻኗዘጎጋጕረጠክዐየዒዪነፕሁሀሠሸሃጊ{\|}~

|===

.Styles
|===
| Font | Example

| Underline | U͟n͟d͟e͟r͟l͟i͟n͟e͟
| Strikethrough | 𝖲̶𝗍̶𝗋̶𝗂̶𝗄̶𝖾̶𝗍̶𝗁̶𝗋̶𝗈̶𝗎̶𝗀̶𝗁̶
| Short Strikethrough | S̵h̵o̵r̵t̵ ̵S̵t̵r̵i̵k̵e̵t̵h̵r̵o̵u̵g̵h̵
|===

== TODO

.TODO
* [x] unicode _fonts_
* [x] braille
* [x] morse
* [x] figlet
* [ ] other utf-8 ascii, possibly other figlet fonts
+
----
▄▌ ▐▄█ █▀ █▚▞▌ ▀█▀

░░▒█░█▒█▒█▀░█▄▒▄█░▀█▀
░▀▄█░▀▄█░█▀░█▒▀▒█░▒█▒

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
███▄█ ██ █ ▄▄█ ▄▀▄ █▄ ▄
███ █ ██ █ ▄██ █▄█ ██ █
█ ▀ ██▄▄▄█▄███▄███▄██▄█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
███▄█░██░█░▄▄█░▄▀▄░█▄░▄
███░█░██░█░▄██░█▄█░██░█
█░▀░██▄▄▄█▄███▄███▄██▄█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄▄
█ █ █ █ █ █ █▄█ █ █
█ █ █ █ █ ▄▄▄█ █▄ ▄█
▄ █ █ █▄█ █ █▄▄▄█ █ █ █
█ █▄█ █ █ ▄▄▄█ █ █ █
█ █ █ █ █ ██▄██ █ █ █
█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄█ █▄█ █▄█ █▄▄▄█

╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋
╋╋╋╋╋╋╭━╮╋╋╋╭╮╋
╋╭╮╋╋╋┃╭╯╋╋╋╯╰╮
╋╰╯╮╭╮╯╰╮╮╭╮╮╭╯
╋╭╮┃┃┃╮╭╯╰╯┃┃┃╋
╋┃┃╰╯┃┃┃╋┃┃┃┃╰╮
╋┃┃━━╯╰╯╋┻┻╯╰━╯
╭╯┃╋╋╋╋╋╋╋╋╋╋╋╋
╰━╯╋╋╋╋╋╋╋╋╋╋╋╋

░░ ░░ ░░ ░░░░░░░ ░░░ ░░░ ░░░░░░░░
▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒ ▒▒▒▒ ▒▒
▒▒ ▒▒ ▒▒ ▒▒▒▒▒ ▒▒ ▒▒▒▒ ▒▒ ▒▒
▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓
█████ ██████ ██ ██ ██ ██

╱╱╱╱╱╱╭━╮╱╱╭╮
╱╭╮╱╱╱┃╭╯╱╭╯╰╮
╱╰╋╮╭┳╯╰┳╮┣╮╭╯
╱╭┫┃┃┣╮╭┫╰╯┃┃
╱┃┃╰╯┃┃┃┃┃┃┃╰╮
╱┃┣━━╯╰╯╰┻┻┻━╯
╭╯┃
╰━╯

╱╱╱╱╭━╮╱╱╭╮
╱╭┳┳┫━╋━━┫╰╮
╱┣┫┃┃╭┫┃┃┃╭┫
╭╯┣━┻╯╰┻┻┻━╯
╰━╯
----

* [x] ornaments
** [x] wrapping chars, e.g. : 【b】【r】【i】【c】【3】, 〖b〗〖r〗〖i〗〖c〗〖3〗, ⧼b⧽⧼r⧽⧼i⧽⧼c⧽⧼3⧽, etc.
** [x] insert chars, e.g. : b྿r྿i྿c྿3, ፠b፠r፠i፠c፠3, b࿐r࿐i࿐c࿐3, etc.
* [x] zalgo: b̼̖̹͉̽̾r͎͔͉͙̽ͭ̈́͛͊i̮̿c̥̦̥̅̈́͐ͮ̚3͎͇ͨ
* [x] styles
** [x] shadow: b̷r̷i̷c̷3̷
** [x] sweating: b̾r̾i̾c̾3̾ ̾
** [x] smeared ink: b҉r҉i҉c҉3҉
* [x] normalize (NFD, NFKD, NFC, NFKC)

This feature is inspired by this nice https://github.com/DenverCoder1/unicode-formatter[js project]
(https://git.io/unicode-formatter[demo]).

.Other sources
* https://en.wikipedia.org/wiki/Braille
* https://en.wikipedia.org/wiki/Braille_ASCII
* https://en.wikipedia.org/wiki/Morse_code
* https://en.wikipedia.org/wiki/Unicode_control_characters (Bidi contorl char in particular)

== License

* This project

> jufmt
>
> Copyright (c) 2020, today - Brice DUTHEIL
>
> This Source Code Form is subject to the terms of the Mozilla Public
> License, v. 2.0. If a copy of the MPL was not distributed with this
> file, You can obtain one at https://mozilla.org/MPL/2.0/.

* In order to render figlet font this project uses a fork of https://github.com/yihleego/banana[yihleego/banana], tat is licensed under Apache License 2.0.

* Fonts comes from
** https://github.com/xero/figlet-fonts[xero/figlet-fonts] (unknown license)
** https://github.com/thugcrowd/gangshit[thugcrowd/gangshit] (unknown license)
** https://patorjk.com/software/taag/[Patrick Gillespie's Text ASCII Art Generator] (unknown license)