5 title => 'character support sheet',
8 unicode font glyph char character support overview cover coverage
9 script block symbol sign mark reference table
11 stylesheet => [qw( light dark mono circus red )],
12 data => [qw( unicode-cover.inc.pl )],
15 if (my $font = $ENV{PATH_INFO} =~ s{^/}{}r) {
16 my ($fontmeta, @cover) = do "ttfsupport/$font.inc.pl";
17 $fontmeta or die "Unknown font $font\n";
24 local $_ = $get{q} || 0;
25 return $_ if /\A\d+\z/; # numeric
26 return hex $1 if /\A (?: 0?x | u\W* ) ([0-9a-f]+) \z/ix; # hexadecimal
27 return $_->[0]->[0] for Unicode::UCD::charblock(ucfirst) || (); # block
28 die "Unknown offset query '$_'\n";
32 say "<h1>Font coverage</h1>";
33 say "<h2>$_</h2>" for EscapeHTML($fontmeta->{name});
34 printf("<p>Version <strong%s>%s</strong> released %s contains %d glyphs.</p>\n",
35 !!$_->[2] && qq( title="revision $_->[2]"),
40 ($fontmeta->{date} || '?') =~ s/T.*//r,
41 EscapeHTML($fontmeta->{version}),
42 $fontmeta->{revision},
44 printf "<p>%s</p>\n", join('<br>', map { $_ ? EscapeHTML($_) : () }
45 $fontmeta->{copyright}, $fontmeta->{license},
48 require Shiar_Sheet::FormatChar;
49 my $glyphs = Shiar_Sheet::FormatChar->new;
51 my %cover = map { ($_ => 1) } @cover; # lookup map
56 .glyphs tbody th[!colspan] { text-align: right }
57 .glyphs tbody td { font-family: "$fontmeta->{name}" }
60 say '<table class="glyphs big">';
62 say "<caption>$_</caption>" for join(' ', grep {$_}
63 $offset > $pagerows && sprintf('<a rel="start" href="?q=%d">◄</a>', 0),
64 $offset > 0 && sprintf(
65 '<a rel="prev" href="?q=%d" title="U+%1$04X">◅</a>',
68 sprintf('U+%04X', $offset),
69 Unicode::UCD::charblock($offset),
70 $offset + $pagerows < 0x11_0000 && sprintf(
71 '<a rel="next" href="?q=%d" title="U+%1$04X">▻</a>',
76 for my $cp ($offset .. $offset+$pagerows-1) {
78 my $block = Unicode::UCD::charblock($cp);
80 if ($sameblock and $sameblock ne $block and $block ne 'No_Block') {
81 say sprintf '<tbody><tr><th colspan=%d>%s', $pagecols+1, $block;
87 if (my $gap = $cp % $pagecols) {
88 say sprintf '<tr><th>%X<th colspan=%d>', $cp, $gap;
92 say sprintf '<tr><th>%X', $cp if $cp % $pagecols == 0;
94 my $info = $glyphs->glyph_info($cp);
95 my ($class, $name, $mnem, $html, $string) = @{$info};
96 my $np = $class =~ /\bC\S\b/; # noprint if control or invalid
97 say sprintf '<td class="%s" title="U+%04X%s">%s',
98 !$class ? ('l0', $cp, '', '') :
99 $cover{$cp} ? $np ? 'l2' : 'l5' : $np ? 'Xi' : 'l1',
100 $cp, !!$name && ": $name",
101 ($cover{$cp} || !$np) && EscapeHTML(chr $cp);
109 <h1>Font coverage</h1>
112 Character support of Unicode
113 <a href="/charset">blocks</a> and <a href="/unicode">presets</a>.
120 my $cover = do 'unicode-cover.inc.pl' or die $@ || $!;
122 my @ossel = @{ $cover->{osdefault} };
123 my @fontlist = map { @{ $cover->{os}->{$_} } } @ossel;
126 'block/Latin-1 Supplement',
127 'block/Latin Extended-A',
128 'block/Latin Extended Additional',
129 'block/Latin Extended-B',
144 'category/Sc', # currency
146 'category/Sm', # mathematical
147 'table/arrows/single',
148 'table/lines/single',
154 if (my $group = $get{q}) {
155 my $grouprows = $cover->{$group}
156 or die "Unknown character category $_\n";
157 @rows = map { "$group/$_" } sort keys %{$grouprows};
160 # output character list
162 print '<table class=mapped>';
164 print "<colgroup span=$_>"
165 for map { scalar @{ $cover->{os}->{$_} } } @ossel;
168 print '<th colspan=2>';
169 printf '<td colspan=%d>%s fonts', scalar @{ $cover->{os}->{$_} }, $_
173 print '<th colspan=2>';
174 printf('<td title="%s"><a href="%s">%s</a>', map { EscapeHTML($_) }
175 join("\n", $_->{name}, $_->{description}),
178 ) for @{ $cover->{fonts} }[@fontlist];
182 my ($group, $name) = split m{/}, $_, 2;
183 my $row = $cover->{$group}->{$name};
186 $name = sprintf '<a href="%s">%s</a>', EncodeURI("/chars/$group/$name"), EscapeHTML($name)
187 if $row->{count} and $row->{count} < 1280;
189 print '<td class=right>', $row->{count};
190 for my $count (@{ $row->{support} }[@fontlist]) {
191 if (not defined $count) {
192 print '<td class="l0">?';
196 print '<td class="l1">✘';
199 if ($count == $row->{count}) {
200 print '<td class="l5">✔';
204 my $rel = $count / $row->{count};
205 my $class = $rel < .5 ? 2 : $rel < .9 ? 3 : 4;
206 printf '<td class="%s">%d%%', "l$class", $rel*100;