This file is indexed.

/usr/share/pyshared/PythonCard/font.py is in python-pythoncard 0.8.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
"""
__version__ = "$Revision: 1.20 $"
__date__ = "$Date: 2004/04/15 22:06:32 $"
"""

import inspect
import wx
import resource

# Construct a Python list from a CSS style font-family list which
# is comma delimited and uses quotes for multi-word items.
# Unquoted multi-word items have starting and ending whitespace stripped
# and all whitespace reduced to single space characters.
def FixWhiteSpace(s):
    s = s.strip()
    s = s.replace('\t', ' ')
    s = s.replace('\n', ' ')
    s = s.replace('\r', ' ')
    while s.find('  ') >= 0:
        s = s.replace('  ', ' ')
    return s

def ListFromCSSFonts(s):
    l = []
    # The starting position of the current item
    start = 0
    # The character that started the current item, empty if outside item
    startChar = ""    
    for i in range(len(s)):
        if startChar:
            if startChar in "\'\"":
                if s[i] == startChar:
                    l.append(s[start+1:i])
                    startChar = ""
            elif s[i] in ",":
                l.append(FixWhiteSpace(s[start:i]))
                startChar = ""
        elif s[i] not in " \t,":
                start = i
                startChar = s[i]
    if startChar:
        l.append(FixWhiteSpace(s[start:]))
    return l

def fontDescription(font):
    desc = {}
    family = font.GetFamily()
    faceName = font.GetFaceName()
    size = font.GetPointSize()
    style = font.GetStyle()
    weight = font.GetWeight()
    #print "wx.DEFAULT, wx.MODERN", wx.DEFAULT, wx.MODERN
    #print family, faceName, size, style, weight
    #print font.GetNativeFontInfo()
    if family >= wx.DEFAULT and family <= wx.MODERN:
        # ['wxDEFAULT', 'wxDECORATIVE', 'wxROMAN', 'wxSCRIPT', 'wxSWISS', 'wxMODERN']
        names = ['default', 'decorative', 'serif', 'script', 'sansSerif', 'monospace']
        desc['family'] = names[family - wx.DEFAULT]
    if faceName != '':
        desc['faceName'] = faceName
    if size != 0:
        desc['size'] = size
    if style == wx.ITALIC and weight == wx.BOLD:
        desc['style'] = 'boldItalic'
    elif style == wx.ITALIC:
        desc['style'] = 'italic'
    elif weight == wx.BOLD:
        desc['style'] = 'bold'
    else:
        desc['style'] = 'regular'
    return desc

def familyId(name):
    if name == 'serif':
        return wx.ROMAN
    elif name == 'sansSerif':
        return wx.SWISS
    elif name == 'monospace':
        return wx.MODERN
    else:
        return wx.DEFAULT

def styleId(name):
    if name.endswith('italic'):
        return wx.ITALIC
    else:
        return wx.NORMAL

def weightId(name):
    if name.startswith('bold'):
        return wx.BOLD
    else:
        return wx.NORMAL

def fontFromDescription(fontDescription):
    return wx.Font(fontDescription.get('size', wx.NORMAL_FONT.GetPointSize()),
                  familyId(fontDescription.get('family', '')),
                  styleId(fontDescription.get('style', 'regular')),
                  weightId(fontDescription.get('style', 'regular')),
                  0,
                  fontDescription.get('faceName', ''))

# KEA 2004-04-15
# have to subclass Python object base class so that property() works below
class Font(object):

    def __init__( self, fontDescription, aParent=None ) :
        self._parent = aParent
        self._family = ''
        self._faceName = ''
        self._size = wx.NORMAL_FONT.GetPointSize()
        self._style = 'regular'
        self._underline = 0
        if fontDescription is not None:
            if isinstance(fontDescription, dict):
                fontDescription = resource.Resource(fontDescription)
            try:
                self._family = fontDescription.family
            except:
                pass
            try:
                self._faceName = fontDescription.faceName
            except:
                pass
            try:
                self._size = fontDescription.size
            except:
                pass
            try:
                self._style = fontDescription.style
            except:
                pass


    def _familyId(self, name):
        if name == 'serif':
            return wx.ROMAN
        elif name == 'sansSerif':
            return wx.SWISS
        elif name == 'monospace':
            return wx.MODERN
        else:
            return wx.DEFAULT

    def _styleId(self, name):
        if name.endswith('italic'):
            return wx.ITALIC
        else:
            return wx.NORMAL

    def _weightId(self, name):
        if name.startswith('bold'):
            return wx.BOLD
        else:
            return wx.NORMAL

    def _getFont(self):
        return wx.Font(self._size,
                      self._familyId(self._family),
                      self._styleId(self._style),
                      self._weightId(self._style),
                      self._underline,
                      self._faceName)

    def _setFont(self, aFont):
        raise AttributeError, "font attribute is read-only"

    def _getSize(self):
        return self._size

    def _setSize(self, size):
        #self._font = self._newFont()
        #self._font.SetPointSize(size)
        self._size = size

    def _getStyle(self):
        return self._style

    def _setStyle(self, style):
        self._style = style

    def _getFaceName(self):
        return self._faceName

    def _setFaceName(self, faceName):
        self._faceName = faceName

    def _getFamily(self):
        return self._family

    def _setFamily(self, family):
        self._family = family

    def description(self):
        desc = {}
        if self._family != '':
            desc['family'] = self._family
        if self._faceName != '':
            desc['faceName'] = self._faceName
        desc['size'] = self._size
        if self._style != 'regular':
            desc['style'] = self._style
        return desc

    def __repr__(self):
        return str(self.description())

    faceName = property(_getFaceName, _setFaceName)
    family = property(_getFamily, _setFamily)
    font = property(_getFont, _setFont)
    size = property(_getSize, _setSize)
    style = property(_getStyle, _setStyle)