travis: weirdpaste.i now has better line directives
[nasm.git] / doc / pswidth.ph
bloba2a90856298df6465cbbb4184414b23d714bde8e
1 #!/usr/bin/perl
3 # Get the width of a PostScript string in PostScript points (1/72")
4 # given a set of font metrics and an encoding vector.
6 sub ps_width($$$) {
7 my($str, $met, $encoding) = @_;
8 my($w) = 0;
9 my($i,$c,$p);
11 $l = length($str);
12 undef $p;
13 for ( $i = 0 ; $i < $l ; $i++ ) {
14 $c = substr($str,$i,1);
15 $w += $$met{widths}{$encoding->[ord($c)]};
16 # The standard PostScript "show" operator doesn't do kerning.
17 # $w += $$met{kern}{$p.$c};
18 $p = $c;
21 return $w / $met->{scale};
24 # OK