1#Copyright ReportLab Europe Ltd. 2000-2017
2#see license.txt for license details
3'''default settings for reportlab
4
5to override these drop a module rl_local_settings.py parallel to this file or
6anywhere on the path.
7'''
8import os, sys
9__version__='3.3.0'
10__all__=tuple('''allowTableBoundsErrors
11shapeChecking
12defaultEncoding
13defaultGraphicsFontName
14pageCompression
15useA85
16defaultPageSize
17defaultImageCaching
18ZLIB_WARNINGS
19warnOnMissingFontGlyphs
20verbose
21showBoundary
22emptyTableAction
23invariant
24eps_preview_transparent
25eps_preview
26eps_ttf_embed
27eps_ttf_embed_uid
28overlapAttachedSpace
29longTableOptimize
30autoConvertEncoding
31_FUZZ
32wrapA85
33fsEncodings
34odbc_driver
35platypus_link_underline
36canvas_basefontname
37allowShortTableRows
38imageReaderFlags
39paraFontSizeHeightOffset
40canvas_baseColor
41ignoreContainerActions
42ttfAsciiReadable
43pdfMultiLine
44pdfComments
45debug
46rtlSupport
47listWrapOnFakeWidth
48T1SearchPath
49TTFSearchPath
50CMapSearchPath
51decimalSymbol
52errorOnDuplicatePageLabelPage
53autoGenerateMissingTTFName
54allowTTFSubsetting
55spaceShrinkage
56underlineWidth
57underlineOffset
58underlineGap
59strikeWidth
60strikeOffset
61strikeGap
62hyphenationLang
63uriWasteReduce
64embeddedHyphenation
65hyphenationMinWordLength
66reserveTTFNotdef
67documentLang
68encryptionStrength
69trustedHosts
70trustedSchemes
71renderPMBackend'''.split())
72
73allowTableBoundsErrors =    1 # set to 0 to die on too large elements in tables in debug (recommend 1 for production use)
74shapeChecking =             1
75defaultEncoding =           'WinAnsiEncoding'       # 'WinAnsi' or 'MacRoman'
76defaultGraphicsFontName=    'Times-Roman'           #initializer for STATE_DEFAULTS in shapes.py
77pageCompression =           1                       # default page compression mode
78useA85 =                    1                       #set to 0 to disable Ascii Base 85 stream filters
79defaultPageSize =           'A4'                    #default page size
80defaultImageCaching =       0                       #set to zero to remove those annoying cached images
81ZLIB_WARNINGS =             1
82warnOnMissingFontGlyphs =   0                       #if 1, warns of each missing glyph
83verbose =                   0
84showBoundary =              0                       # turns on and off boundary behaviour in Drawing
85emptyTableAction=           'error'                 # one of 'error', 'indicate', 'ignore'
86invariant=                  0                       #produces repeatable,identical PDFs with same timestamp info (for regression testing)
87eps_preview_transparent=    None                    #set to white etc
88eps_preview=                1                       #set to False to disable
89eps_ttf_embed=              1                       #set to False to disable
90eps_ttf_embed_uid=          0                       #set to 1 to enable
91overlapAttachedSpace=       1                       #if set non false then adajacent flowable space after
92                                                    #and space before are merged (max space is used).
93longTableOptimize =         1                       #default do use Henning von Bargen's long table optimizations
94autoConvertEncoding  =      0                       #convert internally as needed (experimental)
95_FUZZ=                      1e-6                    #fuzz for layout arithmetic
96wrapA85=                    0                       #set to 1 to get old wrapped line behaviour
97fsEncodings=('utf8','cp1252','cp430')               #encodings to attempt utf8 conversion with
98odbc_driver=                'odbc'                  #default odbc driver
99platypus_link_underline=    0                       #paragraph links etc underlined if true
100canvas_basefontname=        'Helvetica'             #this is used to initialize the canvas; if you override to make
101                                                    #something else you are responsible for ensuring the font is registered etc etc
102                                                    #this will be used everywhere and the font family connections will be made
103                                                    #if the bold/italic/bold italic fonts are also registered and defined as a family.
104
105allowShortTableRows=1                               #allows some rows in a table to be short
106imageReaderFlags=0                                  #attempt to convert images into internal memory files to reduce
107                                                    #the number of open files (see lib.utils.ImageReader)
108                                                    #if imageReaderFlags&2 then attempt autoclosing of those files
109                                                    #if imageReaderFlags&4 then cache data
110                                                    #if imageReaderFlags==-1 then use Ralf Schmitt's re-opening approach
111paraFontSizeHeightOffset=   1                       #if true paragraphs start at height-fontSize
112canvas_baseColor=           None                    #initialize the canvas fill and stroke colors if this is set
113ignoreContainerActions=     1                       #if true then action flowables in flowable _Containers will be ignored
114ttfAsciiReadable=           1                       #smaller subsets when set to 0
115pdfMultiLine=               0                       #use more lines in pdf etc
116pdfComments=                0                       #put in pdf comments
117debug=                      0                       #for debugging code
118rtlSupport=                 0                       #set to 1 to attempt import of RTL assistance eg fribidi etc etc
119listWrapOnFakeWidth=        1                       #set to 0/False to force platypus.flowables._listWrapOn to report correct widths
120                                                    #else it reports minimum(required,available) width
121
122underlineWidth=             ''                      #empty to use canvas strokeWidth or a distance or number*<letter>
123                                                    #   num * <letter> make value proportional to a font size
124                                                    #   P paragraph font size
125                                                    #   L line max font size
126                                                    #   f first use font size
127                                                    #   F max fontsize in the tag
128
129underlineOffset=            '-0.125*F'              #fraction of fontSize from baseline to draw underlines at.
130underlineGap=               '1'                     #gap for double/triple underline
131
132strikeWidth=                ''
133strikeOffset=               '0.25*F'                #fraction of fontSize from baseline to draw strike through at.
134strikeGap=                  '1'                     #gap for double/triple strike
135
136                                                    #by default typical value 0.05. may be overridden on a parastyle.
137decimalSymbol=              '.'                     #what we use to align floats numerically
138errorOnDuplicatePageLabelPage= 0                    #if True will cause repeated PageLabel page numbers to raise an error.
139autoGenerateMissingTTFName=0                        #if true we try to auto generate any missing TTF font name
140
141allowTTFSubsetting=         []                      #list of font file names that will be subsetted even when they
142                                                    #have the no subsetting flag set. These should be fonts for which
143                                                    #the user has explicit permission from the rights holder(s).
144                                                    #This flag could already be overcome by hacking the code.
145                                                    #ReportLab takes no responsibility for the use of this setting.
146
147spaceShrinkage=0.05                                 #allowable space shrinkage to make lines fit
148hyphenationLang=''                                  #if pyphen installed set this to the language of your choice
149                                                    #eg 'en_GB'
150
151uriWasteReduce=0                                    #split URI if we would waste 0.3 of a line or if the URI#
152                                                    #would not fit on the next line; if zero then no splitting
153                                                    #is attempted. suggested value = 0.3
154embeddedHyphenation=0                               #if true attempt hypenation of words with embedded hyphens
155hyphenationMinWordLength=5                          #minimum length of words that can be hyphenated
156reserveTTFNotdef=0                                  #if true force subset element 0 to be zero(.notdef)
157                                                    #helps to fix bug in edge
158documentLang=None                                   #pdf document catalog Lang value xx-xx not ee_xx
159encryptionStrength=40                               #the bits for standard encryption 40, 128 or 256 (AES)
160trustedHosts=None                                   #set to a list of trusted for access hosts None means
161                                                    #all are trusted glob patterns eg *.reportlab.com are
162                                                    #allowed. In environment use a comma separated string.
163trustedSchemes=['file', 'rml', 'data', 'https',     #these url schemes are trusted
164                'http', 'ftp']
165renderPMBackend='_renderPM'                         #or 'rlPyCairo' if available
166
167# places to look for T1Font information
168T1SearchPath =  (
169                'c:/Program Files/Adobe/Acrobat 9.0/Resource/Font',
170                'c:/Program Files/Adobe/Acrobat 8.0/Resource/Font',
171                'c:/Program Files/Adobe/Acrobat 7.0/Resource/Font',
172                'c:/Program Files/Adobe/Acrobat 6.0/Resource/Font', #Win32, Acrobat 6
173                'c:/Program Files/Adobe/Acrobat 5.0/Resource/Font', #Win32, Acrobat 5
174                'c:/Program Files/Adobe/Acrobat 4.0/Resource/Font', #Win32, Acrobat 4
175                '%(disk)s/Applications/Python %(sys_version)s/reportlab/fonts', #Mac?
176                '/usr/lib/Acrobat9/Resource/Font',      #Linux, Acrobat 5?
177                '/usr/lib/Acrobat8/Resource/Font',      #Linux, Acrobat 5?
178                '/usr/lib/Acrobat7/Resource/Font',      #Linux, Acrobat 5?
179                '/usr/lib/Acrobat6/Resource/Font',      #Linux, Acrobat 5?
180                '/usr/lib/Acrobat5/Resource/Font',      #Linux, Acrobat 5?
181                '/usr/lib/Acrobat4/Resource/Font',      #Linux, Acrobat 4
182                '/usr/local/Acrobat9/Resource/Font',    #Linux, Acrobat 5?
183                '/usr/local/Acrobat8/Resource/Font',    #Linux, Acrobat 5?
184                '/usr/local/Acrobat7/Resource/Font',    #Linux, Acrobat 5?
185                '/usr/local/Acrobat6/Resource/Font',    #Linux, Acrobat 5?
186                '/usr/local/Acrobat5/Resource/Font',    #Linux, Acrobat 5?
187                '/usr/local/Acrobat4/Resource/Font',    #Linux, Acrobat 4
188                '/usr/share/fonts/default/Type1',       #Linux, Fedora
189                '%(REPORTLAB_DIR)s/fonts',              #special
190                '%(REPORTLAB_DIR)s/../fonts',           #special
191                '%(REPORTLAB_DIR)s/../../fonts',        #special
192                '%(CWD)s/fonts',                        #special
193                '~/fonts',
194                '~/.fonts',
195                '%(XDG_DATA_HOME)s/fonts',
196                '~/.local/share/fonts',
197                 )
198
199# places to look for TT Font information
200TTFSearchPath = (
201                'c:/winnt/fonts',
202                'c:/windows/fonts',
203                '/usr/lib/X11/fonts/TrueType/',
204                '/usr/share/fonts/truetype',
205                '/usr/share/fonts',             #Linux, Fedora
206                '/usr/share/fonts/dejavu',      #Linux, Fedora
207                '%(REPORTLAB_DIR)s/fonts',      #special
208                '%(REPORTLAB_DIR)s/../fonts',   #special
209                '%(REPORTLAB_DIR)s/../../fonts',#special
210                '%(CWD)s/fonts',                #special
211                '~/fonts',
212                '~/.fonts',
213                '%(XDG_DATA_HOME)s/fonts',
214                '~/.local/share/fonts',
215                #mac os X - from
216                #http://developer.apple.com/technotes/tn/tn2024.html
217                '~/Library/Fonts',
218                '/Library/Fonts',
219                '/Network/Library/Fonts',
220                '/System/Library/Fonts',
221                )
222
223# places to look for CMap files - should ideally merge with above
224CMapSearchPath = (
225                  '/usr/lib/Acrobat9/Resource/CMap',
226                  '/usr/lib/Acrobat8/Resource/CMap',
227                  '/usr/lib/Acrobat7/Resource/CMap',
228                  '/usr/lib/Acrobat6/Resource/CMap',
229                  '/usr/lib/Acrobat5/Resource/CMap',
230                  '/usr/lib/Acrobat4/Resource/CMap',
231                  '/usr/local/Acrobat9/Resource/CMap',
232                  '/usr/local/Acrobat8/Resource/CMap',
233                  '/usr/local/Acrobat7/Resource/CMap',
234                  '/usr/local/Acrobat6/Resource/CMap',
235                  '/usr/local/Acrobat5/Resource/CMap',
236                  '/usr/local/Acrobat4/Resource/CMap',
237                  'C:\\Program Files\\Adobe\\Acrobat\\Resource\\CMap',
238                  'C:\\Program Files\\Adobe\\Acrobat 9.0\\Resource\\CMap',
239                  'C:\\Program Files\\Adobe\\Acrobat 8.0\\Resource\\CMap',
240                  'C:\\Program Files\\Adobe\\Acrobat 7.0\\Resource\\CMap',
241                  'C:\\Program Files\\Adobe\\Acrobat 6.0\\Resource\\CMap',
242                  'C:\\Program Files\\Adobe\\Acrobat 5.0\\Resource\\CMap',
243                  'C:\\Program Files\\Adobe\\Acrobat 4.0\\Resource\\CMap',
244                  '%(REPORTLAB_DIR)s/fonts/CMap',       #special
245                  '%(REPORTLAB_DIR)s/../fonts/CMap',    #special
246                  '%(REPORTLAB_DIR)s/../../fonts/CMap', #special
247                  '%(CWD)s/fonts/CMap',             #special
248                  '%(CWD)s/fonts',              #special
249                  '~/fonts/CMap',
250                  '~/.fonts/CMap',
251                  '%(XDG_DATA_HOME)s/fonts/CMap',
252                  '~/.local/share/fonts/CMap',
253                  )
254
255if sys.platform.startswith('linux'):
256    def _findFontDirs(*ROOTS):
257        R = [].append
258        for rootd in ROOTS:
259            for root, dirs, files in os.walk(rootd):
260                if not files: continue
261                R(root)
262        return tuple(R.__self__)
263    T1SearchPath = T1SearchPath + _findFontDirs(
264                        '/usr/share/fonts/type1',
265                        '/usr/share/fonts/Type1',
266                        )
267    TTFSearchPath = TTFSearchPath + _findFontDirs(
268                        '/usr/share/fonts/truetype',
269                        '/usr/share/fonts/TTF',
270                        )
271