This is a gem for converting Big5-UAO encoded ANSI art to html or PNG, may also works with pure ASCII encoding file.
Latest commit f1c3632 May 9, 2013 @albb0920 Fix high byte become nil if newline in the middle.
TypeError: nil cannot be convert to integer, in Buffer#to_s pack('*C').


This project is under refactoring.

Pending issues:

  • Currently it only supports Ruby 1.9.2 or above because it uses String#encode!
  • It requires uming.ttc font file in current working directory. This is inconvenient.
  • The CSS should be moved somewhere else.
  • Do we need to refine API of AnsiArt::Document. It should be the only API class. All other classes are for internal use. It's nice if we can make its API as generic as possible.

I saw there are some code to use gd2 gem in ruby 1.8.x. I think that doesn't work.


  • Ruby 1.9.2 or above
  • libgd


It's not on yet. Just clone the git reposiory and execute.

rake install

Example: Get it working

This gem requires CJK font AR PL UMing for PNG rendering, which is licensed under Arphic Public License. Put a uming.tcc font file in your working directory.

Ways to find it:

  • In Ubuntu, it might be at /usr/share/fonts/truetype/arphic/uming.ttc.
  • Download it from

Download a ansi file:


And here is the ruby snippet:

require 'rubygems'
gem 'ansi_art'
require 'ansi_art'

doc ='803.ans'))'out.html', 'w') { |f| f.write(doc.to_html) }'out.png', 'wb') { |f| f.write(doc.to_png) }

You should see out.html and out.png in your working directory.

Make HTML display correctly

HTML output needs to be wraped under a <div class="ansi-block"> tag, and apply required css files.


<!doctype html>
    <title>ANSI art test page</title>
    <link href="ansi.css" rel="stylesheet" type="text/css">
    <!--[if IE 9]>
    <link href="ansi.ie9.css" rel="stylesheet" type="text/css">
    <div class="ansi-block">
    <%= c.to_html %>