diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-05-14 21:59:59 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-05-14 21:59:59 +0000 |
commit | 4ca9e3c0e4e605b09b761ab8d13c82d900e16ba6 (patch) | |
tree | 911ef0debafde0cd3351549a62fbb7623d4bad9a /doc/pswidth.ph | |
parent | b99d5553cc79adbdba62faeffd4d66fea3c294cb (diff) | |
download | nasm-4ca9e3c0e4e605b09b761ab8d13c82d900e16ba6.tar.gz nasm-4ca9e3c0e4e605b09b761ab8d13c82d900e16ba6.tar.bz2 nasm-4ca9e3c0e4e605b09b761ab8d13c82d900e16ba6.zip |
Work in progress: new PostScript/PDF generator back end
Diffstat (limited to 'doc/pswidth.ph')
-rw-r--r-- | doc/pswidth.ph | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/pswidth.ph b/doc/pswidth.ph new file mode 100644 index 0000000..b3fd736 --- /dev/null +++ b/doc/pswidth.ph @@ -0,0 +1,26 @@ +#!/usr/bin/perl +# +# Get the width of a PostScript string in font units +# (1000 font units == the font point height) given a set of +# font metrics. +# +sub ps_width($$) { + my($str, $met) = @_; + my($w) = 0; + my($i,$c,$p); + + $l = length($str); + undef $p; + for ( $i = 0 ; $i < $l ; $i++ ) { + $c = substr($str,$i,1); + $w += $$met{widths}[ord($c)]; + # The standard PostScript "show" operator doesn't do kerning. + # $w += $$met{kern}{$p.$c}; + $p = $c; + } + + return $w; +} + +# OK +1; |