spec: change License to BSD
[nasm/avx512.git] / doc / pswidth.ph
blob36fc07aade12b062c342fadb1e66f7a7cb3c4d2e
1 #!/usr/bin/perl
3 # Get the width of a PostScript string in font units
4 # (1000 font units == the font point height) given a set of
5 # font metrics and an encoding vector.
7 sub ps_width($$$) {
8 my($str, $met, $encoding) = @_;
9 my($w) = 0;
10 my($i,$c,$p);
12 $l = length($str);
13 undef $p;
14 for ( $i = 0 ; $i < $l ; $i++ ) {
15 $c = substr($str,$i,1);
16 $w += $$met{widths}{$encoding->[ord($c)]};
17 # The standard PostScript "show" operator doesn't do kerning.
18 # $w += $$met{kern}{$p.$c};
19 $p = $c;
22 return $w;
25 # OK