From e2f73de019a16b411dbbecf027dda79e74e6c7e7 Mon Sep 17 00:00:00 2001 From: Zsolt Foldvari Date: Thu, 27 Sep 2007 19:13:30 +0000 Subject: [PATCH] 2007-09-27 Zsolt Foldvari * src/docgen/PdfDoc.py: Fix pagination problems. * src/docgen/CairoDoc.py: Fix pagination problem. Fix text position in the box. svn: r9020 --- ChangeLog | 5 +++++ src/docgen/CairoDoc.py | 13 ++++++++++--- src/docgen/PdfDoc.py | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87955c5a2..39a5223a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-27 Zsolt Foldvari + * src/docgen/PdfDoc.py: Fix pagination problems. + * src/docgen/CairoDoc.py: Fix pagination problem. Fix text position in + the box. + 2007-09-27 Benny Malengier * src/FilterEditor/_EditRule.py: wrong filter selection, bug #807 Based on work Johan diff --git a/src/docgen/CairoDoc.py b/src/docgen/CairoDoc.py index 05c7ec9f7..08de59dcd 100644 --- a/src/docgen/CairoDoc.py +++ b/src/docgen/CairoDoc.py @@ -823,8 +823,8 @@ class GtkDocFrame(GtkDocBaseElement): _allowed_children = ['LINE', 'POLYGON', 'BOX', 'TEXT'] def divide(self, layout, width, height, dpi_x, dpi_y): - frame_width = self._style.width * dpi_x / 2.54 - frame_height = self._style.height * dpi_y / 2.54 + frame_width = round(self._style.width * dpi_x / 2.54) + frame_height = round(self._style.height * dpi_y / 2.54) t_margin = self._style.spacing[2] * dpi_y / 2.54 b_margin = self._style.spacing[3] * dpi_y / 2.54 @@ -1213,8 +1213,15 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc): paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name) paragraph_style.set_alignment(BaseDoc.PARA_ALIGN_LEFT) + # horizontal position of the text is not included in the style, + # we assume that it is the size of the shadow, or 0.2mm + if style.get_shadow(): + x_offset = style.get_shadow_space() + else: + x_offset = 0.2 + new_text = GtkDocText(paragraph_style, 'center', text, - x + 0.2, y + h / 2, angle=0) + x_offset , y + h / 2, angle=0) self._active_element.add_child(new_text) def draw_text(self, style_name, text, x, y): diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index 702bd844f..14eecdd71 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -95,8 +95,8 @@ class PdfDoc(CairoDoc): """Setup environment for printing. """ # get page size - self.page_width = context.get_width() - self.page_height = context.get_height() + self.page_width = round(context.get_width()) + self.page_height = round(context.get_height()) # initialize pagination self.setup_paginate()