Created
May 19, 2016 07:11
-
-
Save ArsnealX/4d9e2fbfc4c2d73fc1ac05dd0471477e to your computer and use it in GitHub Desktop.
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
equire 'ttfunk' | |
file = TTFunk::File.open("/path/to/fontfile.ttf") | |
cmap = file.cmap | |
chars = {} | |
unicode_chars = [] | |
cmap.tables.each do |subtable| | |
next if !subtable.unicode? | |
chars = chars.merge( subtable.code_map ) | |
end | |
unicode_chars = chars.keys.map{ |dec| [dec.to_s(16).hex].pack('U') } | |
puts "\n -- Found #{unicode_chars.length} characters in this font \n\n" | |
p unicode_chars | |
File.open('/path/to/outputs.txt', 'w').write unicode_chars.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment