File: adjust

package info (click to toggle)
xfonts-mona 2.90-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 7,888 kB
  • sloc: perl: 11,238; makefile: 442; lisp: 68
file content (31 lines) | stat: -rwxr-xr-x 608 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env perl
# $Id: adjust,v 1.2 2002/09/14 20:34:39 euske Exp $

# * public domain * by 1@2ch

# usage: ./adjust file.wid < IN > OUT

# read
open(W, $ARGV[0]) || die("cannot open");
while(<W>) {
    @f = split(' ', $_);
    $wid{$f[0]} = $f[1];
}
close(W);

$enc = 0;
while(<STDIN>) {
    if (/^ENCODING +([0-9]+)/) {
	$enc = $1;
    } elsif (/^DWIDTH +([0-9]+) +([0-9]+)/) {
	if ($enc < 10000) {
	    $wid2 = $wid{$enc};
	} else {
	    $wid2 = $wid{'0'};
	}
	if ($wid2 && $wid2 != $1) {
	    $_ = "DWIDTH " . $wid2 . " " . $2 . " \# ADJUSTED " . ($wid2 - $1) . "\n";
	}
    }
    print STDOUT $_;
}