X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/6b3439ac33bb88d613ac4a3670e14a2c673b3221..133e96335267b12bb7e97d9bbe551a3a043bd32a:/Shiar_Sheet/FormatChar.pm?ds=sidebyside diff --git a/Shiar_Sheet/FormatChar.pm b/Shiar_Sheet/FormatChar.pm index c0a4cb0..f471497 100644 --- a/Shiar_Sheet/FormatChar.pm +++ b/Shiar_Sheet/FormatChar.pm @@ -8,23 +8,34 @@ use utf8; use Data::Dump 'pp'; use PLP::Functions 'EscapeHTML'; -our $VERSION = '1.08'; +our $VERSION = '1.10'; -our $uc = do 'unicode-char.inc.pl'; +our $uc = do 'data/unicode-char.inc.pl'; sub new { my ($class) = @_; bless { anno => ['di', 0], style => 'di' }, $class; } -sub glyph_info { +sub glyph_mkinfo { my ($self, $codepoint) = @_; - return $uc->{chr $codepoint} || eval { + # attempt to get unicode character information + my $info = eval { require Unicode::UCD; - if (my $fullinfo = Unicode::UCD::charinfo($codepoint)) { - return [@$fullinfo{qw/category name - string/}]; - } - } || []; + Unicode::UCD::charinfo($codepoint) + || { category => 'Xn', name => '' }; + } or return; + my $string; + if ($info->{combining}) { + # overlay combining diacritics + $string = chr(9676) . chr($codepoint); + } + return [@$info{qw( category name )}, undef, $string]; +} + +sub glyph_info { + my ($self, $codepoint) = @_; + return $uc->{chr $codepoint} || $self->glyph_mkinfo($codepoint) || []; } sub glyph_html { @@ -34,7 +45,7 @@ sub glyph_html { my ($class, $name, $mnem, $entity, $string) = @$info; my $cell = EscapeHTML($string || $char); - my $title = sprintf 'U+%04X%s', $codepoint, !!$name && " ($name)"; + my $title = sprintf 'U+%04X%s', $codepoint, !!$name && " $name"; $cell = "$cell" if $class and $class =~ /\bZs\b/; $cell = ' ' if $cell eq ''; @@ -61,6 +72,31 @@ sub glyph_cell { return sprintf('