From 0c7ad993f7f8cffcc3972a6f8e5517fd841051b5 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Thu, 25 Jul 2024 16:48:42 -0400 Subject: fonts: much progress. --- fonts/dupglyphs.pl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 fonts/dupglyphs.pl (limited to 'fonts/dupglyphs.pl') diff --git a/fonts/dupglyphs.pl b/fonts/dupglyphs.pl new file mode 100644 index 0000000..e2e8993 --- /dev/null +++ b/fonts/dupglyphs.pl @@ -0,0 +1,41 @@ +#!/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 = '%' . <>; + +while(<>) { + next if /\[0000\];/; + if(/Unicode:.*;.*;/) { + $_ = dup($_); + } else { + $glyphcount++; + } + $output .= $_; +} + +$header =~ s/(Length:\s+)\d+/$1$glyphcount/; + +print $header . $output; -- cgit v1.2.3