Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TTF のフォントデータから含まれる文字をすべて出力する
#!/usr/bin/env ruby
# base:
require 'ttfunk'
ttf_file = ARGV.shift
ttf = ttf_file
cmap = ttf.cmap
chars = {}
unicode_chars = []
cmap.tables.each do |subtable|
next if !subtable.unicode?
chars = chars.merge( subtable.code_map )
unicode_chars ={ |dec| dec.chr("UTF-8") }.uniq
puts unicode_chars.join('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment