3
# Script to convert http://www.unicode.org/Public/UNIDATA/Scripts.txt
4
# into a machine-readable table.
6
######################################################################
9
die "Usage: gen-script-table.pl Scripts.txt > pango-script-table.h\n";
12
open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n";
24
if (/^\#\s+(Scripts-.*.txt)/) {
30
if (!/^([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s*;\s*([A-Za-z_]+)\s*$/) {
31
die "Cannot parse line: '$_'\n";
35
push @ranges, [ hex $1, hex $2, uc $3 ];
37
push @ranges, [ hex $1, hex $1, uc $3 ];
41
@ranges = sort { $a->[0] <=> $b->[0] } @ranges;
45
/* pango-script-table.h: Generated by gen-script-table.pl
58
static const guchar pango_script_easy_table[$easy_range] = {
64
for (my $c = 0; $c < $easy_range; $c++) {
71
$start = $ranges[$i]->[0];
72
$end = $ranges[$i]->[1];
73
$script = $ranges[$i]->[2];
78
printf " PANGO_SCRIPT_UNKNOWN,";
80
printf " PANGO_SCRIPT_%s,", $script;
84
if ($end >= $easy_range) {
86
$ranges[$i]->[0] = $easy_range;
98
} pango_script_table[] = {
101
for (; $i <= $#ranges; $i++) {
102
$start = $ranges[$i]->[0];
103
$end = $ranges[$i]->[1];
104
$script = $ranges[$i]->[2];
106
while ($i <= $#ranges - 1 &&
107
$ranges[$i + 1]->[0] == $end + 1 &&
108
$ranges[$i + 1]->[2] eq $script) {
110
$end = $ranges[$i]->[1];
113
printf " { %#06x, %5d, PANGO_SCRIPT_%s },\n", $start, $end - $start + 1, $script;