Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module Main where
import Graphics.Text.PCF
import Data.Foldable (fold)
import System.Environment (getArgs)
main :: IO ()
main = do
args <- getArgs
let style = case ( any (`elem`["-b","--bold"]) args
, any (`elem`["-i","--italic"]) args
, any (`elem`["-bi","-ib"]) args ) of
(_ , _, True) -> "BIS"
(False, False, _) -> "RS"
(False, True , _) -> "IS"
(True , False, _) -> "BS"
(True , True , _) -> "BIS"
Right font <- loadPCF $ "/usr/share/fonts/X11/100dpi/lu"++style++"12.pcf.gz"
interact $ renderBraillePCF font
@leftaroundabout

This comment has been minimized.

Copy link
Owner Author

leftaroundabout commented Dec 28, 2017

A simple script that renders text in Braille-rasterization, à la drawille. Uses the pcf-font library; the fonts should be available on Ubuntu systems.

$ braillster <<< "Hello, World!"
⣿⠀⠀⢸⡇⠀⣀⣀⠀⢸⡇⣿⠀⢀⣀⣀⠀⠀⠀⢻⡄⢀⣿⡇⠀⣼⠇⢀⣀⣀⠀⢀⡀⣀⢸⡇⠀⣀⡀⣿⢸⡇
⣿⠶⠶⢾⡇⣾⣭⣭⣷⢸⡇⣿⢰⡟⠉⠙⣷⠀⠀⠘⣧⣸⡇⣿⢠⡟⢰⡟⠉⠙⣷⢸⡟⠉⢸⡇⣾⠋⠉⣿⢸⡇
⣿⠀⠀⢸⡇⠻⣦⣤⡴⢸⡇⣿⠘⢷⣤⣴⠟⣤⡄⠀⢻⣿⠀⢸⣿⠁⠘⢷⣤⣴⠟⢸⡇⠀⢸⡇⠻⣦⡴⣿⢨⡅
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
$ braillster -b <<< "Hello, World!"
⣿⡇⠀⠀⣿⡇⠀⣀⣀⡀⠀⣿⡇⣿⡇⠀⢀⣀⡀⠀⠀⠀⠀⢻⣷⠀⣸⣿⡀⢠⡟⠀⢀⣀⡀⠀⢀⣀⢀⡀⣿⡇⠀⣀⣀⢸⣿⢸⣿
⣿⡷⠶⠶⣿⡇⣾⣯⣭⣿⡆⣿⡇⣿⡇⣾⡟⠉⢻⣷⠀⠀⠀⠘⣿⣆⡿⢿⣇⣾⠃⣾⡟⠉⢻⣷⢸⣿⠛⠃⣿⡇⣾⡟⠉⢹⣿⠈⣿
⣿⡇⠀⠀⣿⡇⠻⢷⣤⣤⡆⣿⡇⣿⡇⠻⢷⣤⡾⠟⢰⣶⠀⠀⢻⣿⠇⠸⣿⡟⠀⠻⢷⣤⡾⠟⢸⣿⠀⠀⣿⡇⠻⣷⣤⢾⣿⢠⣤
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
$ braillster -i <<< "Hello, World!"
⠀⣿⠀⠀⢀⡟⠀⠀⣀⡀⠀⢸⠇⢸⠇⠀⢀⣀⡀⠀⠀⣿⠀⢠⣿⡇⢀⡾⠁⠀⢀⣀⡀⠀⣀⠀⣀⠀⡿⠀⠀⣀⣀⡟⠀⡟
⢰⡷⠶⠶⢾⠇⣰⣏⣩⠏⠀⣿⠀⣿⢀⡾⠋⠉⣿⠀⠀⣿⢀⡞⢸⣇⡾⠁⢀⡾⠋⠉⣿⢰⣷⠟⠉⢸⡇⢠⠞⠉⣽⠇⢸⠇
⣼⠁⠀⠀⣿⠀⢿⣤⣤⠖⢰⡇⢰⡇⠸⣧⣤⠾⠃⢠⡄⢹⡞⠀⢸⡿⠁⠀⠸⣧⣤⠾⠃⣼⠁⠀⠀⣾⠀⢿⣤⢾⡿⠀⣬⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
$ braillster -bi <<< "Hello, World!"
⠀⣿⡏⠀⢠⣿⠇⠀⢀⣀⡀⠀⢰⣿⠃⢰⣿⠃⠀⢀⣀⣀⠀⠀⠀⣿⡇⢀⣾⣿⠀⣼⠏⠀⠀⣀⣀⡀⠀⣀⡀⢀⡀⢰⣿⠃⠀⢀⣀⣸⣿⠃⢸⣿⠃
⢸⣿⠷⠶⣾⣿⢀⣾⣏⣽⡿⠀⣾⡿⠀⣾⡿⢀⣾⠟⠉⣿⡇⠀⠀⣿⡇⣼⢻⣿⣼⠏⠀⣰⡿⠋⢹⣿⢸⣿⡵⠛⠀⣾⡿⠀⣴⡟⢉⣿⡿⠀⣸⡟⠀
⣾⡟⠀⢀⣿⡇⠸⢿⣭⣥⠴⢠⣿⠇⢠⣿⠇⠸⢿⣦⡴⠟⢁⣶⡆⢿⣿⠃⢸⣿⠏⠀⠀⠿⣷⣤⠾⠋⣾⡟⠀⠀⢠⣿⠇⠸⣿⡴⢫⣿⠇⢠⣤⡄⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.