[IMP] improved code and defaults

bzr revid: dizzy.zala@gmail.com-20130920062115-r8vr770nwg7450ja
This commit is contained in:
Dharmraj Zala (OpenERP Trainee) 2013-09-20 11:51:15 +05:30
parent 26ad0436a9
commit 92aebae8af
2 changed files with 18 additions and 20 deletions

View File

@ -300,20 +300,20 @@ class res_company(osv.osv):
<frame id="first" x1="28.0" y1="28.0" width="%s" height="%s"/>
<stylesheet>
<!-- Set here the default font to use for all <para> tags -->
<paraStyle name='Normal' fontName="DejaVuSans"/>
<paraStyle name='Normal' fontName="DejaVu Sans"/>
</stylesheet>
<pageGraphics>
<fill color="black"/>
<stroke color="black"/>
<setFont name="DejaVuSans" size="8"/>
<setFont name="DejaVu Sans" size="8"/>
<drawString x="%s" y="%s"> [[ formatLang(time.strftime("%%Y-%%m-%%d"), date=True) ]] [[ time.strftime("%%H:%%M") ]]</drawString>
<setFont name="DejaVuSansBold" size="10"/>
<setFont name="DejaVu Sans Bold" size="10"/>
<drawCentredString x="%s" y="%s">[[ company.partner_id.name ]]</drawCentredString>
<stroke color="#000000"/>
<lines>%s</lines>
<!-- Set here the default font to use for all <drawString> tags -->
<!-- don't forget to change the 2 other occurence of <setFont> above if needed -->
<setFont name="DejaVuSans" size="8"/>
<setFont name="DejaVu Sans" size="8"/>
</pageGraphics>
</pageTemplate>
</header>"""
@ -338,13 +338,13 @@ class res_company(osv.osv):
<frame id="first" x1="1.3cm" y1="3.0cm" height="%s" width="19.0cm"/>
<stylesheet>
<!-- Set here the default font to use for all <para> tags -->
<paraStyle name='Normal' fontName="DejaVuSans"/>
<paraStyle name='Normal' fontName="DejaVu Sans"/>
<paraStyle name="main_footer" fontSize="8.0" alignment="CENTER"/>
<paraStyle name="main_header" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
<pageGraphics>
<!-- Set here the default font to use for all <drawString> tags -->
<setFont name="DejaVuSans" size="8"/>
<setFont name="DejaVu Sans" size="8"/>
<!-- You Logo - Change X,Y,Width and Height -->
<image x="1.3cm" y="%s" height="40.0" >[[ company.logo or removeParentNode('image') ]]</image>
<fill color="black"/>

View File

@ -124,6 +124,14 @@ def all_sysfonts_list():
filepath.append(os.path.join(dirname, filename))
__foundFonts[filename]=os.path.join(dirname, filename)
return filepath
def set_mode(font_info, dirname):
return {
'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
'italic':(),
'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
'bolditalic':(),
}
def RegisterCustomFonts():
"""
@ -140,24 +148,14 @@ def RegisterCustomFonts():
if not last_family:
last_family = font_info.familyName
if not all_mode:
all_mode = {
'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
'italic':(),
'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
'bolditalic':(),
}
all_mode = set_mode(font_info, dirname)
if (last_family != font_info.familyName) or ((i+1) == len(all_system_fonts)):
if not all_mode['italic']:
all_mode['italic'] = (all_mode['regular'][0],all_mode['regular'][1],all_mode['regular'][2],'italic')
all_mode['italic'] = all_mode['regular'][:3]+('italic',)
if not all_mode['bolditalic']:
all_mode['bolditalic'] = (all_mode['bold'][0],all_mode['bold'][1],all_mode['bold'][2],'bolditalic')
all_mode['bolditalic'] = all_mode['bold'][:3]+('bolditalic',)
CustomTTFonts.extend(all_mode.values())
all_mode = {
'regular':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular'),
'italic':(),
'bold':(font_info.familyName, font_info.name, dirname.split('/')[-1], 'bold'),
'bolditalic':(),
}
all_mode = set_mode(font_info, dirname)
mode = font_info.styleName.lower().replace(" ", "")
if (mode== 'normal') or (mode == 'regular') or (mode == 'medium') or (mode == 'book'):
all_mode['regular'] = (font_info.familyName, font_info.name, dirname.split('/')[-1], 'regular')