X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/9c976dfa8a3cd5dc9ae2b3b9e3ae207ff666cab8..b3b71de70835c9edbdf320035d5bb54d4c31db46:/Shiar_Sheet/FormatChar.pm diff --git a/Shiar_Sheet/FormatChar.pm b/Shiar_Sheet/FormatChar.pm index 3d9b6fb..f471497 100644 --- a/Shiar_Sheet/FormatChar.pm +++ b/Shiar_Sheet/FormatChar.pm @@ -8,7 +8,7 @@ use utf8; use Data::Dump 'pp'; use PLP::Functions 'EscapeHTML'; -our $VERSION = '1.09'; +our $VERSION = '1.10'; our $uc = do 'data/unicode-char.inc.pl'; @@ -17,14 +17,25 @@ sub new { 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 {