解决方法
找到一个名为ttfunk的Ruby gem,可以找到
here.
在gem安装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
- Found 2815 characters in this font ["20","21","22","23",...,"fef8","fef9","fefa","fefb","fefc","fffc","ffff"]