Skip to content

Instantly share code, notes, and snippets.

@leftaroundabout
Created December 28, 2017 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leftaroundabout/f09cecbdb39c39fc19fc8f560ad8939d to your computer and use it in GitHub Desktop.
Save leftaroundabout/f09cecbdb39c39fc19fc8f560ad8939d to your computer and use it in GitHub Desktop.
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
Copy link
Author

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