diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 6f56cf8b2..8e31d8950 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -34,8 +34,8 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, \ log = logging.getLogger(__name__) -# FIXME: Add html5 doctype. However, do not break theme gradients. HTMLSRC = u""" + OpenLP Display @@ -404,7 +404,7 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, left bottom, ' \ - 'from(%s), to(%s))' % (theme.background_start_color, + 'from(%s), to(%s)) fixed' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string( \ @@ -412,7 +412,7 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, right bottom, ' \ - 'from(%s), to(%s))' % (theme.background_start_color, + 'from(%s), to(%s)) fixed' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string \ @@ -420,20 +420,21 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left bottom, right top, ' \ - 'from(%s), to(%s))' % (theme.background_start_color, + 'from(%s), to(%s)) fixed' % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == \ BackgroundGradientType.to_string \ (BackgroundGradientType.Vertical): background = \ u'background: -webkit-gradient(linear, left top, ' \ - u'right top, from(%s), to(%s))' % \ + u'right top, from(%s), to(%s)) fixed' % \ (theme.background_start_color, theme.background_end_color) else: background = \ u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ - u'50%%, %s, from(%s), to(%s))' % (width, width, width, - theme.background_start_color, theme.background_end_color) + u'50%%, %s, from(%s), to(%s)) fixed' % (width, width, + width, theme.background_start_color, + theme.background_end_color) return background def build_lyrics_css(item, webkitvers): @@ -557,11 +558,15 @@ def build_lyrics_format_css(theme, width, height): left_margin = int(theme.font_main_outline_size) * 2 else: left_margin = 0 - lyrics = u'white-space:pre-wrap; word-wrap: break-word; ' \ + justify = u'white-space:pre-wrap;' + # fix tag incompatibilities + if theme.display_horizontal_align == HorizontalType.Justify: + justify = u'' + lyrics = u'%s word-wrap: break-word; ' \ 'text-align: %s; vertical-align: %s; font-family: %s; ' \ 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \ 'padding: 0; padding-left: %spx; width: %spx; height: %spx; ' % \ - (align, valign, theme.font_main_name, theme.font_main_size, + (justify, align, valign, theme.font_main_name, theme.font_main_size, theme.font_main_color, 100 + int(theme.font_main_line_adjustment), left_margin, width, height) if theme.font_main_outline: diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index abfd658ba..6d48707b4 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -44,6 +44,7 @@ VERSE = u'The Lord said to {r}Noah{/r}: \n' \ 'Get those children out of the muddy, muddy \n' \ '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \ 'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n' +VERSE_FOR_LINE_COUNT = u'\n'.join(map(unicode, xrange(50))) FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456'] class Renderer(object): @@ -190,7 +191,7 @@ class Renderer(object): serviceItem.theme = theme_data if self.force_page: # make big page for theme edit dialog to get line count - serviceItem.add_from_text(u'', VERSE + VERSE + VERSE) + serviceItem.add_from_text(u'', VERSE_FOR_LINE_COUNT) else: self.imageManager.del_image(theme_data.theme_name) serviceItem.add_from_text(u'', VERSE) @@ -224,14 +225,10 @@ class Renderer(object): # Bibles if item.is_capable(ItemCapabilities.CanWordSplit): pages = self._paginate_slide_words(text.split(u'\n'), line_end) - else: - # Clean up line endings. - lines = self._lines_split(text) - pages = self._paginate_slide(lines, line_end) - # Songs and Custom - if item.is_capable(ItemCapabilities.CanSoftBreak) and \ - len(pages) > 1 and u'[---]' in text: - pages = [] + # Songs and Custom + elif item.is_capable(ItemCapabilities.CanSoftBreak): + pages = [] + if u'[---]' in text: while True: slides = text.split(u'\n[---]\n', 2) # If there are (at least) two occurrences of [---] we use @@ -272,6 +269,11 @@ class Renderer(object): lines = text.strip(u'\n').split(u'\n') pages.extend(self._paginate_slide(lines, line_end)) break + else: + # Clean up line endings. + pages = self._paginate_slide(text.split(u'\n'), line_end) + else: + pages = self._paginate_slide(text.split(u'\n'), line_end) new_pages = [] for page in pages: while page.endswith(u'
'): @@ -585,12 +587,3 @@ class Renderer(object): # this parse we are to be wordy line = line.replace(u'\n', u' ') return line.split(u' ') - - def _lines_split(self, text): - """ - Split the slide up by physical line - """ - # this parse we do not want to use this so remove it - text = text.replace(u'\n[---]', u'') - text = text.replace(u'[---]', u'') - return text.split(u'\n') diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 3b0a62f5b..34a3b9d98 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -176,8 +176,9 @@ class HorizontalType(object): Left = 0 Right = 1 Center = 2 + Justify = 3 - Names = [u'left', u'right', u'center'] + Names = [u'left', u'right', u'center', u'justify'] class VerticalType(object): diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 6001c83d6..c7cba0ebd 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -246,7 +246,7 @@ class Ui_ThemeWizard(object): self.horizontalLabel = QtGui.QLabel(self.alignmentPage) self.horizontalLabel.setObjectName(u'HorizontalLabel') self.horizontalComboBox = QtGui.QComboBox(self.alignmentPage) - self.horizontalComboBox.addItems([u'', u'', u'']) + self.horizontalComboBox.addItems([u'', u'', u'', u'']) self.horizontalComboBox.setObjectName(u'HorizontalComboBox') self.alignmentLayout.addRow(self.horizontalLabel, self.horizontalComboBox) @@ -495,6 +495,8 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Right')) self.horizontalComboBox.setItemText(HorizontalType.Center, translate('OpenLP.ThemeWizard', 'Center')) + self.horizontalComboBox.setItemText(HorizontalType.Justify, + translate('OpenLP.ThemeWizard', 'Justify')) self.transitionsLabel.setText( translate('OpenLP.ThemeWizard', 'Transitions:')) self.areaPositionPage.setTitle(