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