Font Sizing and rendering improvements

bzr-revno: 619
This commit is contained in:
Tim Bentley 2009-10-23 17:35:40 +01:00
commit d98b6c7e88
3 changed files with 13 additions and 6 deletions

View File

@ -169,6 +169,8 @@ class Renderer(object):
page_length = int(self._rect.height() / metrics.height() - 2 ) - 1
ave_line_width = line_width / metrics.averageCharWidth()
ave_line_width = int(ave_line_width + (ave_line_width * 1))
log.debug(u'Page Length area height %s , metrics %s , lines %s' %
(int(self._rect.height()), metrics.height(), page_length ))
split_pages = []
page = []
split_lines = []
@ -195,15 +197,17 @@ class Renderer(object):
else:
split_text = line[:pos]
split_lines.append(split_text)
line = line[pos:]
line = line[pos:].lstrip()
#if we have more text add up to 10 spaces on the front.
if len(line) > 0 :
if len(line) > 0 and self._theme.font_main_indentation > 0:
line = u'%s%s' % \
(u' '[:self._theme.font_main_indentation], line)
#Text fits in a line now
for line in split_lines:
for count, line in enumerate(split_lines):
page.append(line)
if len(page) == page_length:
#last but one line and only 2 lines to go or end of page
if (len(page) == page_length - 1 and len(split_lines) - 3 == count) or \
len(page) == page_length:
split_pages.append(page)
page = []
if len(page) > 0 and page != u' ':

View File

@ -52,7 +52,7 @@ blankthemexml=\
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<location override="False" x="0" y="0" width="0" height="0"/>
<location override="False" x="10" y="10" width="1024" height="730"/>
</font>
<font type="footer">
<name>Arial</name>
@ -61,7 +61,7 @@ blankthemexml=\
<weight>Normal</weight>
<italics>False</italics>
<indentation>0</indentation>
<location override="False" x="0" y="0" width="0" height="0"/>
<location override="False" x="10" y="730" width="1024" height="38"/>
</font>
<display>
<shadow color="#000000">True</shadow>

View File

@ -674,8 +674,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
int(self.theme.font_main_proportion), # size
int(main_weight), # weight
self.theme.font_main_italics)# italic
mainFont.setPixelSize(int(self.theme.font_main_proportion))
metrics = QtGui.QFontMetrics(mainFont)
page_length = (int(self.FontMainHeightSpinBox.value()) / metrics.height() - 2 ) - 1
log.debug(u'Page Length area height %s , metrics %s , lines %s' %
(int(self.FontMainHeightSpinBox.value()), metrics.height(), page_length ))
self.FontMainLinesPageLabel.setText(
translate(u'ThemeManager', u'Slide Height is %s rows' % page_length ))
frame = self.thememanager.generateImage(theme)