4 title => 'character support sheet',
7 unicode glyph char character reference common ipa symbol sign mark table digraph
9 stylesheet => [qw'light dark mono circus red'],
10 data => [qw'unicode-table.inc.pl unicode-char.inc.pl'],
14 <h1>Character support</h1>
17 Selected characters from Unicode <a href="/unicode">preset</a>
18 or <a href="/charset">range</a>.
25 use Shiar_Sheet::FormatChar;
26 my $glyphs = Shiar_Sheet::FormatChar->new;
29 win95 => [qw( arial ariuni verdana times )], # microsoft
30 mac10 => [qw( )], # apple
31 android => [qw( droidsans )], # google
32 oss => [qw( dvsans c2k unifont )],
34 my @ossel = qw( win95 oss android );
36 my $tables = do 'unicode-table.inc.pl' or die $@ || $!;
37 my (%font, @fontlist);
39 my $osfonts = $oslist{$os};
40 for my $fontid (@{$osfonts}) {
41 push @fontlist, $fontid;
42 my ($fontmeta, @fontrange) = do "ttfsupport/$fontid.inc.pl";
45 -id => $fontmeta->{id} || $fontid,
46 -name => $fontmeta->{name},
47 map { (chr $_ => 1) } @fontrange
57 my $query = $ENV{PATH_INFO} || $get{q} || 'ipa';
60 when (qr{^[a-z]+(?:/|\z)}) {
62 push @querydesc, "preset group $_";
63 my ($tablegroup, $tablename) = split m{/}, $_, 2;
64 my @tables = $tablename ? $tables->{$tablegroup}->{$tablename}
65 : sort values %{ $tables->{$tablegroup} };
67 my $includerows; # ignore rows before body row
69 $includerows ||= m/^[.]/ or next;
71 next if $_ eq '>' or $_ eq '=';
77 when (qr{[\d,;\s+-]+}) {
78 push @querydesc, "character codepoints $_";
79 for (map { split /[^\d-]/ } $_) {
80 my ($charnum, $range) = split /-/, $_;
81 push @chars, chr $_ for $charnum .. ($range // $charnum);
85 push @querydesc, "unicode match $_";
87 my $match = qr/\A\p{$_}\z/;
88 push @chars, grep { m/$match/ } map { chr $_ }
89 0..0xD7FF, 0xE000..0xFDCF, 0xFDF0..0xFFFD;
90 } or die "invalid unicode match: $_\n";
93 die "unknown parameter: $_\n";
97 @chars <= 1500 or die sprintf(
98 'too many matches (%d) for %s'."\n",
99 scalar @chars, join(', ', @querydesc),
102 # output character list
104 print '<table class=mapped>';
105 say '<caption>'.EscapeHTML(join ', ', @querydesc).'</caption>';
107 print "<colgroup span=$_>" for 2, map { scalar @{$oslist{$_}} } @ossel;
110 print '<td colspan=3>character';
111 print '<td colspan=2>input';
112 printf '<td colspan=%d>%s fonts', scalar @{ $oslist{$_} }, $_
116 print '<td colspan=2>unicode';
118 print '<td><a href="/digraphs" title="digraph">di</a><td>html';
119 printf '<td title="%s">%s', $font{$_}->{-name}, $font{$_}->{-id} // $_
123 for my $chr (@chars) {
124 my $codepoint = ord $chr;
125 my $ascii = $codepoint <= 127;
127 print "<tr><th>$chr\n";
128 my $info = $glyphs->glyph_info($codepoint);
129 my ($class, $name, $mnem, $html, $string) = @$info;
130 print "<td>$_" for sprintf('%X', $codepoint), EscapeHTML($name || '?');
131 printf '<td class="%s">%s', @$_ for (
132 [$ascii ? 'l0' : defined $mnem ? 'l4' : 'l1', $mnem // ''],
133 [$ascii ? 'l0' : defined $html ? 'l4' : 'l1', $html // ''],
135 !$font{$_}->{-id} ? [l0 => '?'] :
136 $font{$_}->{$chr} ? [l4 => '✔'] : [l1 => '✘']