src/reportlab/pdfbase/_fontdata.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
child 4370 823a8c33ce43
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
     2
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2216
diff changeset
     3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/pdfbase/_fontdata.py
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
     4
#$Header $
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3723
diff changeset
     5
__version__='3.3.0'
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
     6
__doc__="""Database of font related things
3031
6f90e7668adb docstrings cleaned up for epydoc
tim
parents: 2964
diff changeset
     7
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
     8
    - standardFonts - tuple of the 14 standard string font names
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
     9
    - standardEncodings - tuple of the known standard font names
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
    10
    - encodings - a mapping object from standard encoding names (and minor variants)
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
    11
      to the encoding vectors ie the tuple of string glyph names
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
    12
    - widthsByFontGlyph - fontname x glyphname --> width of glyph
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 3031
diff changeset
    13
    - widthVectorsByFont - fontName -> vector of widths 
3332
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
    14
    
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
    15
    This module defines a static, large data structure.  At the request
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
    16
    of the Jython project, we have split this off into separate modules
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
    17
    as Jython cannot handle more than 64k of bytecode in the 'top level'
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
    18
    code of a Python module.  
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    19
"""
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
    20
import os, sys
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    21
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    22
# mapping of name to width vector, starts empty until fonts are added
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    23
# e.g. widths['Courier'] = [...600,600,600,...]
725
05c05cc41686 Fix bad name error(s)
rgbecker
parents: 721
diff changeset
    24
widthVectorsByFont = {}
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    25
fontsByName = {}
689
18104568afde Changes to basic Font stuff, moved it to pdfmetrics
rgbecker
parents: 687
diff changeset
    26
fontsByBaseEnc = {}
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    27
# this is a list of the standard 14 font names in Acrobat Reader
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    28
standardFonts = (
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    29
    'Courier', 'Courier-Bold', 'Courier-Oblique', 'Courier-BoldOblique',
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    30
    'Helvetica', 'Helvetica-Bold', 'Helvetica-Oblique', 'Helvetica-BoldOblique',
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    31
    'Times-Roman', 'Times-Bold', 'Times-Italic', 'Times-BoldItalic',
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    32
    'Symbol','ZapfDingbats')
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
    33
2216
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    34
standardFontAttributes = {
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    35
    #family, bold, italic defined for basic ones
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    36
    'Courier':('Courier',0,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    37
    'Courier-Bold':('Courier',1,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    38
    'Courier-Oblique':('Courier',0,1),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    39
    'Courier-BoldOblique':('Courier',1,1),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    40
    
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    41
    'Helvetica':('Helvetica',0,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    42
    'Helvetica-Bold':('Helvetica',1,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    43
    'Helvetica-Oblique':('Helvetica',0,1),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    44
    'Helvetica-BoldOblique':('Helvetica',1,1),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    45
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    46
    'Times-Roman':('Times-Roman',0,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    47
    'Times-Bold':('Times-Roman',1,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    48
    'Times-Italic':('Times-Roman',0,1),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    49
    'Times-BoldItalic':('Times-Roman',1,1),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    50
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    51
    'Symbol':('Symbol',0,0),
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    52
    'ZapfDingbats':('ZapfDingbats',0,0)
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    53
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    54
    }
aadcd9dc9480 Font reregistration cleanup
andy_robinson
parents: 1981
diff changeset
    55
881
865c3099aec4 Added findT1File to base Face, and _fontdata
rgbecker
parents: 878
diff changeset
    56
#this maps fontnames to the equivalent filename root.
1981
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    57
_font2fnrMapWin32 = {
2824
00671dc77c11 _fontdata.py: force all t1 defaults to be lowercase
rgbecker
parents: 2767
diff changeset
    58
                    'symbol':                   'sy______',
00671dc77c11 _fontdata.py: force all t1 defaults to be lowercase
rgbecker
parents: 2767
diff changeset
    59
                    'zapfdingbats':             'zd______',
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    60
                    'helvetica':                '_a______',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    61
                    'helvetica-bold':           '_ab_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    62
                    'helvetica-boldoblique':    '_abi____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    63
                    'helvetica-oblique':        '_ai_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    64
                    'times-bold':               '_eb_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    65
                    'times-bolditalic':         '_ebi____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    66
                    'times-italic':             '_ei_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    67
                    'times-roman':              '_er_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    68
                    'courier-bold':             'cob_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    69
                    'courier-boldoblique':      'cobo____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    70
                    'courier':                  'com_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    71
                    'courier-oblique':          'coo_____',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
    72
                    }
1981
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    73
if sys.platform in ('linux2',):
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    74
    _font2fnrMapLinux2 ={
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    75
                'symbol': 'Symbol',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    76
                'zapfdingbats': 'ZapfDingbats',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    77
                'helvetica': 'Arial',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    78
                'helvetica-bold': 'Arial-Bold',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    79
                'helvetica-boldoblique': 'Arial-BoldItalic',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    80
                'helvetica-oblique': 'Arial-Italic',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    81
                'times-bold': 'TimesNewRoman-Bold',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    82
                'times-bolditalic':'TimesNewRoman-BoldItalic',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    83
                'times-italic': 'TimesNewRoman-Italic',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    84
                'times-roman': 'TimesNewRoman',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    85
                'courier-bold': 'Courier-Bold',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    86
                'courier-boldoblique': 'Courier-BoldOblique',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    87
                'courier': 'Courier',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    88
                'courier-oblique': 'Courier-Oblique',
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    89
                }
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    90
    _font2fnrMap = _font2fnrMapLinux2
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
    91
    for k, v in _font2fnrMap.items():
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
    92
        if k in _font2fnrMapWin32.keys():
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
    93
            _font2fnrMapWin32[v.lower()] = _font2fnrMapWin32[k]
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
    94
    del k, v
1981
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    95
else:
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
    96
    _font2fnrMap = _font2fnrMapWin32
881
865c3099aec4 Added findT1File to base Face, and _fontdata
rgbecker
parents: 878
diff changeset
    97
865c3099aec4 Added findT1File to base Face, and _fontdata
rgbecker
parents: 878
diff changeset
    98
def _findFNR(fontName):
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
    99
    return _font2fnrMap[fontName.lower()]
881
865c3099aec4 Added findT1File to base Face, and _fontdata
rgbecker
parents: 878
diff changeset
   100
2339
4b1dae4bd1a8 More changes related to compact distro path recognition
rgbecker
parents: 2332
diff changeset
   101
from reportlab.rl_config import T1SearchPath
4b1dae4bd1a8 More changes related to compact distro path recognition
rgbecker
parents: 2332
diff changeset
   102
from reportlab.lib.utils import rl_isfile
4b1dae4bd1a8 More changes related to compact distro path recognition
rgbecker
parents: 2332
diff changeset
   103
def _searchT1Dirs(n,rl_isfile=rl_isfile,T1SearchPath=T1SearchPath):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   104
    assert T1SearchPath!=[], "No Type-1 font search path"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   105
    for d in T1SearchPath:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   106
        f = os.path.join(d,n)
2339
4b1dae4bd1a8 More changes related to compact distro path recognition
rgbecker
parents: 2332
diff changeset
   107
        if rl_isfile(f): return f
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   108
    return None
2339
4b1dae4bd1a8 More changes related to compact distro path recognition
rgbecker
parents: 2332
diff changeset
   109
del T1SearchPath, rl_isfile
881
865c3099aec4 Added findT1File to base Face, and _fontdata
rgbecker
parents: 878
diff changeset
   110
1981
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   111
def findT1File(fontName,ext='.pfb'):
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   112
    if sys.platform in ('linux2',) and ext=='.pfb':
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   113
        try:
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   114
            f = _searchT1Dirs(_findFNR(fontName))
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   115
            if f: return f
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   116
        except:
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   117
            pass
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   118
1981
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   119
        try:
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   120
            f = _searchT1Dirs(_font2fnrMapWin32[fontName.lower()]+ext)
1981
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   121
            if f: return f
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   122
        except:
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   123
            pass
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   124
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   125
    return _searchT1Dirs(_findFNR(fontName)+ext)
5b1d7f21461f Fixed up fake font searching again
rgbecker
parents: 1683
diff changeset
   126
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   127
# this lists the predefined font encodings - WinAnsi and MacRoman.  We have
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   128
# not added MacExpert - it's possible, but would complicate life and nobody
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   129
# is asking.  StandardEncoding means something special.
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   130
standardEncodings = ('WinAnsiEncoding','MacRomanEncoding','StandardEncoding','SymbolEncoding','ZapfDingbatsEncoding','PDFDocEncoding', 'MacExpertEncoding')
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   131
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   132
#this is the global mapping of standard encodings to name vectors
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   133
class _Name2StandardEncodingMap(dict):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   134
    '''Trivial fake dictionary with some [] magic'''
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   135
    _XMap = {'winansi':'WinAnsiEncoding','macroman': 'MacRomanEncoding','standard':'StandardEncoding','symbol':'SymbolEncoding', 'zapfdingbats':'ZapfDingbatsEncoding','pdfdoc':'PDFDocEncoding', 'macexpert':'MacExpertEncoding'}
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   136
    def __setitem__(self,x,v):
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   137
        y = x.lower()
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   138
        if y[-8:]=='encoding': y = y[:-8]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   139
        y = self._XMap[y]
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   140
        if y in self: raise IndexError('Encoding %s is already set' % y)
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   141
        dict.__setitem__(self,y,v)
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   142
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   143
    def __getitem__(self,x):
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   144
        y = x.lower()
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   145
        if y[-8:]=='encoding': y = y[:-8]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 966
diff changeset
   146
        y = self._XMap[y]
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   147
        return dict.__getitem__(self,y)
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   148
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   149
encodings = _Name2StandardEncodingMap()
3332
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   150
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   151
#due to compiled method size limits in Jython,
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   152
#we pull these in from separate modules to keep this module
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   153
#well under 64k.  We might well be able to ditch many of
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   154
#these anyway now we run on Unicode.
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   155
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   156
from reportlab.pdfbase._fontdata_enc_winansi import WinAnsiEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   157
from reportlab.pdfbase._fontdata_enc_macroman import MacRomanEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   158
from reportlab.pdfbase._fontdata_enc_standard import StandardEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   159
from reportlab.pdfbase._fontdata_enc_symbol import SymbolEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   160
from reportlab.pdfbase._fontdata_enc_zapfdingbats import ZapfDingbatsEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   161
from reportlab.pdfbase._fontdata_enc_pdfdoc import PDFDocEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   162
from reportlab.pdfbase._fontdata_enc_macexpert import MacExpertEncoding
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   163
encodings.update({
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   164
    'WinAnsiEncoding': WinAnsiEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   165
    'MacRomanEncoding': MacRomanEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   166
    'StandardEncoding': StandardEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   167
    'SymbolEncoding': SymbolEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   168
    'ZapfDingbatsEncoding': ZapfDingbatsEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   169
    'PDFDocEncoding': PDFDocEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   170
    'MacExpertEncoding': MacExpertEncoding,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   171
})
3332
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   172
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   173
ascent_descent = {
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   174
    'Courier': (629, -157),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   175
    'Courier-Bold': (626, -142),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   176
    'Courier-BoldOblique': (626, -142),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   177
    'Courier-Oblique': (629, -157),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   178
    'Helvetica': (718, -207),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   179
    'Helvetica-Bold': (718, -207),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   180
    'Helvetica-BoldOblique': (718, -207),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   181
    'Helvetica-Oblique': (718, -207),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   182
    'Times-Roman': (683, -217),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   183
    'Times-Bold': (676, -205),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   184
    'Times-BoldItalic': (699, -205),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   185
    'Times-Italic': (683, -205),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   186
    'Symbol': (0, 0),
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   187
    'ZapfDingbats': (0, 0)
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   188
    }
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   189
3332
39cfdaff24f0 broke out fontdata to keep under Jython limit
andy
parents: 3032
diff changeset
   190
# ditto about 64k limit - profusion of external files
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   191
import reportlab.pdfbase._fontdata_widths_courier
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   192
import reportlab.pdfbase._fontdata_widths_courierbold
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   193
import reportlab.pdfbase._fontdata_widths_courieroblique
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   194
import reportlab.pdfbase._fontdata_widths_courierboldoblique
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   195
import reportlab.pdfbase._fontdata_widths_helvetica
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   196
import reportlab.pdfbase._fontdata_widths_helveticabold
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   197
import reportlab.pdfbase._fontdata_widths_helveticaoblique
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   198
import reportlab.pdfbase._fontdata_widths_helveticaboldoblique
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   199
import reportlab.pdfbase._fontdata_widths_timesroman
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   200
import reportlab.pdfbase._fontdata_widths_timesbold
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   201
import reportlab.pdfbase._fontdata_widths_timesitalic
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   202
import reportlab.pdfbase._fontdata_widths_timesbolditalic
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   203
import reportlab.pdfbase._fontdata_widths_symbol
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   204
import reportlab.pdfbase._fontdata_widths_zapfdingbats
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   205
widthsByFontGlyph = {
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   206
    'Courier':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   207
    reportlab.pdfbase._fontdata_widths_courier.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   208
    'Courier-Bold':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   209
    reportlab.pdfbase._fontdata_widths_courierbold.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   210
    'Courier-Oblique':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   211
    reportlab.pdfbase._fontdata_widths_courieroblique.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   212
    'Courier-BoldOblique':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   213
    reportlab.pdfbase._fontdata_widths_courierboldoblique.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   214
    'Helvetica':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   215
    reportlab.pdfbase._fontdata_widths_helvetica.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   216
    'Helvetica-Bold':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   217
    reportlab.pdfbase._fontdata_widths_helveticabold.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   218
    'Helvetica-Oblique':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   219
    reportlab.pdfbase._fontdata_widths_helveticaoblique.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   220
    'Helvetica-BoldOblique':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   221
    reportlab.pdfbase._fontdata_widths_helveticaboldoblique.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   222
    'Times-Roman':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   223
    reportlab.pdfbase._fontdata_widths_timesroman.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   224
    'Times-Bold':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   225
    reportlab.pdfbase._fontdata_widths_timesbold.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   226
    'Times-Italic':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   227
    reportlab.pdfbase._fontdata_widths_timesitalic.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   228
    'Times-BoldItalic':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   229
    reportlab.pdfbase._fontdata_widths_timesbolditalic.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   230
    'Symbol':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   231
    reportlab.pdfbase._fontdata_widths_symbol.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   232
    'ZapfDingbats':
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   233
    reportlab.pdfbase._fontdata_widths_zapfdingbats.widths,
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   234
}
687
b84a53895dcb Initial split of pdfmetrics into code + database; some minor name adjustments
rgbecker
parents:
diff changeset
   235
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   236
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   237
#preserve the initial values here
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   238
def _reset(
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   239
        initial_dicts=dict(
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   240
            ascent_descent=ascent_descent.copy(),
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   241
            fontsByBaseEnc=fontsByBaseEnc.copy(),
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   242
            fontsByName=fontsByName.copy(),
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   243
            standardFontAttributes=standardFontAttributes.copy(),
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   244
            widthVectorsByFont=widthVectorsByFont.copy(),
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   245
            widthsByFontGlyph=widthsByFontGlyph.copy(),
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   246
            )
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   247
        ):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   248
    for k,v in initial_dicts.items():
2767
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   249
        d=globals()[k]
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   250
        d.clear()
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   251
        d.update(v)
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   252
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   253
from reportlab.rl_config import register_reset
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   254
register_reset(_reset)
2ba5a1d26ad0 reportlab: make a85 wrap optional, add _reset to rl_config
rgbecker
parents: 2339
diff changeset
   255
del register_reset