aboutsummaryrefslogtreecommitdiff
path: root/rename
diff options
context:
space:
mode:
authorJohn Ankarstr\xf6m <john@ankarstrom.se>2021-06-03 14:33:06 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-08 19:52:05 +0200
commitd4b1ddbeebc469d9696e0877cc6bf1d21663eccf (patch)
tree09b876b6ce6550975ca9115126a575d89a10d770 /rename
downloadfnt-d4b1ddbeebc469d9696e0877cc6bf1d21663eccf.tar.gz
Convert ttf -> dit for (g)troff
Diffstat (limited to 'rename')
-rwxr-xr-xrename31
1 files changed, 31 insertions, 0 deletions
diff --git a/rename b/rename
new file mode 100755
index 0000000..e8a87e0
--- /dev/null
+++ b/rename
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+# rename -- automatically rename ditroff file
+
+sub usage {
+ die "usage: $0 [-n] family file\n";
+}
+
+usage if @ARGV != 2 and @ARGV != 3;
+if ($ARGV[0] eq '-n') {
+ $test = 1;
+ usage if @ARGV != 3;
+}
+$family = $ARGV[-2];
+$file = $ARGV[-1];
+
+die "family '$family' should begin with capital letter\n"
+ unless $family =~ /^[A-Z]+$/ or $family =~ m{/[A-Z]+$};
+
+for ($file) {
+ $family .= 'B' if (/Bold/);
+ $family .= 'I' if (/Italic/);
+ $family .= 'I' if (/Oblique/);
+ $family .= 'R' if $family eq $ARGV[-1];
+}
+
+if ($test) {
+ print "$file -> $family\n";
+} else {
+ rename $file, $family;
+}