summaryrefslogtreecommitdiff
path: root/lib/GridFiller/Result/Pango.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/GridFiller/Result/Pango.pm')
-rw-r--r--lib/GridFiller/Result/Pango.pm23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/GridFiller/Result/Pango.pm b/lib/GridFiller/Result/Pango.pm
index 1172848..34b3401 100644
--- a/lib/GridFiller/Result/Pango.pm
+++ b/lib/GridFiller/Result/Pango.pm
@@ -149,11 +149,14 @@ sub _put_squares {
}
sub layout_for_string {
- my ($self,$string) = @_;
+ my ($self,$string,$dir) = @_;
my $p = Pango::Cairo::create_layout($self->_cairo_c);
Pango::Cairo::Context::set_font_options($p->get_context,$self->font_options);
Pango::Cairo::update_context($self->_cairo_c,,$p->get_context);
+ if ($dir == $VERTICAL) {
+ $p->get_context->set_base_gravity('east');
+ }
$p->context_changed;
$p->set_font_description($self->font_description);
$p->set_text($string);
@@ -164,13 +167,13 @@ sub layout_for_string {
sub length_closure {
my ($self) = @_;
- return sub { $self->string_width($_[0]) }
+ return sub { $self->string_width(@_) }
}
sub string_extents {
- my ($self,$string) = @_;
+ my ($self,$string,$dir) = @_;
- my $p = $self->layout_for_string($string);
+ my $p = $self->layout_for_string($string,$dir);
my ($w,$h) = $p->get_pixel_size;
return
ceil($w / $self->cell_size),
@@ -178,15 +181,15 @@ sub string_extents {
}
sub string_width {
- my ($self,$string) = @_;
+ my ($self,$string,$dir) = @_;
- return +($self->string_extents($string))[0];
+ return +($self->string_extents($string,$dir))[0];
}
sub string_height {
- my ($self,$string) = @_;
+ my ($self,$string,$dir) = @_;
- return +($self->string_extents($string))[1];
+ return +($self->string_extents($string,$dir))[1];
}
sub _center_adj {
@@ -220,7 +223,7 @@ sub place_word_at {
$self->log->debug("Placing $word at ${x}:${y} ($dir)");
- my $p = $self->layout_for_string($word);
+ my $p = $self->layout_for_string($word,$dir);
my @colour = $self->colour_for_string($word,$x,$y,$dir);
my $size = $self->cell_size;
my $cr = $self->_cairo_c;
@@ -235,8 +238,6 @@ sub place_word_at {
$cr->move_to($x,$y);
}
else {
- $p->get_context->set_base_gravity('east');
- $p->context_changed;
$y+=$w_adjustment;
$x-=$h_adjustment;
$cr->move_to($x+$size,$y);