summaryrefslogtreecommitdiff
path: root/renumber.pl
diff options
context:
space:
mode:
authorJens Schweikhardt <schweikh@schweikhardt.net>2025-08-18 23:25:41 +0200
committerJens Schweikhardt <schweikh@schweikhardt.net>2025-08-18 23:25:41 +0200
commit88ad7de6e6ba2c2af1d58ebb556cc62442660564 (patch)
tree4534855b0821d5191b85c4d7cf6c23fa713849d4 /renumber.pl
parent3a25bd58be72b77b677e41ae5ef25005e168aa1f (diff)
First cut.
Diffstat (limited to 'renumber.pl')
-rwxr-xr-xrenumber.pl47
1 files changed, 47 insertions, 0 deletions
diff --git a/renumber.pl b/renumber.pl
new file mode 100755
index 0000000..bc2b6ab
--- /dev/null
+++ b/renumber.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+
+use v5.36;
+use warnings;
+use diagnostics;
+use strict;
+use utf8;
+use open qw(:std :encoding(UTF-8));
+use charnames ':full';
+
+my $width = 12;
+my $height = 22;
+my $dblwidth = 2 * $width;
+
+my $lnr = 0;
+my $n = $height;
+while (<>) {
+ chop;
+ ++$lnr;
+ if (/^STARTCHAR\s+[Uu]\+([[:xdigit:]]+)/) {
+ my $cp = hex $1;
+ my $name = charnames::viacode ($cp) // '<no name>';
+ $_ = sprintf "STARTCHAR U+%04x %s", $cp, $name;
+ }
+ elsif (/^[[:digit:]]+ \|(.{$width})\|/) {
+ $_ = sprintf "%02d |%s|", $n--, $1;
+ }
+ elsif (/^[[:digit:]]+ \|(.{$dblwidth})\|/) {
+ $_ = sprintf "%02d |%s|", $n--, $1;
+ }
+ elsif (/^ENDCHAR$/) {
+ if ($n != 0) {
+ my $N = 22 - $n;
+ print STDERR
+ "line $lnr: ENDCHAR after $N bitmap rows, expected $height\n";
+ exit 1;
+ }
+ $n = $height;
+ }
+ else {
+ print STDERR "line $lnr: unrecognized input: '$_'\n";
+ exit 1;
+ }
+ print "$_\n";
+}
+
+# vi: set tabstop=2 shiftwidth=2 expandtab fileformat=unix: