GTK3: pdf out conversion, avoid segfault in pdf report write,

svn: r20283
This commit is contained in:
Benny Malengier 2012-08-29 12:58:22 +00:00
parent 6536b74a59
commit 97a7b690ac
3 changed files with 6 additions and 20 deletions

View File

@ -95,19 +95,15 @@ class PdfDoc(libcairodoc.CairoDoc):
except:
raise ReportError(_("Could not create %s") % filename)
surface.set_fallback_resolution(300, 300)
cr = PangoCairo.create_context(cairo.Context(surface))
fontmap = PangoCairo.font_map_get_default()
saved_resolution = fontmap.get_resolution()
cr = cairo.Context(surface)
fontmap = PangoCairo.font_map_new()
fontmap.set_resolution(DPI)
pango_context = fontmap.create_context()
options = cairo.FontOptions()
options.set_hint_metrics(cairo.HINT_METRICS_OFF)
PangoCairo.context_set_font_options(pango_context, options)
layout = Pango.Layout(pango_context)
cr.update_context(pango_context)
PangoCairo.update_context(cr, pango_context)
# paginate the document
self.paginate_document(layout, page_width, page_height, DPI, DPI)
body_pages = self._pages
@ -180,13 +176,9 @@ class PdfDoc(libcairodoc.CairoDoc):
DPI, DPI)
cr.show_page()
cr.restore()
# close the surface (file)
surface.finish()
# Restore the resolution. On windows, Gramps UI fonts will be smaller
# if we don't restore the resolution.
fontmap.set_resolution(saved_resolution)
def __increment_pages(self, toc, index, start_page, offset):
"""

View File

@ -202,9 +202,7 @@ class FanChart(Report):
self.apply_filter(family.get_father_handle(),index*2)
self.apply_filter(family.get_mother_handle(),(index*2)+1)
def write_report(self):
self.doc.start_page()
self.apply_filter(self.center_person.get_handle(),1)
@ -259,10 +257,8 @@ class FanChart(Report):
self.draw_circular (x, y, start_angle, max_angle, block_size, generation)
for generation in range (max_circular, self.max_generations):
self.draw_radial (x, y, start_angle, max_angle, block_size, generation)
self.doc.end_page()
def get_info(self,person_handle,generation):
person = self.database.get_person_from_handle(person_handle)
pn = person.get_primary_name()
@ -324,7 +320,6 @@ class FanChart(Report):
else:
return [ pn.get_first_name(), pn.get_surname(), val ]
def draw_circular(self, x, y, start_angle, max_angle, size, generation):
segments = 2**generation
delta = max_angle / segments
@ -349,7 +344,6 @@ class FanChart(Report):
xc, yc, text_angle, mark)
text_angle += delta
def draw_radial(self, x, y, start_angle, max_angle, size, generation):
segments = 2**generation
delta = max_angle / segments

View File

@ -714,7 +714,7 @@ class GtkDocParagraph(GtkDocBaseElement):
# 3/4 of the spacing is added above the text, 1/4 is added below
cr.move_to(x, t_margin + v_padding + spacing * 0.75)
cr.set_source_rgb(*ReportUtils.rgb_color(font_style.get_color()))
cr.show_layout(layout)
PangoCairo.show_layout(cr, layout)
# calculate the full paragraph height
height = layout_height + spacing + t_margin + 2*v_padding + b_margin
@ -1295,7 +1295,7 @@ class GtkDocText(GtkDocBaseElement):
cr.rotate(radians(self._angle))
cr.move_to(align_x, align_y)
cr.set_source_rgb(*ReportUtils.rgb_color(font_style.get_color()))
cr.show_layout(layout)
PangoCairo.show_layout(cr, layout)
cr.restore()
return layout_height