~ubuntu-branches/debian/squeeze/python-imaging/squeeze

« back to all changes in this revision

Viewing changes to PIL/ImageFont.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-11-20 19:22:59 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091120192259-n3iy0f17n5akogom
Tags: 1.1.7-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
2
# The Python Imaging Library.
3
 
# $Id: ImageFont.py 2813 2006-10-07 10:11:35Z fredrik $
 
3
# $Id$
4
4
#
5
5
# PIL raster font management
6
6
#
28
28
import Image
29
29
import os, string, sys
30
30
 
 
31
class _imagingft_not_installed:
 
32
    # module placeholder
 
33
    def __getattr__(self, id):
 
34
        raise ImportError("The _imagingft C module is not installed")
 
35
 
 
36
try:
 
37
    import _imagingft
 
38
    core = _imagingft
 
39
    del _imagingft
 
40
except ImportError:
 
41
    core = _imagingft_not_installed()
 
42
 
31
43
# FIXME: add support for pilfont2 format (see FontFile.py)
32
44
 
33
45
# --------------------------------------------------------------------
89
101
            raise SyntaxError("Not a PILfont file")
90
102
        d = string.split(file.readline(), ";")
91
103
        self.info = [] # FIXME: should be a dictionary
92
 
        s = file.readline()
93
 
        while s and s != "DATA\n":
 
104
        while True:
 
105
            s = file.readline()
 
106
            if not s or s == "DATA\n":
 
107
                break
94
108
            self.info.append(s)
95
109
 
96
110
        # read PILfont metrics
117
131
 
118
132
    def __init__(self, file, size, index=0, encoding=""):
119
133
        # FIXME: use service provider instead
120
 
        import _imagingft
121
 
        self.font = _imagingft.getfont(file, size, index, encoding)
 
134
        self.font = core.getfont(file, size, index, encoding)
122
135
 
123
136
    def getname(self):
124
137
        return self.font.family, self.font.style