2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-11 06:42:06 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2009-03-19 07:54:29 +05:30
|
|
|
# Copyright (C) 2007-2009 Brian G. Matherly
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2005-02-22 07:29:28 +05:30
|
|
|
# $Id$
|
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
"""
|
|
|
|
PostScript document generator.
|
|
|
|
"""
|
|
|
|
|
2003-06-16 10:27:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2003-06-16 10:27:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
2006-06-04 23:57:50 +05:30
|
|
|
#Gramps modules
|
2003-06-16 10:27:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
2009-06-24 02:19:18 +05:30
|
|
|
from gui.utils import open_file_with_default_application
|
2009-03-19 08:02:16 +05:30
|
|
|
from ReportBase import ReportUtils
|
2009-05-31 20:29:56 +05:30
|
|
|
from gen.plug.docgen import BaseDoc, DrawDoc, FONT_SERIF, PAPER_PORTRAIT, SOLID
|
|
|
|
from gen.plug.utils import gformat
|
2006-07-05 05:08:51 +05:30
|
|
|
import Errors
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
def lrgb(grp):
|
2006-06-04 23:57:50 +05:30
|
|
|
grp = ReportUtils.rgb_color(grp)
|
2009-08-09 00:45:19 +05:30
|
|
|
return (gformat(grp[0]), gformat(grp[1]), gformat(grp[2]))
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
def coords(grp):
|
2009-08-09 00:45:19 +05:30
|
|
|
return (gformat(grp[0]), gformat(grp[1]))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-06-16 10:27:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PSDrawDoc
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-08-09 00:45:19 +05:30
|
|
|
class PSDrawDoc(BaseDoc, DrawDoc):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def __init__(self, styles, type):
|
|
|
|
BaseDoc.__init__(self, styles, type)
|
|
|
|
self.file = None
|
2002-10-20 19:55:16 +05:30
|
|
|
self.filename = None
|
|
|
|
self.level = 0
|
2005-01-19 10:17:36 +05:30
|
|
|
self.page = 0
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def fontdef(self, para):
|
2002-10-20 19:55:16 +05:30
|
|
|
font = para.get_font()
|
2009-05-30 03:55:44 +05:30
|
|
|
if font.get_type_face() == FONT_SERIF:
|
2002-10-20 19:55:16 +05:30
|
|
|
if font.get_bold():
|
|
|
|
if font.get_italic():
|
|
|
|
font_name = "/Times-BoldItalic"
|
|
|
|
else:
|
|
|
|
font_name = "/Times-Bold"
|
|
|
|
else:
|
|
|
|
if font.get_italic():
|
|
|
|
font_name = "/Times-Italic"
|
|
|
|
else:
|
|
|
|
font_name = "/Times-Roman"
|
|
|
|
else:
|
|
|
|
if font.get_bold():
|
|
|
|
if font.get_italic():
|
|
|
|
font_name = "/Helvetica-BoldOblique"
|
|
|
|
else:
|
|
|
|
font_name = "/Helvetica-Bold"
|
|
|
|
else:
|
|
|
|
if font.get_italic():
|
|
|
|
font_name = "/Helvetica-Oblique"
|
|
|
|
else:
|
|
|
|
font_name = "/Helvetica"
|
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
return "%s find-latin-font %d scalefont setfont\n" % (font_name, font.get_size())
|
|
|
|
|
|
|
|
def translate(self, x, y):
|
|
|
|
return (x, self.paper.get_size().get_height()-y)
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def open(self, filename):
|
|
|
|
"""
|
|
|
|
Opens the file so that it can be generated.
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
@param filename: path name of the file to create
|
|
|
|
"""
|
2002-10-20 19:55:16 +05:30
|
|
|
if filename[-3:] != ".ps":
|
|
|
|
self.filename = filename + ".ps"
|
|
|
|
else:
|
|
|
|
self.filename = filename
|
2003-01-29 08:36:51 +05:30
|
|
|
|
2003-05-16 07:19:50 +05:30
|
|
|
try:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file = open(self.filename,"w")
|
2003-05-16 07:19:50 +05:30
|
|
|
except IOError,msg:
|
|
|
|
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
|
|
|
|
raise Errors.ReportError(errmsg)
|
|
|
|
except:
|
|
|
|
raise Errors.ReportError(_("Could not create %s") % self.filename)
|
2003-01-29 08:36:51 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%!PS-Adobe-3.0\n')
|
|
|
|
self.file.write('%%LanguageLevel: 2\n')
|
|
|
|
self.file.write('%%Pages: (atend)\n')
|
|
|
|
self.file.write('%%PageOrder: Ascend\n')
|
2009-05-30 03:55:44 +05:30
|
|
|
if self.paper.get_orientation() != PAPER_PORTRAIT:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%%Orientation: Landscape\n')
|
2003-06-11 08:29:01 +05:30
|
|
|
else:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%%Orientation: Portrait\n')
|
|
|
|
self.file.write('%%EndComments\n')
|
|
|
|
self.file.write('/cm { 28.34 mul } def\n')
|
|
|
|
self.file.write('% build iso-latin-1 version of a font\n')
|
|
|
|
self.file.write('/font-to-iso-latin-1 { % <font> font-to-iso-latin-1 <font>\n')
|
|
|
|
self.file.write('%% reencode for iso latin1; from the 2nd edition red book, sec 5.6.1\n')
|
|
|
|
self.file.write('dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall\n')
|
|
|
|
self.file.write('/Encoding ISOLatin1Encoding def currentdict end\n')
|
|
|
|
self.file.write('dup /FontName get 80 string cvs (-ISOLatin1) concatstrings cvn \n')
|
|
|
|
self.file.write('exch definefont\n')
|
|
|
|
self.file.write('} def\n')
|
|
|
|
self.file.write('\n')
|
|
|
|
self.file.write('/find-latin-font { % <name> find-latin-font <font>\n')
|
|
|
|
self.file.write('findfont font-to-iso-latin-1\n')
|
|
|
|
self.file.write('} def\n')
|
2004-01-20 09:27:19 +05:30
|
|
|
|
2003-07-28 22:50:18 +05:30
|
|
|
self.filename = filename
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def close(self):
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%%Trailer\n')
|
|
|
|
self.file.write('%%Pages: ')
|
|
|
|
self.file.write('%d\n' % self.page)
|
|
|
|
self.file.write('%%EOF\n')
|
|
|
|
self.file.close()
|
2009-02-01 09:51:17 +05:30
|
|
|
if self.open_req:
|
2009-06-24 02:19:18 +05:30
|
|
|
open_file_with_default_application(self.filename)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def write_text(self, text, mark=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
pass
|
|
|
|
|
2004-01-13 10:35:39 +05:30
|
|
|
def start_page(self):
|
2005-01-19 10:17:36 +05:30
|
|
|
self.page = self.page + 1
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write("%%Page:")
|
|
|
|
self.file.write("%d %d\n" % (self.page, self.page))
|
2009-05-30 03:55:44 +05:30
|
|
|
if self.paper.get_orientation() != PAPER_PORTRAIT:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('90 rotate %s cm %s cm translate\n' % (
|
2007-02-25 02:45:21 +05:30
|
|
|
gformat(0),gformat(-1*self.paper.get_size().get_height())))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def end_page(self):
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('showpage\n')
|
|
|
|
self.file.write('%%PageTrailer\n')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def encode(self, text):
|
2004-01-20 09:27:19 +05:30
|
|
|
try:
|
|
|
|
orig = unicode(text)
|
|
|
|
new_text = orig.encode('iso-8859-1')
|
|
|
|
except:
|
2005-12-06 12:08:09 +05:30
|
|
|
new_text = "?"*len(text)
|
|
|
|
return new_text
|
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def encode_text(self, p, text):
|
2005-12-06 12:08:09 +05:30
|
|
|
fdef = self.fontdef(p)
|
|
|
|
new_text = self.encode(text)
|
2009-08-09 00:45:19 +05:30
|
|
|
return (new_text, fdef)
|
2004-01-20 09:27:19 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def center_text(self, style, text, x, y):
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet = self.get_style_sheet()
|
|
|
|
stype = style_sheet.get_draw_style(style)
|
2003-06-11 08:29:01 +05:30
|
|
|
pname = stype.get_paragraph_style()
|
2007-04-23 17:16:26 +05:30
|
|
|
p = style_sheet.get_paragraph_style(pname)
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2007-02-25 02:45:21 +05:30
|
|
|
x += self.paper.get_left_margin()
|
|
|
|
y = y + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
|
2007-02-13 10:04:01 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
(text, fdef) = self.encode_text(p, text)
|
2004-01-20 09:27:19 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave\n')
|
|
|
|
self.file.write('%s %s %s setrgbcolor\n' % lrgb(stype.get_color()))
|
|
|
|
self.file.write(fdef)
|
|
|
|
self.file.write('(%s) dup stringwidth pop -2 div ' % text)
|
|
|
|
self.file.write('%s cm add %s cm moveto ' % coords(self.translate(x, y)))
|
|
|
|
self.file.write('show\n')
|
|
|
|
self.file.write('grestore\n')
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def draw_text(self, style, text, x1, y1):
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet = self.get_style_sheet()
|
|
|
|
stype = style_sheet.get_draw_style(style)
|
|
|
|
pname = stype.get_paragraph_style()
|
|
|
|
p = style_sheet.get_paragraph_style(pname)
|
2003-02-05 19:23:00 +05:30
|
|
|
|
2007-02-25 02:45:21 +05:30
|
|
|
x1 = x1 + self.paper.get_left_margin()
|
|
|
|
y1 = y1 + self.paper.get_top_margin() + ReportUtils.pt2cm(p.get_font().get_size())
|
2003-02-05 19:23:00 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
(text, fdef) = self.encode_text(p, text)
|
2005-02-22 07:15:52 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave\n')
|
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x1, y1)))
|
|
|
|
self.file.write(fdef)
|
|
|
|
self.file.write('(%s) show grestore\n' % text)
|
2003-01-31 09:58:39 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def rotate_text(self, style, text, x, y, angle):
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2007-02-25 02:45:21 +05:30
|
|
|
x += self.paper.get_left_margin()
|
|
|
|
y += self.paper.get_top_margin()
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet = self.get_style_sheet()
|
|
|
|
stype = style_sheet.get_draw_style(style)
|
2003-06-11 08:29:01 +05:30
|
|
|
pname = stype.get_paragraph_style()
|
2007-04-23 17:16:26 +05:30
|
|
|
p = style_sheet.get_paragraph_style(pname)
|
2005-01-19 10:17:36 +05:30
|
|
|
font = p.get_font()
|
2003-06-11 08:29:01 +05:30
|
|
|
|
|
|
|
size = font.get_size()
|
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
(new_text, fdef) = self.encode_text(p, text[0])
|
2004-01-20 09:27:19 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave\n')
|
|
|
|
self.file.write(fdef)
|
|
|
|
coords = self.translate(x, y)
|
|
|
|
self.file.write('%s cm %s cm translate\n' % (
|
2005-12-06 12:08:09 +05:30
|
|
|
gformat(coords[0]),gformat(coords[1])))
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%s rotate\n' % gformat(-angle))
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%s %s %s setrgbcolor\n' % lrgb(stype.get_color()))
|
2003-06-11 08:29:01 +05:30
|
|
|
|
|
|
|
val = len(text)
|
|
|
|
y = ((size * val)/2.0) - size
|
|
|
|
|
|
|
|
for line in text:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('(%s) dup stringwidth pop -2 div '
|
2005-12-06 12:08:09 +05:30
|
|
|
% self.encode(line))
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write("%s moveto show\n" % gformat(y))
|
2003-06-11 08:29:01 +05:30
|
|
|
y -= size
|
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('grestore\n')
|
2003-06-11 08:29:01 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def draw_path(self, style, path):
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet = self.get_style_sheet()
|
|
|
|
stype = style_sheet.get_draw_style(style)
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave\n')
|
|
|
|
self.file.write('newpath\n')
|
|
|
|
self.file.write('%s setlinewidth\n' % gformat(stype.get_line_width()))
|
2009-05-30 03:55:44 +05:30
|
|
|
if stype.get_line_style() == SOLID:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('[] 0 setdash\n')
|
2003-02-05 19:23:00 +05:30
|
|
|
else:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('[2 4] 0 setdash\n')
|
2003-02-05 19:23:00 +05:30
|
|
|
|
|
|
|
point = path[0]
|
2007-02-25 02:45:21 +05:30
|
|
|
x1 = point[0]+self.paper.get_left_margin()
|
|
|
|
y1 = point[1]+self.paper.get_top_margin()
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x1, y1)))
|
2003-02-05 19:23:00 +05:30
|
|
|
|
|
|
|
for point in path[1:]:
|
2007-02-25 02:45:21 +05:30
|
|
|
x1 = point[0]+self.paper.get_left_margin()
|
|
|
|
y1 = point[1]+self.paper.get_top_margin()
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%s cm %s cm lineto\n' % coords(self.translate(x1, y1)))
|
|
|
|
self.file.write('closepath\n')
|
2003-02-09 05:14:44 +05:30
|
|
|
|
|
|
|
color = stype.get_fill_color()
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave %s %s %s setrgbcolor fill grestore\n' % lrgb(color))
|
|
|
|
self.file.write('%s %s %s setrgbcolor stroke\n' % lrgb(stype.get_color()))
|
|
|
|
self.file.write('grestore\n')
|
2003-02-05 19:23:00 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def draw_line(self, style, x1, y1, x2, y2):
|
2007-02-25 02:45:21 +05:30
|
|
|
x1 = x1 + self.paper.get_left_margin()
|
|
|
|
x2 = x2 + self.paper.get_left_margin()
|
|
|
|
y1 = y1 + self.paper.get_top_margin()
|
|
|
|
y2 = y2 + self.paper.get_top_margin()
|
2007-04-23 17:16:26 +05:30
|
|
|
style_sheet = self.get_style_sheet()
|
|
|
|
stype = style_sheet.get_draw_style(style)
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave newpath\n')
|
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x1, y1)))
|
|
|
|
self.file.write('%s cm %s cm lineto\n' % coords(self.translate(x2, y2)))
|
|
|
|
self.file.write('%s setlinewidth\n' % gformat(stype.get_line_width()))
|
2009-05-30 03:55:44 +05:30
|
|
|
if stype.get_line_style() == SOLID:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('[] 0 setdash\n')
|
2003-02-04 00:54:27 +05:30
|
|
|
else:
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('[2 4] 0 setdash\n')
|
2003-02-04 00:54:27 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('2 setlinecap\n')
|
|
|
|
self.file.write('%s %s %s setrgbcolor stroke\n' % lrgb(stype.get_color()))
|
|
|
|
self.file.write('grestore\n')
|
2003-01-31 09:58:39 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
def draw_box(self, style, text, x, y, w, h):
|
2007-02-25 02:45:21 +05:30
|
|
|
x = x + self.paper.get_left_margin()
|
|
|
|
y = y + self.paper.get_top_margin()
|
2007-04-23 17:16:26 +05:30
|
|
|
|
|
|
|
style_sheet = self.get_style_sheet()
|
|
|
|
box_style = style_sheet.get_draw_style(style)
|
2007-02-26 03:23:38 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave\n')
|
2004-01-09 08:46:48 +05:30
|
|
|
|
|
|
|
shadsize = box_style.get_shadow_space()
|
|
|
|
if box_style.get_shadow():
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('newpath\n')
|
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x+shadsize, y+shadsize)))
|
|
|
|
self.file.write('0 -%s cm rlineto\n' % gformat(h))
|
|
|
|
self.file.write('%s cm 0 rlineto\n' % gformat(w))
|
|
|
|
self.file.write('0 %s cm rlineto\n' % gformat(h))
|
|
|
|
self.file.write('closepath\n')
|
|
|
|
self.file.write('.5 setgray\n')
|
|
|
|
self.file.write('fill\n')
|
|
|
|
self.file.write('newpath\n')
|
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x, y)))
|
|
|
|
self.file.write('0 -%s cm rlineto\n' % gformat(h))
|
|
|
|
self.file.write('%s cm 0 rlineto\n' % gformat(w))
|
|
|
|
self.file.write('0 %s cm rlineto\n' % gformat(h))
|
|
|
|
self.file.write('closepath\n')
|
2007-02-27 09:40:43 +05:30
|
|
|
|
|
|
|
fill_color = box_style.get_fill_color()
|
|
|
|
color = box_style.get_color()
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('gsave %s %s %s setrgbcolor fill grestore\n' % lrgb(fill_color))
|
|
|
|
self.file.write('%s %s %s setrgbcolor stroke\n' % lrgb(color))
|
2007-02-27 09:40:43 +05:30
|
|
|
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('newpath\n')
|
2005-01-20 09:41:13 +05:30
|
|
|
if box_style.get_line_width():
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x, y)))
|
|
|
|
self.file.write('0 -%s cm rlineto\n' % gformat(h))
|
|
|
|
self.file.write('%s cm 0 rlineto\n' % gformat(w))
|
|
|
|
self.file.write('0 %s cm rlineto\n' % gformat(h))
|
|
|
|
self.file.write('closepath\n')
|
|
|
|
self.file.write('%s setlinewidth\n' % gformat(box_style.get_line_width()))
|
|
|
|
self.file.write('%s %s %s setrgbcolor stroke\n' % lrgb(box_style.get_color()))
|
2005-01-19 10:17:36 +05:30
|
|
|
if text != "":
|
2007-02-27 09:40:43 +05:30
|
|
|
para_name = box_style.get_paragraph_style()
|
|
|
|
assert( para_name != '' )
|
2007-04-23 17:16:26 +05:30
|
|
|
p = style_sheet.get_paragraph_style(para_name)
|
2009-08-09 00:45:19 +05:30
|
|
|
(text, fdef) = self.encode_text(p, text)
|
|
|
|
self.file.write(fdef)
|
2005-12-06 12:08:09 +05:30
|
|
|
lines = text.split('\n')
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
nlines = len(lines)
|
|
|
|
mar = 10/28.35
|
|
|
|
f_in_cm = p.get_font().get_size()/28.35
|
|
|
|
fs = f_in_cm * 1.2
|
2007-02-26 03:23:38 +05:30
|
|
|
center = y + (h + fs)/2.0 + (fs*shadsize)
|
2002-10-20 19:55:16 +05:30
|
|
|
ystart = center - (fs/2.0) * nlines
|
|
|
|
for i in range(nlines):
|
|
|
|
ypos = ystart + (i * fs)
|
2009-08-09 00:45:19 +05:30
|
|
|
self.file.write('%s cm %s cm moveto\n' % coords(self.translate(x+mar, ypos)))
|
|
|
|
self.file.write("(%s) show\n" % lines[i])
|
|
|
|
self.file.write('grestore\n')
|