Debian Codegraph @

debian/patches/fix-centered-text

raw
1 Description: Fix centered text
2 Centered text was off-center
3 Forwarded: yes, done
4 Author: dod
5 --- a/lib/SDLx/Text.pm
6 +++ b/lib/SDLx/Text.pm
7 @@ -344,16 +344,20 @@
8
9 foreach my $i ( 0 .. $#{$surfaces}) {
10 if (my $surface = $surfaces->[$i]) {
11 + my $tx ;
12 $y += ($linebreaks * $surface->h);
13 $linebreaks = 0;
14
15 if ($self->{h_align} eq 'center' ) {
16 # $x = ($target->w / 2) - ($surface->w / 2);
17 - $x -= $surface->w / 2;
18 + $tx = $x + ($self->w -$surface->w) / 2;
19 }
20 elsif ($self->{h_align} eq 'right' ) {
21 # $x = $target->w - $surface->w;
22 - $x -= $surface->w;
23 + $tx = $x + $self->w - $surface->w;
24 + }
25 + else {
26 + $tx = $x ;
27 }
28
29 # blit the shadow
30 @@ -363,14 +367,14 @@
31
32 SDL::Video::blit_surface(
33 $shadow, SDL::Rect->new(0,0,$shadow->w, $shadow->h),
34 - $target, SDL::Rect->new($x + $offset, $y + $offset, 0, 0)
35 + $target, SDL::Rect->new($tx + $offset, $y + $offset, 0, 0)
36 );
37 }
38
39 # blit the text
40 SDL::Video::blit_surface(
41 $surface, SDL::Rect->new(0,0,$surface->w, $surface->h),
42 - $target, SDL::Rect->new($x, $y, 0, 0)
43 + $target, SDL::Rect->new($tx, $y, 0, 0)
44 );
45 }
46 $linebreaks++;