0
트루 타입 글꼴의 "advance"을 얻기 위해 작성한 아주 간단한 스크립트를 실행하고 있습니다. 특정 글꼴은 New Times Roman입니다. 이 :: TTF 내가 다시 받고 있어요 값의 종류, 나는 펄 라이브러리 글꼴을 사용하고트루 타입 글꼴 테이블 "hmtx"에 저장된 "고급"단위는 무엇입니까?
{
"A" : 1479
"a" : 909,
"B" : 1366,
"b" : 1024
"C" : 1366,
"c" : 909,
"N" : 1479,
"n" : 1024,
"M" : 1821,
"m" : 1593,
"." : 512,
}
, 당신은 find the manual here 수 있습니다. 그리고 내 스크립트는 다음과 같습니다.
use strict;
use warnings;
use autodie;
use Font::TTF::Font;
my $f = Font::TTF::Font->open('/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf')
|| die $!;
my $json = JSON::XS->new->ascii->pretty->allow_nonref;
my @chars = ('.', '-', 'a'...'z', 'A'...'Z', 0..9);
my %db;
foreach my $char (@chars) {
my $ord = ord($char);
my $snum = $f->{'cmap'}->ms_lookup($ord);
$f->{'hmtx'}->read;
my $sadv = $f->{'hmtx'}{'advance'}[$snum];
$db{$char} = $sadv;
}
use JSON::XS qw(encode_json);
print $json->encode(\%db);