From 694063d5dfa602825d82cc17bbf3b5404abcf936 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Thu, 17 Oct 2024 23:46:16 +0200 Subject: [PATCH] Fixing utf-8 bugs. --- lib/Exd/FileFormat.pm | 2 +- lib/Exd/Gui.pm | 2 ++ lib/Exd/Printer.pm | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Exd/FileFormat.pm b/lib/Exd/FileFormat.pm index af682e1..851721d 100644 --- a/lib/Exd/FileFormat.pm +++ b/lib/Exd/FileFormat.pm @@ -116,7 +116,7 @@ sub get_script($self) { } sub set_script( $self, $script_contents ) { - return $self->dir->child('script.pl')->spew_raw($script_contents); + return $self->dir->child('script.pl')->spew_utf8($script_contents); } sub to_zip($self) { diff --git a/lib/Exd/Gui.pm b/lib/Exd/Gui.pm index dd9c89b..27bfe8e 100644 --- a/lib/Exd/Gui.pm +++ b/lib/Exd/Gui.pm @@ -313,6 +313,8 @@ sub _daemon_script_runner($self) { my ( $read_from_parent, $write_to_script ); pipe $read_from_script, $write_to_parent; pipe $read_from_parent, $write_to_script; + binmode $write_to_parent, ':utf8'; + binmode $write_to_script, ':utf8'; $self->_select->add($read_from_script); $self->_read_from_script($read_from_script); $self->_read_from_parent($read_from_parent); diff --git a/lib/Exd/Printer.pm b/lib/Exd/Printer.pm index a0f56f2..788b243 100644 --- a/lib/Exd/Printer.pm +++ b/lib/Exd/Printer.pm @@ -276,9 +276,6 @@ sub _get_next_line($self, $lines) { sub print_text( $self, $text, $font_size ) { my ($none, $file_code, $line) = caller(0); die "The bare minimum for font size is 4 at $file_code line $line" if $font_size < 4; - if ( !( ref $text ) ) { - $text = $text; - } my $tempdir = Path::Tiny->tempdir; my $file = $tempdir->child('result.png'); my $font = Pango::FontDescription->from_string( @@ -310,6 +307,7 @@ sub print_text( $self, $text, $font_size ) { my $context = $layout->get_context; my $metrics = $context->get_metrics($font, undef); if ( !ref $part ) { + $part = decode 'utf-8', $part; Pango::Cairo::update_layout( $cr, $layout ); $layout->set_text($part); $layout->set_font_description($font);