Skip Menu |

This queue is for tickets about the Pango CPAN distribution.

Report information
The Basics
Id: 53656
Status: open
Priority: 0/
Queue: Pango

People
Owner: Nobody in particular
Requestors: cornelius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.221
Fixed in: (no value)



Subject: ascent wrong when scale to a large double number.
if i scale cairo context to a large double number: my $dpi = 600; $cr->scale( 1 / 25.4 * $dpi, 1 / 25.4 * $dpi); then the ink ascent doesnt touch the text. there is a space between ascent and font text. and if i just scale to 3,3 , which is correct. $cr->scale( 3, 3); the ink ascent is just beside the text.
Subject: pango-extents-scale-with-int.png
pango-extents-scale-with-int.png
Subject: pango-extents-scale-with-float.png
pango-extents-scale-with-float.png
On Wed Jan 13 11:52:07 2010, CORNELIUS wrote: Show quoted text
> if i scale cairo context to a large double number: > > my $dpi = 600; > $cr->scale( 1 / 25.4 * $dpi, 1 / 25.4 * $dpi); > > then the ink ascent doesnt touch the text. there is a space between
ascent Show quoted text
> and font text. > > and if i just scale to 3,3 , which is correct. > > $cr->scale( 3, 3); > > the ink ascent is just beside the text.
I can't imagine that this is a bug in the Perl bindings. If there's a bug somewhere, maybe related to precision loss, then I guess it would be in libcairo itself. Can you post a small, self-contained example program that exhibits the bug?
sorry for late response here is my test-case.
Subject: scale21x21.pl
#!/usr/bin/env perl use utf8; use warnings; use strict; use lib 'lib'; use Cairo; use Pango; use constant { text_offset => 20, width => 900, height => 2000 , }; sub draw_note; sub draw_extents; # take logical, ink (pango::rectangle) sub ascent { -$_[0]->{y} } # take logical,ink (pango::rectangle) sub descent { $_[0]->{y} + $_[0]->{height} } # GistID: my $surface = Cairo::ImageSurface->create ('argb32', width , height ); my $cr = Cairo::Context->create ($surface); $cr->scale( 21 , 21); $cr->translate( 1 , 1 ); $cr->set_line_width(0.1); $cr->set_font_size(2); my @fonts = ( 'Folio Md BT', 'Souvenir Lt BT', 'News701 BT', 'News701 BT', 'Apple LiGothic', 'AR Roman1 Medium', 'AR Roman1 Heavy', 'AR RGothic1 Bold', ); for my $fontname ( @fonts ) { my $layout = Pango::Cairo::create_layout ($cr); $layout->set_text("Orz"); my $desc = Pango::FontDescription->from_string("$fontname Normal 12"); $desc->set_absolute_size( 12 * Pango->scale() ); my $lang = Pango::Language->from_string( 'en_US' ); $layout->set_font_description ($desc); Pango::Cairo::show_layout($cr, $layout); draw_extents( $cr, $layout, $desc, $lang ); $cr->translate( 0 , text_offset ); } $cr->show_page(); $surface->write_to_png ('pango-extents-en.png'); system('open','pango-extents-en.png'); sub draw_extents { my ( $cr, $layout, $desc, $lang ) = @_; my $layoutline = $layout->get_line(0); my $fontmap = Pango::Cairo::FontMap->new_for_font_type('ft'); my $context = $fontmap->create_context(); my $font = $context->load_font($desc); Pango::Cairo::update_context( $cr, $context ); Pango::Cairo::update_layout( $cr, $layout ); my ( $ink, $logical ) = $layoutline->get_pixel_extents(); my $metrics = $font->get_metrics($lang); my $ascent = $metrics->get_ascent() / Pango->scale; my $descent = $metrics->get_descent()/ Pango->scale; my $baseline_y = $layout->get_baseline() / Pango->scale; # logical rectangle $cr->save; $cr->set_source_rgba( 0, 0, 1 , 1 ); $cr->rectangle( $logical->{x} , $baseline_y - ascent($logical) , $logical->{width}, $logical->{height} ); $cr->stroke; draw_note( $cr, 'logical', 100 , 0 ); $cr->restore; # ink rectangle $cr->save; $cr->set_source_rgba( 0, 0, 0, 0.4 ); $cr->rectangle( $ink->{x} , $baseline_y - ascent($ink) , $ink->{width}, $ink->{height} ); $cr->stroke; draw_note( $cr, 'ink', $ink->{x}, $baseline_y - ascent($ink) ); $cr->restore; # draw baseline $cr->save; $cr->set_source_rgba( 1 , 0, 0 , 1 ); $cr->move_to( 0 , $baseline_y ); $cr->line_to( $logical->{width} + 20 , $baseline_y ); $cr->stroke; draw_note($cr, 'baseline' , $logical->{width} + 2 , $baseline_y ); $cr->restore; # draw descent line $cr->save; $cr->set_source_rgba( 1 , 0, 0 , 0.5 ); $cr->move_to( 0 , $baseline_y + $descent ); $cr->line_to( $logical->{width} , $baseline_y + $descent ); $cr->stroke; draw_note($cr, 'descent line' , 0 , $baseline_y + $descent ); $cr->restore; # draw ascent line $cr->save; $cr->set_source_rgba( 1 , 0, 0 , 0.5 ); $cr->move_to( 0 , $baseline_y - $ascent ); $cr->line_to( $logical->{width} , $baseline_y - $ascent ); $cr->stroke; draw_note($cr, 'ascent line' , 0 , $baseline_y - $ascent ); $cr->restore; } sub draw_note { my ( $cr, $text, $x, $y ) = @_; $cr->save; $cr->move_to( $x, $y ); $cr->show_text($text); $cr->stroke; $cr->restore; }
Subject: scale33.pl
#!/usr/bin/env perl use utf8; use warnings; use strict; use lib 'lib'; use Cairo; use Pango; use constant { text_offset => 80, width => 900, height => 2000, }; sub draw_note; sub draw_extents; # take logical, ink (pango::rectangle) sub ascent { -$_[0]->{y} } # take logical,ink (pango::rectangle) sub descent { $_[0]->{y} + $_[0]->{height} } my $surface = Cairo::ImageSurface->create ('argb32', width , height ); my $cr = Cairo::Context->create ($surface); $cr->scale( 3, 3); $cr->translate( 1 , 1 ); $cr->set_line_width(0.1); $cr->set_font_size(5); my @fonts = ( 'Folio Md BT', 'Souvenir Lt BT', 'News701 BT', 'News701 BT', 'Apple LiGothic', 'AR Roman1 Medium', 'AR Roman1 Heavy', 'AR RGothic1 Bold', ); for my $fontname ( @fonts ) { my $layout = Pango::Cairo::create_layout ($cr); # $layout->set_text("orz123"); $layout->set_text("Orz"); my $desc = Pango::FontDescription->from_string("$fontname Normal 12"); $desc->set_absolute_size( 60 * Pango->scale() ); my $lang = Pango::Language->from_string( 'en_US' ); $layout->set_font_description ($desc); Pango::Cairo::show_layout($cr, $layout); draw_extents( $cr, $layout, $desc, $lang ); $cr->translate( 0 , text_offset ); } $cr->show_page(); $surface->write_to_png ('pango-extents-en.png'); system('open','pango-extents-en.png'); sub draw_extents { my ( $cr, $layout, $desc, $lang ) = @_; my $layoutline = $layout->get_line(0); my $fontmap = Pango::Cairo::FontMap->new_for_font_type('ft'); my $context = $fontmap->create_context(); my $font = $context->load_font($desc); Pango::Cairo::update_context( $cr, $context ); Pango::Cairo::update_layout( $cr, $layout ); my ( $ink, $logical ) = $layoutline->get_pixel_extents(); my $metrics = $font->get_metrics($lang); my $ascent = $metrics->get_ascent() / Pango->scale; my $descent = $metrics->get_descent()/ Pango->scale; my $baseline_y = $layout->get_baseline() / Pango->scale; # logical rectangle $cr->save; $cr->set_source_rgba( 0, 0, 1 , 1 ); $cr->rectangle( $logical->{x} , $baseline_y - ascent($logical) , $logical->{width}, $logical->{height} ); $cr->stroke; draw_note( $cr, 'logical', 100 , 0 ); $cr->restore; # ink rectangle $cr->save; $cr->set_source_rgba( 0, 0, 0, 0.4 ); $cr->rectangle( $ink->{x} , $baseline_y - ascent($ink) , $ink->{width}, $ink->{height} ); $cr->stroke; draw_note( $cr, 'ink', $ink->{x}, $baseline_y - ascent($ink) ); $cr->restore; # draw baseline $cr->save; $cr->set_source_rgba( 1 , 0, 0 , 1 ); $cr->move_to( 0 , $baseline_y ); $cr->line_to( $logical->{width} + 20 , $baseline_y ); $cr->stroke; draw_note($cr, 'baseline' , $logical->{width} + 2 , $baseline_y ); $cr->restore; # draw descent line $cr->save; $cr->set_source_rgba( 1 , 0, 0 , 0.5 ); $cr->move_to( 0 , $baseline_y + $descent ); $cr->line_to( $logical->{width} , $baseline_y + $descent ); $cr->stroke; draw_note($cr, 'descent line' , 0 , $baseline_y + $descent ); $cr->restore; # draw ascent line $cr->save; $cr->set_source_rgba( 1 , 0, 0 , 0.5 ); $cr->move_to( 0 , $baseline_y - $ascent ); $cr->line_to( $logical->{width} , $baseline_y - $ascent ); $cr->stroke; draw_note($cr, 'ascent line' , 0 , $baseline_y - $ascent ); $cr->restore; } sub draw_note { my ( $cr, $text, $x, $y ) = @_; $cr->save; $cr->move_to( $x, $y ); $cr->show_text($text); $cr->stroke; $cr->restore; }
On Sat Jan 30 05:49:40 2010, CORNELIUS wrote: Show quoted text
> here is my test-case.
These programs are too long. Please try to provide the *smallest* program that exhibits the problem. Don't draw unrelated stuff. Also, try to use fonts that are commonly available; I have none of the fonts you use in your test.
On Sun Feb 28 07:20:22 2010, TSCH wrote: Show quoted text
> > here is my test-case.
> > These programs are too long. Please try to provide the *smallest* > program that exhibits the problem. Don't draw unrelated stuff. Also, > try to use fonts that are commonly available; I have none of the fonts > you use in your test.
Just to clarify: I'm asking for a smaller test case so that I'm able to tell whether the bug is in the bindings. If you have problems reducing your test case, you could also try describing your issue on the pango or cairo mailing lists: <http://mail.gnome.org/mailman/listinfo/gtk-i18n-list> and <http://lists.cairographics.org/cgi-bin/mailman/listinfo/cairo>. Maybe somebody there knows an answer right away.