What unit is "advanced" stored in for True Type fonts table "hmtx"? -


i running simple script wrote "advance" of true type fonts. font in specific new times roman. kind of values i'm getting back,

{    "a" : 1479    "a" : 909,    "b" : 1366,    "b" : 1024    "c" : 1366,    "c" : 909,    "n" : 1479,    "n" : 1024,    "m" : 1821,    "m" : 1593,    "." : 512, } 

i'm using perl library font::ttf, can find manual here. and, here script,

use strict; use warnings; use autodie; use font::ttf::font;  $f = font::ttf::font->open('/usr/share/fonts/truetype/msttcorefonts/times_new_roman.ttf')   || die $!;  $json = json::xs->new->ascii->pretty->allow_nonref;  @chars = ( '.', '-', 'a'...'z', 'a'...'z', 0..9 );  %db; foreach $char ( @chars ) {   $ord = ord($char);   $snum = $f->{'cmap'}->ms_lookup($ord);   $f->{'hmtx'}->read;   $sadv = $f->{'hmtx'}{'advance'}[$snum];   $db{$char} = $sadv; }  use json::xs qw(encode_json); print $json->encode( \%db ); 

it's in "units-per-em" [1]. grid of glyph design space side of size defined in head tag under "unitsperem". truetype has 2048, .otf postscript outlines 1000. if want useful, take size of font, multiply advance , divide unitsperem.

[1] http://en.wikipedia.org/wiki/em_(typography)


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -