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: except:
raise ReportError(_("Could not create %s") % filename) raise ReportError(_("Could not create %s") % filename)
surface.set_fallback_resolution(300, 300) surface.set_fallback_resolution(300, 300)
cr = PangoCairo.create_context(cairo.Context(surface)) cr = cairo.Context(surface)
fontmap = PangoCairo.font_map_new()
fontmap = PangoCairo.font_map_get_default()
saved_resolution = fontmap.get_resolution()
fontmap.set_resolution(DPI) fontmap.set_resolution(DPI)
pango_context = fontmap.create_context() pango_context = fontmap.create_context()
options = cairo.FontOptions() options = cairo.FontOptions()
options.set_hint_metrics(cairo.HINT_METRICS_OFF) options.set_hint_metrics(cairo.HINT_METRICS_OFF)
PangoCairo.context_set_font_options(pango_context, options) PangoCairo.context_set_font_options(pango_context, options)
layout = Pango.Layout(pango_context) layout = Pango.Layout(pango_context)
cr.update_context(pango_context) PangoCairo.update_context(cr, pango_context)
# paginate the document # paginate the document
self.paginate_document(layout, page_width, page_height, DPI, DPI) self.paginate_document(layout, page_width, page_height, DPI, DPI)
body_pages = self._pages body_pages = self._pages
@ -184,10 +180,6 @@ class PdfDoc(libcairodoc.CairoDoc):
# close the surface (file) # close the surface (file)
surface.finish() 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): def __increment_pages(self, toc, index, start_page, offset):
""" """
Increment the page numbers in the table of contents and index. Increment the page numbers in the table of contents and index.

View File

@ -202,9 +202,7 @@ class FanChart(Report):
self.apply_filter(family.get_father_handle(),index*2) self.apply_filter(family.get_father_handle(),index*2)
self.apply_filter(family.get_mother_handle(),(index*2)+1) self.apply_filter(family.get_mother_handle(),(index*2)+1)
def write_report(self): def write_report(self):
self.doc.start_page() self.doc.start_page()
self.apply_filter(self.center_person.get_handle(),1) 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) self.draw_circular (x, y, start_angle, max_angle, block_size, generation)
for generation in range (max_circular, self.max_generations): for generation in range (max_circular, self.max_generations):
self.draw_radial (x, y, start_angle, max_angle, block_size, generation) self.draw_radial (x, y, start_angle, max_angle, block_size, generation)
self.doc.end_page() self.doc.end_page()
def get_info(self,person_handle,generation): def get_info(self,person_handle,generation):
person = self.database.get_person_from_handle(person_handle) person = self.database.get_person_from_handle(person_handle)
pn = person.get_primary_name() pn = person.get_primary_name()
@ -324,7 +320,6 @@ class FanChart(Report):
else: else:
return [ pn.get_first_name(), pn.get_surname(), val ] return [ pn.get_first_name(), pn.get_surname(), val ]
def draw_circular(self, x, y, start_angle, max_angle, size, generation): def draw_circular(self, x, y, start_angle, max_angle, size, generation):
segments = 2**generation segments = 2**generation
delta = max_angle / segments delta = max_angle / segments
@ -349,7 +344,6 @@ class FanChart(Report):
xc, yc, text_angle, mark) xc, yc, text_angle, mark)
text_angle += delta text_angle += delta
def draw_radial(self, x, y, start_angle, max_angle, size, generation): def draw_radial(self, x, y, start_angle, max_angle, size, generation):
segments = 2**generation segments = 2**generation
delta = max_angle / segments 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 # 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.move_to(x, t_margin + v_padding + spacing * 0.75)
cr.set_source_rgb(*ReportUtils.rgb_color(font_style.get_color())) 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 # calculate the full paragraph height
height = layout_height + spacing + t_margin + 2*v_padding + b_margin height = layout_height + spacing + t_margin + 2*v_padding + b_margin
@ -1295,7 +1295,7 @@ class GtkDocText(GtkDocBaseElement):
cr.rotate(radians(self._angle)) cr.rotate(radians(self._angle))
cr.move_to(align_x, align_y) cr.move_to(align_x, align_y)
cr.set_source_rgb(*ReportUtils.rgb_color(font_style.get_color())) cr.set_source_rgb(*ReportUtils.rgb_color(font_style.get_color()))
cr.show_layout(layout) PangoCairo.show_layout(cr, layout)
cr.restore() cr.restore()
return layout_height return layout_height