bri*_*lez 10
找到一个ttfunk可以在这里找到的Ruby gem .
在a之后gem install ttfunk,您可以通过运行以下脚本来获取所有unicode字符:
require 'ttfunk'
file = TTFunk::File.open("path/to/font.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) }
puts "\n -- Found #{unicode_chars.length} characters in this font \n\n"
p unicode_chars
Run Code Online (Sandbox Code Playgroud)
这将输出如下内容:
- Found 2815 characters in this font
["20", "21", "22", "23", ... , "fef8", "fef9", "fefa", "fefb", "fefc", "fffc", "ffff"]
Run Code Online (Sandbox Code Playgroud)