new utilities for font analysis
This commit is contained in:
parent
7d76a74f1f
commit
58429bd7ce
5 changed files with 94 additions and 0 deletions
|
@ -55,6 +55,7 @@ SVN trunk (1.1+svn):
|
|||
* (internal) make attack animations work like all other animations
|
||||
* backport latest SDL_ttf change, fix ascender/descender issue for DejaVu
|
||||
* fix crash when using zoom keys in the main lobby
|
||||
* new utils: codecomp codeextract codeglyphs codelist, for font analysis
|
||||
|
||||
Version 1.1:
|
||||
* campaign server
|
||||
|
|
46
utils/codecomp
Executable file
46
utils/codecomp
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/perl
|
||||
# codecomp
|
||||
# compare list of codepoints with a baseline list
|
||||
|
||||
while (<>) {
|
||||
# next unless /codepoints=\"(.*)\"/;
|
||||
# push @cs, [ split /,/, $1 ];
|
||||
push @cs, [ split /,/ ];
|
||||
push @fs, $ARGV;
|
||||
}
|
||||
# hardcode DejaVu codepoint list for now, as baseline
|
||||
# use codeextract to update, this list is from DejaVu 2.2
|
||||
@c = split /,/, '32-126,160-387,390-411,413-414,420-421,423-425,427-430,433,437-438,443,448-468,470,477,479,482-483,490-493,497-499,536-539,555,557-559,561-563,567-569,592-696,699-700,702-705,710-712,716,720-723,726,728-734,736-745,768-819,825-831,865,884-885,890,894,900-906,908,910-929,931-974,976-993,1008-1119,1168-1175,1178-1179,1184-1191,1196-1199,1202-1207,1210-1211,1217-1218,1221-1224,1227-1228,1232-1241,1244-1245,1254-1259,7426,7432-7433,7444,7455,7543,7692-7693,7698-7699,7716-7717,7734-7737,7740-7741,7745-7751,7754-7755,7767,7770-7773,7777-7779,7788-7789,7792-7793,7806-7813,7864-7865,7882-7885,7908-7909,7922-7923,8208-8213,8216-8218,8220-8230,8240-8241,8249-8250,8252-8253,8263-8265,8304,8308-8313,8319,8364,8373,8451,8482,8486-8487,8490-8491,8498,8523,8704,8706-8707,8710-8711,8719-8723,8725,8727-8730,8733-8735,8743-8749,8776,8800-8801,8803-8805,8962,8976-8977,8984-8985,8997,9085,9251,9472-9631,9674,9688,9702,9784,10731,10764-10766,64256-64260,65533';
|
||||
|
||||
#foreach $d ( @cs ) {
|
||||
# print join(',', @$d), "\n";
|
||||
#}
|
||||
|
||||
foreach $d ( @cs ) {
|
||||
$i = 0; $j = 0;
|
||||
my @e;
|
||||
# compare @{$d} and @c, want to find all intersections
|
||||
while ( $c[$i] and $d->[$j] ) {
|
||||
($a,$b) = split /-/, $c[$i];
|
||||
$b = $a unless $b;
|
||||
($x,$y) = split /-/, $d->[$j];
|
||||
$y = $x unless $y;
|
||||
if ( $x <= $b and $a <= $y ) { # intersection
|
||||
my $min = ($a > $x) ? $a : $x;
|
||||
my $max = ($b < $y) ? $b : $y;
|
||||
push @e, $min . (($min != $max) ? "-$max" : '');
|
||||
}
|
||||
++$i if $b <= $y;
|
||||
++$j if $b >= $y;
|
||||
# if $b == $y advance both
|
||||
}
|
||||
push @es, [ @e ];
|
||||
}
|
||||
$i = 0;
|
||||
while ( $es[$i] ) {
|
||||
# if *equal* is flagged, then this codepoint list is covered by DejaVu
|
||||
print "*equal* " if join(',', @{$es[$i]}) eq join(',', @{$cs[$i]});
|
||||
print $fs[$i], ' = ', join(',', @{$es[$i]}), "\n";
|
||||
++$i;
|
||||
}
|
||||
|
11
utils/codeextract
Executable file
11
utils/codeextract
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/perl -n
|
||||
# codeextract
|
||||
# usage: codeextract status.txt | codelist
|
||||
# extracts list of font codes from DejaVu font status.txt file, as a
|
||||
# list of decimal integers suitable as input to codelist
|
||||
|
||||
next if $. < 7; # skip first 6 lines
|
||||
s/ .*//; # get rid of stuff other than codepoint
|
||||
s/^U\+//; # set up number
|
||||
print hex $_, "\n";
|
||||
|
12
utils/codeglyphs
Executable file
12
utils/codeglyphs
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
# codeglyphs
|
||||
# usage: codeglyphs en_GB | codelist
|
||||
# (this should yield something like 10,32-95,97-126,235,243,252)
|
||||
# run this in the main wesnoth directory
|
||||
# expects as input a language code used in LINGUAS
|
||||
# extracts list of glyphs used in translation files, suitable as input
|
||||
# to codelist
|
||||
|
||||
cat `find po -name "$1.po" -print` | \
|
||||
perl -ne 'BEGIN { use Unicode::String } $u = Unicode::String->new($_); push @u, $u->unpack; END { print join("\n",@u), "\n" }' | \
|
||||
sort -nu
|
24
utils/codelist
Executable file
24
utils/codelist
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/perl -n
|
||||
# codelist
|
||||
# given list of integers, one per line, outputs a minimal list of ranges
|
||||
# describing the list
|
||||
|
||||
# this is useful for codepoints that are in a font, based on list of codes
|
||||
# output format is suitable for codepoints="" in Wesnoth fonts.cfg
|
||||
|
||||
#push @n, hex;
|
||||
chomp; push @n, $_;
|
||||
END {
|
||||
foreach (sort { $a <=> $b } @n) {
|
||||
if ($_ == $last + 1) {
|
||||
$last = $_;
|
||||
} else {
|
||||
push @r, ($first == $last) ? "$first" : "$first-$last";
|
||||
$first = $last = $_;
|
||||
}
|
||||
}
|
||||
push @r, ($first == $last) ? "$first" : "$first-$last";
|
||||
shift @r; # get rid of blank first element
|
||||
print join(",", @r), "\n";
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue