Skip to content

A little toy program to render chinese characters (or any unicode characters) to the terminal as ASCII art.

Notifications You must be signed in to change notification settings

caseymcrane/hanzi-ascii

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hanzi-ascii

This is just a little program I made for fun to display a 4 character chinese idiom (a chengyu) in the terminal. Right now it just prints to standard output but I'd like to refactor it to use ncurses.

It works by reading Unicode characters from a text file called 'hz', loading them in as freetype glyphs, rendering them as bitmaps at twice the print resolution, and then uses a cool sampling method to print them in monochrome ASCII using 16 different Unicode block elements. In this sense, it is perhaps misleading to call this "ASCII art", but I think it fits the spirit.

My favorite part of this project is the way it samples 4 "pixels" at a time and uses bitwise operations in C to map each 2x2 grid to the corresponding block character without any branches or if statements of any kind. I felt quite proud after writing that :-)

About

A little toy program to render chinese characters (or any unicode characters) to the terminal as ASCII art.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages