index: release v1.18 with only altgr index linked
[sheet.git] / Shiar_Sheet / FormatChar.pm
index 3d9b6fb65538fb57cc8b62652b26e5cfd3f54b51..f471497b1f4bbb8687920a461ae0f6635d2b3661 100644 (file)
@@ -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 {