Fixing utf-8 bugs.

This commit is contained in:
Sergiotarxz 2024-10-17 23:46:16 +02:00
parent 0164723fbf
commit 694063d5df
3 changed files with 4 additions and 4 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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);