Skip to content

Instantly share code, notes, and snippets.

@ohwgiles
Created November 10, 2013 12:52
Show Gist options
  • Save ohwgiles/7397880 to your computer and use it in GitHub Desktop.
Save ohwgiles/7397880 to your computer and use it in GitHub Desktop.
test whether a font contains a glyph for a specified unicode character
#!/usr/bin/perl
# Reading fields from standard input, omit lines which contain
# a character which is absent in the specified font
# Make sure perl is invoked correctly (see PERL_UNICODE)
use Font::TTF::Font;
my $fontPath = "/usr/share/fonts/Adobe/AdobeKaitiStd.otf";
my $font = Font::TTF::Font->open($fontPath);
while(<>) {
($cjCode, $utf8) = split(" ");
print if $font->{cmap}->ms_lookup(unpack('U', $utf8));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment