After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 435413 - pango_layout_set_justify_all_lines()
pango_layout_set_justify_all_lines()
Status: RESOLVED OBSOLETE
Product: pango
Classification: Platform
Component: general
1.16.x
Other Linux
: Normal enhancement
: Small API
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2007-05-03 06:01 UTC by Behdad Esfahbod
Modified: 2018-05-22 12:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Behdad Esfahbod 2007-05-03 06:01:31 UTC
Currently PangoLayout has an align attr of left/center/right, and a justify attr of true/false.  One missing combination is to make pango justify all lines, even the last line of paragraphs that is.  It is quite useful in rendering Persian poetry for example where all verses are stretched to the same width (see http://rira.ir/rira/php/?page=view&mod=classicpoems&obj=poem&id=1 for example).

So, there are three ways to implement this that I see:

  1) Add a new setting: pango_layout_set_justify_fill() or something.  It will only make sense if justify is true, and then align is ignored.

  2) Add a new align setting: PANGO_ALIGN_FILL.  It makes a lot of sense cause alignment doesn't make sense otherwise.  If justify is off or a line cannot be justified, it acts like align center.  The major problem with this is adding a new value to an enum that most people don't expect to see extended.

  3) Change semantics of ALIGN_CENTER justify=true to fill.  This is taking one combination and putting another, hopefully more useful, one.  The main problem with this one is that it more often than not will surprise people.

Another option would be to add a new attribute which is a forced line break that unlike a LINE SEPARATOR, will justify the previous line.  Needs support in markup too.

Owen?  Others?
Comment 1 Owen Taylor 2007-05-03 11:01:37 UTC
I'd call it pango_layout_set_justify_last_line() or something like that

 - set_justify_fill() is going to be confusing to people; it's not
   obvious how it differs from set_justify().
 - extending PANGO_ALIGN, is, as you point out, a little dangerous.
   Also, people will probably try PANGO_ALIGN_FILL instead of
   pango_layout_set_justify() and get surprising results
 - Changing ALIGN_CENTER, justify=true doesn't make sense to me;
   and in fact, I think the current behavior is probably useful
   in some cases.

I don't have a great intuition for naming here, since it isn't
something found in western typographic practice (it doesnt' really
work for Latin), but my inclination in that case is to go with
a name that is descriptive.
Comment 2 Matthias Clasen 2007-05-03 11:34:46 UTC
I have to concur with Owen here. If this really only affects the last line,
expressing that in the function name would be good.
Comment 3 Owen Taylor 2007-05-03 14:02:47 UTC
Hmm, also, about the title of this bug report - GTK_JUSTIFY_FILL definitely
should not justify the last line of paragraphs.
Comment 4 Behdad Esfahbod 2007-05-03 19:02:20 UTC
Ok, thanks for the comments.  What is GTK_JUSTIFY_FILL supposed to do then?  Docs say "The text is placed is distributed across the label.".  Sounds like the same to me.
Comment 5 Owen Taylor 2007-05-03 19:20:31 UTC
GTK_JUSTIFY_FILL is align according to the text direction + justify ... like normal Western book printing. 

(Maybe the treatment of the last line should depend on the language of the
text, but my memory is that many or most books in Arabic script don't justify
the last lines of paragraphs either.)


Comment 6 Behdad Esfahbod 2007-05-03 19:40:06 UTC
Ah ok, so I can go on and implement GTK_JUSTIFY_FILL using pango_layout_set_justify().

Note that for Arabic too the default is not to justify the last line.  It's just a feature that is needed in some situations.

Also, not very important, it's not just about the last line of paragraphs, but also the line before LINE SEPARATOR chars.
Comment 7 Behdad Esfahbod 2007-05-04 00:07:15 UTC
Behnam, what does CSS3 call this feature?
Comment 8 Behnam Esfahbod 2007-05-05 20:05:14 UTC
text-align-last: justify;

source: http://www.w3.org/TR/css3-text/#text-align-last
Comment 9 GNOME Infrastructure Team 2018-05-22 12:27:36 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/74.