6659: Justified paragraph layout does not work

Actually: it works always, but pango does not justify partial lines...


svn: r22137
This commit is contained in:
Benny Malengier 2013-05-02 08:50:51 +00:00
parent 73f772232d
commit 9823168d15

View File

@ -540,12 +540,21 @@ class GtkDocParagraph(GtkDocBaseElement):
# #
align = self._style.get_alignment_text() align = self._style.get_alignment_text()
if align == 'left': if align == 'left':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_LEFT) layout.set_alignment(pango.ALIGN_LEFT)
elif align == 'right': elif align == 'right':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_RIGHT) layout.set_alignment(pango.ALIGN_RIGHT)
elif align == 'center': elif align == 'center':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_CENTER) layout.set_alignment(pango.ALIGN_CENTER)
elif align == 'justify': elif align == 'justify':
#We have a problem, in pango, justify works only on full lines,
# and we need an alignment for the partial lines. We don't know
# for justify what alignment the user wants however. We assume
# here RIGHT ...
layout.set_alignment(pango.ALIGN_LEFT)
# full width needed
layout.set_justify(True) layout.set_justify(True)
else: else:
raise ValueError raise ValueError
@ -688,12 +697,18 @@ class GtkDocParagraph(GtkDocBaseElement):
# #
align = self._style.get_alignment_text() align = self._style.get_alignment_text()
if align == 'left': if align == 'left':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_LEFT) layout.set_alignment(pango.ALIGN_LEFT)
elif align == 'right': elif align == 'right':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_RIGHT) layout.set_alignment(pango.ALIGN_RIGHT)
elif align == 'center': elif align == 'center':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_CENTER) layout.set_alignment(pango.ALIGN_CENTER)
elif align == 'justify': elif align == 'justify':
# We need to guess what alignment the user wants for the
# partial lines, as pango does not justify partial lines
layout.set_alignment(pango.ALIGN_LEFT)
layout.set_justify(True) layout.set_justify(True)
# #
font_style = self._style.get_font() font_style = self._style.get_font()
@ -1247,12 +1262,18 @@ class GtkDocText(GtkDocBaseElement):
# set paragraph properties # set paragraph properties
align = self._style.get_alignment_text() align = self._style.get_alignment_text()
if align == 'left': if align == 'left':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_LEFT) layout.set_alignment(pango.ALIGN_LEFT)
elif align == 'right': elif align == 'right':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_RIGHT) layout.set_alignment(pango.ALIGN_RIGHT)
elif align == 'center': elif align == 'center':
layout.set_justify(False)
layout.set_alignment(pango.ALIGN_CENTER) layout.set_alignment(pango.ALIGN_CENTER)
elif align == 'justify': elif align == 'justify':
# we have a problem, for pango, we need to guess now what
# alignment the user wants for partial lines ...
layout.set_alignment(pango.ALIGN_CENTER)
layout.set_justify(True) layout.set_justify(True)
else: else:
raise ValueError raise ValueError