[reportlab-users] [Bitbucket] Issue #22: add '~/.fonts' (for user fonts on Ubuntu) to TTFSearchPath (rptlab/reportlab)

Robin Becker robin at reportlab.com
Tue Feb 25 06:28:25 EST 2014

On 25/02/2014 08:38, Andy Robinson wrote:

> On 24 February 2014 22:40, Marius Gedminas <marius at gedmin.as> wrote:

>> I believe the new standard is ~/.local/share/fonts/ [1] (where the

>> ~/.local/share part can be overridden by the $XDG_DATA_HOME environment

>> variable[2]).


>> [1] https://github.com/ValveSoftware/steam-for-linux/issues/2307

>> [2] http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html



> That is very useful to know about - thank you.


> Now the Python 3.x thing is largely behind us, we can start to

> 'featurise' a bit more rapidly, and we aim to do a 3.1 fairly soon

> (which will have an accompanying commercial package). I think we

> should add....


> - a user font directory as discussed above

> - we introduced a hook for people to add their own monkeypatches, but

> currently it looks for files in the site-packages area where reportlab

> is installed. IMHO we should also look for somewhere more

> traditional like a dot-file in the home directory


the problem with all the extension mechanisms is that they need to be
prioritised somehow. We have two kinds of extension mechanisms one for settings
which supposedly end up in

The standard paths variables should live in rl_settings.py; what is the priority




indeed does it matter?

Currently in py33 branch when we start up we're doing this in rl_config (ie the
settings case)

_overrides = {}
rl_exec('from reportlab.local_rl_settings import *',_overrides)
except ImportError:
rl_exec('from local_rl_settings import *',_overrides)
except ImportError:
rl_exec('from reportlab.rl_settings import *',_DEFAULTS)

so we get our settings overrides from PYTHONPATH local_rl_settings then
reportlab.local_rl_settings. Presumably ~/.fonts & ~/.local/share/fonts &
$XDG_DATA/fonts should live in rl_settings.py somewhere near the start of the lists.

For the monkey patching referred to by Andy we have

import reportlab.local_rl_mods
except ImportError:

at the end of reportlab.__init__.py. This has nothing to do with settings, but
can be used to do awful things to reportlab's code. At least one user, D Hughes,
used this mechanism to create a tracking canvas for some special purpose. He
would have preferred this import to live outside of reportlab ie on the
PYTHONPATH somewhere. That can be done in the same way as for the settings by adding

import local_rl_mods
except ImportError:

after the above.

So now we can also consider adding ~/.local_rl_settings & ~/.local_rl_mods as
importables (although we would need to handle the imports with imp). I propose
these should come between reportlab.local_rl_xxx and PYTHONPATH local_rl_xxx.

Anyone still following?
Robin Becker

More information about the reportlab-users mailing list