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.",
35 !!$_->[2] && qq( title="revision $_->[2]"),
40 ($fontmeta->{date} || '?') =~ s/T.*//r,
41 EscapeHTML($fontmeta->{version}),
42 $fontmeta->{revision},
44 for ($fontmeta->{os}) {
46 print ucfirst join(' ',
48 (map { "by $_" } $fontmeta->{oscorp} || "various sources"),
49 (map { "with <em>$_</em>" } $_ || ()),
50 ('and published as freeware "Core Web font"') x ($_ eq 'Windows 2000'),
51 (map { "under a $_ license" }
52 map { $fontmeta->{license} ? qq(<a href="$fontmeta->{license}">$_</a>) : $_ }
53 $_ && $_ ne 'Android' ? 'proprietary' : 'free',
59 say "<p>$_</p>" for EscapeHTML($fontmeta->{copyright}) || ();
61 require Shiar_Sheet::FormatChar;
62 my $glyphs = Shiar_Sheet::FormatChar->new;
64 my %cover = map { ($_ => 1) } @cover; # lookup map
69 .glyphs tbody th[!colspan] { text-align: right }
70 .glyphs tbody td { font-family: "$fontmeta->{name}" }
71 .glyphs tbody td:nth-child(18) { border-left-width: 2px }
73 font-family: "$fontmeta->{name}";
74 src: url(/data/font/$font.ttf);
78 say '<table class="glyphs big">';
80 say "<caption>$_</caption>" for join(' ', grep {$_}
81 $offset > $pagerows && sprintf('<a rel="start" href="?q=%d">◄</a>', 0),
82 $offset > 0 && sprintf(
83 '<a rel="prev" href="?q=%d" title="U+%1$04X">◅</a>',
86 sprintf('U+%04X', $offset),
87 Unicode::UCD::charblock($offset),
88 $offset + $pagerows < 0x11_0000 && sprintf(
89 '<a rel="next" href="?q=%d" title="U+%1$04X">▻</a>',
94 for my $cp ($offset .. $offset+$pagerows-1) {
96 my $block = Unicode::UCD::charblock($cp);
97 if ($block ne (state $sameblock = $block) and $block ne 'No_Block') {
99 printf '<tr><th colspan=%d>%s', $pagecols+1, $block
100 unless $block eq 'No_Block';
106 say sprintf '<tr><th>%X', $cp if $colpos++ % $pagecols == 0;
108 my $info = $glyphs->glyph_info($cp);
109 my ($class, $name, $mnem, $html, $string) = @{$info};
110 my $np = $class =~ /\bC\S\b/; # noprint if control or invalid
111 # display literal character, with placeholder circle if non-spacing/enclosing
112 my $html = ($class =~ /\bM[ne]\b/ && chr 9676) . EscapeHTML(chr $cp);
113 say sprintf '<td class="%s" title="U+%04X%s">%s',
114 !$class ? ('l0', $cp, '', '') :
115 $cover{$cp} ? $np ? 'l2' : 'l5' : $np ? 'Xi' : 'l1',
116 $cp, !!$name && ": $name",
117 ($cover{$cp} || !$np) && $html;
125 <h1>Font coverage</h1>
128 Character support of Unicode
129 <a href="/charset">blocks</a> and <a href="/unicode">presets</a>.
136 my $cover = do 'unicode-cover.inc.pl' or die $@ || $!;
138 my @ossel = @{ $cover->{osdefault} };
139 my @fontlist = map { @{ $cover->{os}->{$_} } } @ossel;
144 'block/Latin-1 Supplement',
145 'block/Latin Extended-A',
146 'block/Latin Extended Additional',
147 'block/Latin Extended-B',
162 'category/Sc', # currency
164 'category/Sm', # mathematical
165 'table/arrows/single',
166 'table/lines/single',
172 if (my $group = $get{q}) {
173 my $grouprows = $cover->{$group}
174 or die "Unknown character category $_\n";
175 @rows = map { "$group/$_" } sort keys %{$grouprows};
178 # output character list
180 print '<table class=mapped>';
182 print "<colgroup span=$_>"
183 for map { scalar @{ $cover->{os}->{$_} } } @ossel;
186 print '<th colspan=2>';
187 for my $os (@ossel) {
188 my $osfonts = $cover->{os}->{$os};
189 my $osfont = $cover->{fonts}->[ $osfonts->[0] ]; # first font
190 printf '<td colspan=%d>%s', scalar @{$osfonts}, $osfont->{os} || ''
194 print '<th colspan=2>';
195 printf('<td title="%s"><a href="%s">%s</a>', map { EscapeHTML($_) }
196 join("\n", $_->{name}, $_->{description}),
199 ) for @{ $cover->{fonts} }[@fontlist];
203 my ($group, $name) = split m{/}, $_, 2;
204 my $row = $cover->{$group}->{$name};
207 $name = sprintf 'Unicode v%.1f', $name / 10 if $group eq 'version';
208 $name = sprintf '<a href="%s">%s</a>', EncodeURI("/chars/$group/$name"), EscapeHTML($name)
209 if $row->{count} and $row->{count} < 1280;
211 print '<td class=right>', $row->{count};
212 for my $count (@{ $row->{support} }[@fontlist]) {
213 if (not defined $count) {
214 print '<td class="l0">?';
218 print '<td class="l1">✘';
221 if ($count == $row->{count}) {
222 print '<td class="l5">✔';
226 my $rel = $count / $row->{count};
227 my $class = $rel < .5 ? 2 : $rel < .9 ? 3 : 4;
228 printf '<td class="%s">%d%%', "l$class", $rel*100;