[IMP]view a dynaemic font in general setting for select font and set a font for company header and footer

bzr revid: mme@tinyerp.com-20130902130840-pvtegpqlpxkip46k
This commit is contained in:
Mehul Mehta (OpenERP)
2013-09-02 21:08:40 +08:00
parent e0ceeb8214
commit 7acb2f3105
+46 -6
View File
@@ -21,14 +21,54 @@
from openerp.osv import fields, osv
import re
import matplotlib.font_manager
import os
import platform
from reportlab import rl_config
from openerp.tools import config
_lst_font=[]
for i in matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf'):
m=re.sub('(.*/)','', i)
n=m.strip('.ttf')
n=n.replace('-',' ')
_lst_font.append((n,n))
TTFSearchPath_Linux = [
'/usr/share/fonts/truetype', # SuSE
'/usr/share/fonts/dejavu', '/usr/share/fonts/liberation', # Fedora, RHEL
'/usr/share/fonts/truetype/*', # Ubuntu,
'/usr/share/fonts/TTF/*', # at Mandriva/Mageia
'/usr/share/fonts/TTF', # Arch Linux
]
TTFSearchPath_Windows = [
'c:/winnt/fonts',
'c:/windows/fonts'
]
TTFSearchPath_Darwin = [
'~/Library/Fonts',
'/Library/Fonts',
'/Network/Library/Fonts',
'/System/Library/Fonts',
]
TTFSearchPathMap = {
'Darwin': TTFSearchPath_Darwin,
'Windows': TTFSearchPath_Windows,
'Linux': TTFSearchPath_Linux,
}
searchpath = []
if config.get('fonts_search_path'):
searchpath += map(str.strip, config.get('fonts_search_path').split(','))
local_platform = platform.system()
if local_platform in TTFSearchPathMap:
searchpath += TTFSearchPathMap[local_platform]
searchpath += rl_config.TTFSearchPath
for dirglob in searchpath:
if os.path.isdir(dirglob):
for file in os.listdir('/'+dirglob):
if os.path.isfile('/'+dirglob+'/'+file):
font=file.strip('.ttf')
font=font.replace('-',' ')
_lst_font.append((font,font))
class base_config_settings(osv.osv_memory):
_name = 'base.config.settings'