Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pkg/* | ||
*.gem | ||
.bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# AnsiArt | ||
|
||
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. | ||
|
||
I saw there are some code to use `gd2` gem in ruby 1.8.x. I think that doesn't work. | ||
|
||
## Requirement | ||
|
||
* Ruby 1.9.2 or above | ||
* libgd | ||
|
||
## Installation | ||
|
||
It's not on rubygems.org yet. Just clone the git reposiory and execute. | ||
|
||
rake install | ||
|
||
## Example: Get it working | ||
|
||
Put a `uming.tcc` font file in your working directory. | ||
In Ubuntu it might be at `/usr/share/fonts/truetype/arphic/uming.ttc`. | ||
|
||
Download a ansi file: | ||
|
||
wget http://ansi.loli.tw/ansiarts/static/803.ans | ||
|
||
And here is the ruby snippet: | ||
|
||
require 'rubygems' | ||
gem 'ansi_art' | ||
require 'ansi_art' | ||
|
||
c = AnsiArt::Document.new(IO.read('803.ans')) | ||
html = c.to_html | ||
File.open('out.html', 'w') { |f| f.write(html) } | ||
png = c.to_png | ||
File.open('out.png', 'wb') { |f| f.write(png) } | ||
|
||
You should see `out.html` and `out.png` in your working directory. | ||
|