Skip to content

Instantly share code, notes, and snippets.

@youpy
Created August 9, 2012 16:51
Show Gist options
  • Save youpy/3305827 to your computer and use it in GitHub Desktop.
Save youpy/3305827 to your computer and use it in GitHub Desktop.
generate image for TEE PARTY
# -*- coding: utf-8 -*-
require 'shellwords'
require 'nokogiri'
require 'open-uri'
def main
unicode, font_path, file = ARGV
info = info(unicode)
abort unless info.name
# brew instal graphicsmagick
system(*%W(gm convert
-debug annotate
-trim
-font #{e(font_path)}
-background white
-size 2924x3990
-resize 2924x3990
-gravity center
-extent 2924x3990
label:#{[unicode.to_i(16)].pack("U")}
-fill black
-transparent white
#{e(file)}))
end
def e(str)
Shellwords.escape(str)
end
def info(unicode)
doc = Nokogiri::HTML(open('http://www.fileformat.info/info/unicode/char/%s/index.htm' % unicode.downcase))
Struct.new(:name, :code).new(*doc.title.scan(/'(.+)' \((U\+[\dA-F]+)/)[0])
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment