Skip to content

Commit

Permalink
FIXED: The width of dnd's overlay is wrong
Browse files Browse the repository at this point in the history
CHANGED: remove is_nonspacing function
  • Loading branch information
qindapao authored and nkh committed Dec 4, 2023
1 parent c948c74 commit af7e7b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/App/Asciio/GTK/Asciio/DnD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use Sereal qw(
use Sereal::Encoder qw(SRL_SNAPPY SRL_ZLIB SRL_ZSTD) ;

use App::Asciio::Actions::Clipboard ;
use App::Asciio::String ;

#--------------------------------------------------------------------------

Expand Down Expand Up @@ -80,7 +81,7 @@ my $text = $self->transform_elements_to_ascii_buffer_aligned_left($self->get_sel
my $lines = $text =~ tr /\n/\n/ ;

my ($character_width, $character_height) = $self->get_character_size() ;
my ($width, $height) = (length($text) * $character_width, $character_height * $lines) ;
my ($width, $height) = (max(map { unicode_length $_ } split('\n', $text)) * $character_width, $character_height * $lines) ;
my $surface = Cairo::ImageSurface->create('argb32', $width, $height) ;
my $gc = Cairo::Context->create($surface) ;
my $layout = Pango::Cairo::create_layout($gc) ;
Expand Down
10 changes: 0 additions & 10 deletions lib/App/Asciio/String.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require Exporter ;
@EXPORT = qw(
unicode_length
make_vertical_text
is_nonspacing_char
) ;

#-----------------------------------------------------------------------------
Expand All @@ -20,15 +19,6 @@ use App::Asciio::Markup ;

use Memoize ;
memoize('unicode_length') ;
memoize('is_nonspacing_char') ;

#-----------------------------------------------------------------------------

sub is_nonspacing_char
{
my ($character) = @_ ;
return $character =~ /\p{gc:Mn}/ ;
}

#-----------------------------------------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions lib/App/Asciio/ZBuffer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ for my $strip (@{$element->get_stripes})
my $Y = $element->{Y} + $strip->{Y_OFFSET} + $line_index ;
my $X = $element->{X} + $strip->{X_OFFSET} + $character_index ;

if(is_nonspacing_char($char))
my $character_length = unicode_length($char) ;

if($character_length == 0)
{
$glyphs[$#glyphs][1] .= $char if @glyphs ;
}
Expand All @@ -84,7 +86,7 @@ for my $strip (@{$element->get_stripes})
push @glyphs, [ "$Y;$X", $char] ;
}

$character_index += unicode_length($char);
$character_index += $character_length;
}

$line_index++ ;
Expand Down

0 comments on commit af7e7b7

Please sign in to comment.