在基于Debian的系统上,怎样才能找到一个Unicode字体的字形? [英] How can one find the Unicode codepoints that a font has glyphs for, on a Debian-based system?

查看:187
本文介绍了在基于Debian的系统上,怎样才能找到一个Unicode字体的字形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从基于Debian系统的脚本语言(Python或者Ruby)来说,我想找到以下任何一种:


  1. 所有Unicode代码点,特定字体都有字形

  2. 所有为特定Unicode代码点设置字形的字体

(显然,1或2可以从另一个派生出来,所以更简单的事情会更好)。我过去曾经这样做过:

  fc-list:file charset 

..并根据 fontconfig
但在我看来,这应该是一个更简单的方法做到这一点。

(我不完全确定这是正确的StackExchange网站的这个问题,但我正在寻找一个答案,可以用编程方式。)

解决方案 FreeType 2语言绑定。下面是一个使用 Font :: FreeType 列出字体的Unicode代码点的Perl解决方案:

 使用Font :: FreeType; 
Font FreeType-> new-> face('DejaVuSans.ttf') - > foreach_char(sub {
printf(%04X \ n,$ _-> char_code );
});


From a scripting language (Python or Ruby, say) on a Debian-based system, I would like to find either one of:

  1. All the Unicode codepoints that a particular font has glyphs for
  2. All the fonts that have glyphs for a particular Unicode codepoint

(Obviously either 1 or 2 can be derived form the other, so whatever is easier would be great.) I have done this in the past by running:

fc-list : file charset

... and parsing the output at the end of each line, based on this code from fontconfig but it seems to me that there ought to be a much simpler way of doing this.

(I'm not completely sure this is the right StackExchange site for this question, but I am looking for an answer that can be used programmatically.)

解决方案

I would try any of the FreeType 2 language bindings. Here's a Perl solution to list the Unicode code points of a font using Font::FreeType:

use Font::FreeType;
Font::FreeType->new->face('DejaVuSans.ttf')->foreach_char(sub {
    printf("%04X\n", $_->char_code);
});

这篇关于在基于Debian的系统上,怎样才能找到一个Unicode字体的字形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆