Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib64/python2.7/site-packages/matplotlib
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
matplotlib
/
📁
..
📄
__init__.py
(28.29 KB)
📄
__init__.pyc
(28.75 KB)
📄
__init__.pyo
(28.69 KB)
📄
_cm.py
(361.73 KB)
📄
_cm.pyc
(100.64 KB)
📄
_cm.pyo
(100.64 KB)
📄
_cntr.so
(20.47 KB)
📄
_delaunay.so
(59.75 KB)
📄
_image.so
(276.23 KB)
📄
_mathtext_data.py
(56.63 KB)
📄
_mathtext_data.pyc
(62.3 KB)
📄
_mathtext_data.pyo
(62.3 KB)
📄
_path.so
(273.74 KB)
📄
_png.so
(152.84 KB)
📄
_pylab_helpers.py
(2.65 KB)
📄
_pylab_helpers.pyc
(3.75 KB)
📄
_pylab_helpers.pyo
(3.75 KB)
📄
afm.py
(14.74 KB)
📄
afm.pyc
(16.98 KB)
📄
afm.pyo
(16.98 KB)
📄
artist.py
(34.79 KB)
📄
artist.pyc
(40.46 KB)
📄
artist.pyo
(40.46 KB)
📄
axes.py
(273.52 KB)
📄
axes.pyc
(246.65 KB)
📄
axes.pyo
(245.56 KB)
📄
axis.py
(56.01 KB)
📄
axis.pyc
(59.43 KB)
📄
axis.pyo
(59.13 KB)
📄
backend_bases.py
(70.62 KB)
📄
backend_bases.pyc
(78.09 KB)
📄
backend_bases.pyo
(78.01 KB)
📁
backends
📄
bezier.py
(14.57 KB)
📄
bezier.pyc
(13.49 KB)
📄
bezier.pyo
(13.49 KB)
📄
blocking_input.py
(13.37 KB)
📄
blocking_input.pyc
(14.42 KB)
📄
blocking_input.pyo
(14.11 KB)
📄
cbook.py
(41.75 KB)
📄
cbook.pyc
(57.32 KB)
📄
cbook.pyo
(57.1 KB)
📄
cm.py
(7.91 KB)
📄
cm.pyc
(9.8 KB)
📄
cm.pyo
(9.8 KB)
📄
collections.py
(39.83 KB)
📄
collections.pyc
(44.05 KB)
📄
collections.pyo
(44.05 KB)
📄
colorbar.py
(26.81 KB)
📄
colorbar.pyc
(25.23 KB)
📄
colorbar.pyo
(25.23 KB)
📄
colors.py
(38.19 KB)
📄
colors.pyc
(39.74 KB)
📄
colors.pyo
(39.74 KB)
📄
contour.py
(41.89 KB)
📄
contour.pyc
(35.61 KB)
📄
contour.pyo
(35.45 KB)
📄
dates.py
(35.16 KB)
📄
dates.pyc
(40.17 KB)
📄
dates.pyo
(40.11 KB)
📁
delaunay
📄
dviread.py
(31.28 KB)
📄
dviread.pyc
(34.66 KB)
📄
dviread.pyo
(34.52 KB)
📄
figure.py
(40.3 KB)
📄
figure.pyc
(42.68 KB)
📄
figure.pyo
(42.55 KB)
📄
finance.py
(20.1 KB)
📄
finance.pyc
(18.24 KB)
📄
finance.pyo
(18.08 KB)
📄
font_manager.py
(41.65 KB)
📄
font_manager.pyc
(40.31 KB)
📄
font_manager.pyo
(40.31 KB)
📄
fontconfig_pattern.py
(6.28 KB)
📄
fontconfig_pattern.pyc
(6.55 KB)
📄
fontconfig_pattern.pyo
(6.55 KB)
📄
ft2font.so
(298.99 KB)
📄
hatch.py
(6.41 KB)
📄
hatch.pyc
(9.26 KB)
📄
hatch.pyo
(9.26 KB)
📄
image.py
(30.8 KB)
📄
image.pyc
(32.99 KB)
📄
image.pyo
(32.95 KB)
📄
legend.py
(31.54 KB)
📄
legend.pyc
(23.32 KB)
📄
legend.pyo
(23.15 KB)
📄
lines.py
(53.4 KB)
📄
lines.pyc
(56.63 KB)
📄
lines.pyo
(56.53 KB)
📄
mathtext.py
(99.62 KB)
📄
mathtext.pyc
(103.58 KB)
📄
mathtext.pyo
(103.21 KB)
📄
mlab.py
(92.08 KB)
📄
mlab.pyc
(99.53 KB)
📄
mlab.pyo
(99.35 KB)
📁
mpl-data
📄
mpl.py
(785 B)
📄
mpl.pyc
(1.16 KB)
📄
mpl.pyo
(1.16 KB)
📁
numerix
📄
nxutils.so
(9.48 KB)
📄
offsetbox.py
(29.11 KB)
📄
offsetbox.pyc
(34.01 KB)
📄
offsetbox.pyo
(33.96 KB)
📄
patches.py
(125.47 KB)
📄
patches.pyc
(130.6 KB)
📄
patches.pyo
(130.47 KB)
📄
path.py
(21.25 KB)
📄
path.pyc
(21 KB)
📄
path.pyo
(20.78 KB)
📁
projections
📄
pylab.py
(10.72 KB)
📄
pylab.pyc
(12.15 KB)
📄
pylab.pyo
(12.15 KB)
📄
pyparsing.py
(140.55 KB)
📄
pyparsing.pyc
(147.64 KB)
📄
pyparsing.pyo
(147.64 KB)
📄
pyplot.py
(80.54 KB)
📄
pyplot.pyc
(80.06 KB)
📄
pyplot.pyo
(80.06 KB)
📄
quiver.py
(36.66 KB)
📄
quiver.pyc
(33.35 KB)
📄
quiver.pyo
(33.35 KB)
📄
rcsetup.py
(22.88 KB)
📄
rcsetup.pyc
(21.02 KB)
📄
rcsetup.pyo
(20.85 KB)
📄
scale.py
(13.9 KB)
📄
scale.pyc
(19.78 KB)
📄
scale.pyo
(19.78 KB)
📁
sphinxext
📄
spines.py
(12.39 KB)
📄
spines.pyc
(11.6 KB)
📄
spines.pyo
(11.19 KB)
📄
table.py
(16.43 KB)
📄
table.pyc
(16.97 KB)
📄
table.pyo
(16.82 KB)
📄
texmanager.py
(21.94 KB)
📄
texmanager.pyc
(19.74 KB)
📄
texmanager.pyo
(19.74 KB)
📄
text.py
(58.42 KB)
📄
text.pyc
(59.27 KB)
📄
text.pyo
(59.27 KB)
📄
ticker.py
(39.48 KB)
📄
ticker.pyc
(50.94 KB)
📄
ticker.pyo
(50.81 KB)
📄
tight_bbox.py
(3.57 KB)
📄
tight_bbox.pyc
(4.06 KB)
📄
tight_bbox.pyo
(4.06 KB)
📄
transforms.py
(73.62 KB)
📄
transforms.pyc
(90.27 KB)
📄
transforms.pyo
(89.38 KB)
📄
ttconv.so
(63.95 KB)
📄
type1font.py
(11.27 KB)
📄
type1font.pyc
(11.22 KB)
📄
type1font.pyo
(11.22 KB)
📄
units.py
(4.86 KB)
📄
units.pyc
(5.78 KB)
📄
units.pyo
(5.78 KB)
📄
widgets.py
(39.88 KB)
📄
widgets.pyc
(42.59 KB)
📄
widgets.pyo
(42.4 KB)
📄
windowing.py
(454 B)
📄
windowing.pyc
(1.33 KB)
📄
windowing.pyo
(1.33 KB)
Editing: type1font.py
""" This module contains a class representing a Type 1 font. This version reads pfa and pfb files and splits them for embedding in pdf files. It also supports SlantFont and ExtendFont transformations, similarly to pdfTeX and friends. There is no support yet for subsetting. Usage:: >>> font = Type1Font(filename) >>> clear_part, encrypted_part, finale = font.parts >>> slanted_font = font.transform({'slant': 0.167}) >>> extended_font = font.transform({'extend': 1.2}) Sources: * Adobe Technical Note #5040, Supporting Downloadable PostScript Language Fonts. * Adobe Type 1 Font Format, Adobe Systems Incorporated, third printing, v1.1, 1993. ISBN 0-201-57044-0. """ import matplotlib.cbook as cbook import cStringIO import itertools import numpy as np import re import struct class Type1Font(object): """ A class representing a Type-1 font, for use by backends. .. attribute:: parts A 3-tuple of the cleartext part, the encrypted part, and the finale of zeros. .. attribute:: prop A dictionary of font properties. """ __slots__ = ('parts', 'prop') def __init__(self, input): """ Initialize a Type-1 font. *input* can be either the file name of a pfb file or a 3-tuple of already-decoded Type-1 font parts. """ if isinstance(input, tuple) and len(input) == 3: self.parts = input else: file = open(input, 'rb') try: data = self._read(file) finally: file.close() self.parts = self._split(data) self._parse() def _read(self, file): """ Read the font from a file, decoding into usable parts. """ rawdata = file.read() if not rawdata.startswith(chr(128)): return rawdata data = '' while len(rawdata) > 0: if not rawdata.startswith(chr(128)): raise RuntimeError, \ 'Broken pfb file (expected byte 128, got %d)' % \ ord(rawdata[0]) type = ord(rawdata[1]) if type in (1,2): length, = struct.unpack('<i', rawdata[2:6]) segment = rawdata[6:6+length] rawdata = rawdata[6+length:] if type == 1: # ASCII text: include verbatim data += segment elif type == 2: # binary data: encode in hexadecimal data += ''.join(['%02x' % ord(char) for char in segment]) elif type == 3: # end of file break else: raise RuntimeError, \ 'Unknown segment type %d in pfb file' % type return data def _split(self, data): """ Split the Type 1 font into its three main parts. The three parts are: (1) the cleartext part, which ends in a eexec operator; (2) the encrypted part; (3) the fixed part, which contains 512 ASCII zeros possibly divided on various lines, a cleartomark operator, and possibly something else. """ # Cleartext part: just find the eexec and skip whitespace idx = data.index('eexec') idx += len('eexec') while data[idx] in ' \t\r\n': idx += 1 len1 = idx # Encrypted part: find the cleartomark operator and count # zeros backward idx = data.rindex('cleartomark') - 1 zeros = 512 while zeros and data[idx] in ('0', '\n', '\r'): if data[idx] == '0': zeros -= 1 idx -= 1 if zeros: raise RuntimeError, 'Insufficiently many zeros in Type 1 font' # Convert encrypted part to binary (if we read a pfb file, we # may end up converting binary to hexadecimal to binary again; # but if we read a pfa file, this part is already in hex, and # I am not quite sure if even the pfb format guarantees that # it will be in binary). binary = ''.join([chr(int(data[i:i+2], 16)) for i in range(len1, idx, 2)]) return data[:len1], binary, data[idx:] _whitespace = re.compile(r'[\0\t\r\014\n ]+') _token = re.compile(r'/{0,2}[^]\0\t\r\v\n ()<>{}/%[]+') _comment = re.compile(r'%[^\r\n\v]*') _instring = re.compile(r'[()\\]') @classmethod def _tokens(cls, text): """ A PostScript tokenizer. Yield (token, value) pairs such as ('whitespace', ' ') or ('name', '/Foobar'). """ pos = 0 while pos < len(text): match = cls._comment.match(text[pos:]) or cls._whitespace.match(text[pos:]) if match: yield ('whitespace', match.group()) pos += match.end() elif text[pos] == '(': start = pos pos += 1 depth = 1 while depth: match = cls._instring.search(text[pos:]) if match is None: return pos += match.end() if match.group() == '(': depth += 1 elif match.group() == ')': depth -= 1 else: # a backslash - skip the next character pos += 1 yield ('string', text[start:pos]) elif text[pos:pos+2] in ('<<', '>>'): yield ('delimiter', text[pos:pos+2]) pos += 2 elif text[pos] == '<': start = pos pos += text[pos:].index('>') yield ('string', text[start:pos]) else: match = cls._token.match(text[pos:]) if match: try: float(match.group()) yield ('number', match.group()) except ValueError: yield ('name', match.group()) pos += match.end() else: yield ('delimiter', text[pos]) pos += 1 def _parse(self): """ Find the values of various font properties. This limited kind of parsing is described in Chapter 10 "Adobe Type Manager Compatibility" of the Type-1 spec. """ # Start with reasonable defaults prop = { 'weight': 'Regular', 'ItalicAngle': 0.0, 'isFixedPitch': False, 'UnderlinePosition': -100, 'UnderlineThickness': 50 } tokenizer = self._tokens(self.parts[0]) filtered = itertools.ifilter(lambda x: x[0] != 'whitespace', tokenizer) for token, value in filtered: if token == 'name' and value.startswith('/'): key = value[1:] token, value = filtered.next() if token == 'name': if value in ('true', 'false'): value = value == 'true' else: value = value.lstrip('/') elif token == 'string': value = value.lstrip('(').rstrip(')') elif token == 'number': if '.' in value: value = float(value) else: value = int(value) else: # more complicated value such as an array value = None if key != 'FontInfo' and value is not None: prop[key] = value # Fill in the various *Name properties if not prop.has_key('FontName'): prop['FontName'] = prop.get('FullName') or prop.get('FamilyName') or 'Unknown' if not prop.has_key('FullName'): prop['FullName'] = prop['FontName'] if not prop.has_key('FamilyName'): extras = r'(?i)([ -](regular|plain|italic|oblique|(semi)?bold|(ultra)?light|extra|condensed))+$' prop['FamilyName'] = re.sub(extras, '', prop['FullName']) self.prop = prop @classmethod def _transformer(cls, tokens, slant, extend): def fontname(name): result = name if slant: result += '_Slant_' + str(int(1000*slant)) if extend != 1.0: result += '_Extend_' + str(int(1000*extend)) return result def italicangle(angle): return str(float(angle) - np.arctan(slant)/np.pi*180) def fontmatrix(array): array = array.lstrip('[').rstrip(']').strip().split() array = [ float(x) for x in array ] oldmatrix = np.eye(3,3) oldmatrix[0:3,0] = array[::2] oldmatrix[0:3,1] = array[1::2] modifier = np.array([[extend, 0, 0], [slant, 1, 0], [0, 0, 1]]) newmatrix = np.dot(modifier, oldmatrix) array[::2] = newmatrix[0:3,0] array[1::2] = newmatrix[0:3,1] return '[' + ' '.join(str(x) for x in array) + ']' def replace(fun): def replacer(tokens): token, value = tokens.next() # name, e.g. /FontMatrix yield value token, value = tokens.next() # possible whitespace while token == 'whitespace': yield value token, value = tokens.next() if value != '[': # name/number/etc. yield fun(value) else: # array, e.g. [1 2 3] array = [] while value != ']': array += value token, value = tokens.next() array += value yield fun(''.join(array)) return replacer def suppress(tokens): for x in itertools.takewhile(lambda x: x[1] != 'def', tokens): pass yield '' table = { '/FontName': replace(fontname), '/ItalicAngle': replace(italicangle), '/FontMatrix': replace(fontmatrix), '/UniqueID': suppress } while True: token, value = tokens.next() if token == 'name' and value in table: for value in table[value](itertools.chain([(token, value)], tokens)): yield value else: yield value def transform(self, effects): """ Transform the font by slanting or extending. *effects* should be a dict where ``effects['slant']`` is the tangent of the angle that the font is to be slanted to the right (so negative values slant to the left) and ``effects['extend']`` is the multiplier by which the font is to be extended (so values less than 1.0 condense). Returns a new :class:`Type1Font` object. """ buffer = cStringIO.StringIO() tokenizer = self._tokens(self.parts[0]) for value in self._transformer(tokenizer, slant=effects.get('slant', 0.0), extend=effects.get('extend', 1.0)): buffer.write(value) result = buffer.getvalue() buffer.close() return Type1Font((result, self.parts[1], self.parts[2]))
Upload File
Create Folder