Clean up phase 1 one of render sort out

fix bug in render frames (who forgot the footer)
This commit is contained in:
Tim Bentley 2009-07-15 18:33:31 +01:00
parent 511088b73b
commit 05a1c5a328
2 changed files with 19 additions and 19 deletions

View File

@ -151,13 +151,13 @@ class Renderer(object):
lines = verse.split(u'\n') lines = verse.split(u'\n')
for line in lines: for line in lines:
text.append(line) text.append(line)
print text #print text
split_text = self.pre_render_text(text) split_text = self.pre_render_text(text)
# print "-----------------------------" # print "-----------------------------"
# print split_text # print split_text
# split_text = self._split_set_of_lines(text, False) # split_text = self._split_set_of_lines(text, False)
print "-----------------------------" # print "-----------------------------"
print split_text # print split_text
log.debug(u'format_slide - End') log.debug(u'format_slide - End')
return split_text return split_text
@ -165,28 +165,28 @@ class Renderer(object):
metrics = QtGui.QFontMetrics(self.mainFont) metrics = QtGui.QFontMetrics(self.mainFont)
#take the width work out approx how many characters and add 50% #take the width work out approx how many characters and add 50%
line_width = self._rect.width() - self._right_margin line_width = self._rect.width() - self._right_margin
#number of lines on a page #number of lines on a page - adjust for rounding up.
page_length = self._rect.height() / metrics.height() page_length = int(self._rect.height() / metrics.height()) - 1
ave_line_width = line_width / metrics.averageCharWidth() ave_line_width = line_width / metrics.averageCharWidth()
print ave_line_width #print ave_line_width
ave_line_width = int(ave_line_width + (ave_line_width * 0.5)) ave_line_width = int(ave_line_width + (ave_line_width * 0.5))
print ave_line_width #print ave_line_width
split_pages = [] split_pages = []
page = [] page = []
split_lines = [] split_lines = []
count = 0 count = 0
for line in text: for line in text:
print line , len(line) #print line , len(line)
if len(line) > ave_line_width: if len(line) > ave_line_width:
while len(line) > 0: while len(line) > 0:
pos = line.find(u' ', ave_line_width) pos = line.find(u' ', ave_line_width)
print ave_line_width, pos, line[:pos] #print ave_line_width, pos, line[:pos]
split_text = line[:pos] split_text = line[:pos]
print metrics.width(split_text, -1), line_width #print metrics.width(split_text, -1), line_width
while metrics.width(split_text, -1) > line_width: while metrics.width(split_text, -1) > line_width:
#Find the next space to the left #Find the next space to the left
pos = line[:pos].rfind(u' ') pos = line[:pos].rfind(u' ')
print ave_line_width, pos, line[:pos] #print ave_line_width, pos, line[:pos]
#no more spaces found #no more spaces found
if pos == -1: if pos == -1:
split_text = line split_text = line
@ -198,11 +198,11 @@ class Renderer(object):
if len(line) <= ave_line_width: if len(line) <= ave_line_width:
split_lines.append(line) split_lines.append(line)
line = u'' line = u''
count += 1 # count += 1
if count == 50: # if count == 50:
a = c # a = c
print split_lines #print split_lines
print line #print line
else: else:
split_lines.append(line) split_lines.append(line)
line = u'' line = u''

View File

@ -138,12 +138,12 @@ class RenderManager(object):
main_rect = None main_rect = None
footer_rect = None footer_rect = None
if theme.font_main_override == False: if theme.font_main_override == False:
main_rect = QtCore.QRect(10,0, self.width-1, self.height-1) main_rect = QtCore.QRect(10,0, self.width - 1, self.footer_start - 20)
else: else:
main_rect = QtCore.QRect(int(theme.font_main_x) , int(theme.font_main_y), main_rect = QtCore.QRect(int(theme.font_main_x) , int(theme.font_main_y),
int(theme.font_main_width)-1, int(theme.font_main_height)-1) int(theme.font_main_width)-1, int(theme.font_main_height) - 1)
if theme.font_footer_override == False: if theme.font_footer_override == False:
footer_rect = QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start) footer_rect = QtCore.QRect(10,self.footer_start, self.width - 1, self.height-self.footer_start)
else: else:
footer_rect = QtCore.QRect(int(theme.font_footer_x),int(theme.font_footer_y), footer_rect = QtCore.QRect(int(theme.font_footer_x),int(theme.font_footer_y),
int(theme.font_footer_width)-1, int(theme.font_footer_height)-1) int(theme.font_footer_width)-1, int(theme.font_footer_height)-1)