From 19fc54d5aa92aef7bee05c8fd2f209d76ec19a5d Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sat, 13 Jul 2024 03:05:15 +0200 Subject: [PATCH] Improving dyslexia mode. --- lib/JapaChar/View/HiraganaKatakanaTestExercise.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/JapaChar/View/HiraganaKatakanaTestExercise.pm b/lib/JapaChar/View/HiraganaKatakanaTestExercise.pm index 498f474..3e838ba 100644 --- a/lib/JapaChar/View/HiraganaKatakanaTestExercise.pm +++ b/lib/JapaChar/View/HiraganaKatakanaTestExercise.pm @@ -211,10 +211,15 @@ sub _get_label_featured_character( $self, $text ) { my $color = Pango::Color->new; my $hex_color = sha1_hex(encode 'utf-8', $text); - my ($r, $g, $b) = map { $_ = hex $_; ($_ << 8) | $_ } $hex_color =~ /(..)(..)(..)/; - my $color_attr = Pango::AttrForeground->new($r, $g, $b); + my @foreground = map { $_ = hex $_; ($_ << 8) | $_ } $hex_color =~ /(..)(..)(..)/; + my @background = map { 0xffff - $_ } @foreground; + my $fore_attr = Pango::AttrForeground->new(@foreground); + my $back_attr = Pango::AttrBackground->new(@background); $attr_list->insert($size); - $attr_list->insert($color_attr); + if ($self->_app->accessibility->is_dyslexia) { + $attr_list->insert($fore_attr); + $attr_list->insert($back_attr); + } $label->set_attributes($attr_list); $label->set_halign('center'); return $label;