4 my $font = $ENV{PATH_INFO} =~ s{^/}{}r;
7 title => 'font coverage '.($font ? "for $font" : 'sheet'),
10 unicode font glyph char character support overview cover coverage
11 script block symbol sign mark reference table
13 stylesheet => [qw( light dark mono circus red )],
14 data => [qw( unicode-cover.inc.pl )],
18 my ($fontmeta, @cover) = do "ttfsupport/$font.inc.pl";
19 $fontmeta or die "Unknown font $font\n";
26 local $_ = $get{q} || 0;
27 return $_ if /\A\d+\z/; # numeric
28 return hex $1 if /\A (?: 0?x | u\W* ) ([0-9a-f]+) \z/ix; # hexadecimal
29 return $_->[0]->[0] for Unicode::UCD::charblock(ucfirst) || (); # block
30 die "Unknown offset query '$_'\n";
34 say "<h1>Font coverage</h1>";
35 say "<h2>$_</h2>" for EscapeHTML($fontmeta->{name});
36 printf("<p>Version <strong%s>%s</strong> released %s contains %d glyphs.",
37 !!$_->[2] && qq( title="revision $_->[2]"),
42 ($fontmeta->{date} || '?') =~ s/T.*//r,
43 EscapeHTML($fontmeta->{version}),
44 $fontmeta->{revision},
46 for ($fontmeta->{os}) {
48 print ucfirst join(' ',
50 (map { "by $_" } $fontmeta->{oscorp} || "various sources"),
51 (map { "with <em>$_</em>" } $_ || ()),
52 ('and published as freeware "Core Web font"') x ($_ eq 'Windows 2000'),
53 (map { "under a $_ license" }
54 map { $fontmeta->{license} ? qq(<a href="$fontmeta->{license}">$_</a>) : $_ }
55 $_ && $_ ne 'Android' ? 'proprietary' : 'free',
61 say "<p>$_</p>" for EscapeHTML($fontmeta->{copyright}) || ();
63 require Shiar_Sheet::FormatChar;
64 my $glyphs = Shiar_Sheet::FormatChar->new;
66 my %cover = map { ($_ => 1) } @cover; # lookup map
71 .glyphs tbody th[!colspan] { text-align: right }
72 .glyphs tbody td { font-family: "$fontmeta->{name}" }
73 .glyphs tbody td:nth-child(18) { border-left-width: 2px }
75 font-family: "$fontmeta->{name}";
76 src: url(/data/font/$font.ttf);
80 say '<table class="glyphs big">';
82 say "<caption>$_</caption>" for join(' ', grep {$_}
83 $offset > $pagerows && sprintf('<a rel="start" href="?q=%d">◄</a>', 0),
84 $offset > 0 && sprintf(
85 '<a rel="prev" href="?q=%d" title="U+%1$04X">◅</a>',
88 sprintf('U+%04X', $offset),
89 Unicode::UCD::charblock($offset),
90 $offset + $pagerows < 0x11_0000 && sprintf(
91 '<a rel="next" href="?q=%d" title="U+%1$04X">▻</a>',
96 for my $cp ($offset .. $offset+$pagerows-1) {
98 my $block = Unicode::UCD::charblock($cp);
99 if ($block ne (state $sameblock = $block) and $block ne 'No_Block') {
101 printf '<tr><th colspan=%d>%s', $pagecols+1, $block
102 unless $block eq 'No_Block';
108 say sprintf '<tr><th>%X', $cp if $colpos++ % $pagecols == 0;
110 my $info = $glyphs->glyph_info($cp);
111 my ($class, $name, $mnem, $html, $string) = @{$info};
112 my $np = $class =~ /\bC\S\b/; # noprint if control or invalid
113 # display literal character, with placeholder circle if non-spacing/enclosing
114 my $html = ($class =~ /\bM[ne]\b/ && chr 9676) . EscapeHTML(chr $cp);
115 say sprintf '<td class="%s" title="U+%04X%s">%s',
116 !$class ? ('l0', $cp, '', '') :
117 $cover{$cp} ? $np ? 'l2' : 'l5' : $np ? 'Xi' : 'l1',
118 $cp, !!$name && ": $name",
119 ($cover{$cp} || !$np) && $html;
127 <h1>Font coverage</h1>
130 Character support of Unicode
131 <a href="/charset">blocks</a> and <a href="/unicode">presets</a>.
138 my $cover = do 'unicode-cover.inc.pl' or die $@ || $!;
140 my @ossel = @{ $cover->{osdefault} };
141 my @fontlist = map { @{ $cover->{os}->{$_} } } @ossel;
146 'block/Latin-1 Supplement',
147 'block/Latin Extended-A',
148 'block/Latin Extended Additional',
149 'block/Latin Extended-B',
164 'category/Sc', # currency
166 'category/Sm', # mathematical
167 'table/arrows/single',
168 'table/lines/single',
174 if (my $group = $get{q}) {
175 my $grouprows = $cover->{$group}
176 or die "Unknown character category $_\n";
177 @rows = map { "$group/$_" } sort keys %{$grouprows};
180 # output character list
182 print '<table class=mapped>';
184 print "<colgroup span=$_>"
185 for map { scalar @{ $cover->{os}->{$_} } } @ossel;
188 print '<th colspan=2>';
189 for my $os (@ossel) {
190 my $osfonts = $cover->{os}->{$os};
191 my $osfont = $cover->{fonts}->[ $osfonts->[0] ]; # first font
192 printf '<td colspan=%d>%s', scalar @{$osfonts}, $osfont->{os} || ''
196 print '<th colspan=2>';
197 printf('<td title="%s"><a href="%s">%s</a>', map { EscapeHTML($_) }
198 join("\n", $_->{name}, $_->{description}),
201 ) for @{ $cover->{fonts} }[@fontlist];
205 my ($group, $name) = split m{/}, $_, 2;
206 my $row = $cover->{$group}->{$name};
209 $name = sprintf 'Unicode v%.1f', $name / 10 if $group eq 'version';
210 $name = sprintf '<a href="%s">%s</a>', EncodeURI("/chars/$group/$name"), EscapeHTML($name)
211 if $row->{count} and $row->{count} < 1280;
213 print '<td class=right>', $row->{count};
214 for my $count (@{ $row->{support} }[@fontlist]) {
215 if (not defined $count) {
216 print '<td class="l0">?';
220 print '<td class="l1">✘';
223 if ($count == $row->{count}) {
224 print '<td class="l5">✔';
228 my $rel = $count / $row->{count};
229 my $class = $rel < .5 ? 2 : $rel < .9 ? 3 : 4;
230 printf '<td class="%s">%d%%', "l$class", $rel*100;