aboutsummaryrefslogtreecommitdiff
path: root/fonts/dupglyphs.pl
diff options
context:
space:
mode:
Diffstat (limited to 'fonts/dupglyphs.pl')
-rw-r--r--fonts/dupglyphs.pl42
1 files changed, 42 insertions, 0 deletions
diff --git a/fonts/dupglyphs.pl b/fonts/dupglyphs.pl
new file mode 100644
index 0000000..0532522
--- /dev/null
+++ b/fonts/dupglyphs.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/perl -w
+
+# read a psftools .txt font, for any glyph that has multiple Unicode
+# codepoints, output that glyph multiple times (one per codepoint).
+# result is suitable for conversion to a BDF.
+
+$glyphcount = 0;
+
+sub dup {
+ my $orig = shift;
+ my $new;
+ my $ret;
+ my @cps = ($orig =~ /\[(\w+)\];/g);
+
+ for my $cp (@cps) {
+ #warn ">> $cp <<\n";
+ $glyphcount++;
+ ($new = $orig) =~ s,(Unicode: ).*,$1\[$cp\];,;
+ $ret .= $new;
+ }
+ return $ret;
+}
+
+$/ = '%';
+
+<>;
+$header = '%' . <>;
+
+$zerocount = 0;
+while(<>) {
+ next if /\[0000\];/ && ($zerocount++);
+ if(/Unicode:.*;.*;/) {
+ $_ = dup($_);
+ } else {
+ $glyphcount++;
+ }
+ $output .= $_;
+}
+
+$header =~ s/(Length:\s+)\d+/$1$glyphcount/;
+
+print $header . $output;