2 # -*- coding: ISO-8859-1 -*-
5 # Copyright (C) 2003-2005 Jörg Lehmann <joergl@users.sourceforge.net>
6 # Copyright (C) 2003-2005 André Wobst <wobsta@users.sourceforge.net>
8 # This file is part of PyX (http://pyx.sourceforge.net/).
10 # PyX is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # PyX is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with PyX; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 This module contains various resources like fonts and definitions
27 needed by canvasitems and a resource registry class.
31 import pswriter
, pdfwriter
35 """ a resource needed by a canvasitem """
37 def __init__(self
, id):
40 def PSregister(self
, registry
):
41 """ register PSresources in registry """
46 # various standard resources
49 class definition(resource
):
51 """ function definition """
53 def __init__(self
, id, body
):
57 def PSregister(self
, registry
):
58 registry
.add(pswriter
.PSdefinition(self
.id, self
.body
))
63 """ font definition """
65 def __init__(self
, font
):
66 """ include Type 1 font defined by the following parameters """
67 # XXX passing the font instance is probably not so nice
68 self
.id = self
.fontname
= font
.getpsname()
69 self
.basepsname
= font
.getbasepsname()
70 self
.fontfile
= font
.getfontfile()
71 self
.encodingfile
= font
.getencodingfile()
72 self
.encoding
= font
.getencoding()
73 self
.usedchars
= font
.usedchars
76 def PSregister(self
, registry
):
78 registry
.add(pswriter
.PSfontfile(self
.basepsname
, self
.fontfile
, self
.encodingfile
, self
.usedchars
))
80 registry
.add(pswriter
._ReEncodeFont
)
81 registry
.add(pswriter
.PSfontencoding(self
.encoding
, self
.encodingfile
))
82 registry
.add(pswriter
.PSfontreencoding(self
.fontname
, self
.basepsname
, self
.encoding
))
84 def PDFregister(self
, registry
):
85 registry
.add(pdfwriter
.PDFfont(self
.fontname
, self
.basepsname
, self
.font
))