Re: [PATCH] Icon view RTL layout



Am Freitag, den 03.03.2006, 14:15 +0100 schrieb Alexander Larsson:
> 
> What exactly is it that causes the problem in RTL mode? There must be
> a
> better solution than changing the width of the layout.

The problem is that in RTL mode we have a layout like

[ some very long being line-breaked ]
[ because max width. was reached    ]

if the text does fit we have

[ short text                        ]
[                                   ]

So in a pure RTL environment, we determine the max. text width,
and simply draw the left part of the layout required to display the
entire text.

Now, let's investigate an LTR environment. I'm not using hebrew glyphs
because Evo locks up when moxing LTR/RTL.

This text is shorter than max. width:

[                         txettrohs ]
[                                   ]

This text is longer than max. width

[ tgnolyrevtxetgnolyrevtxetgnolyrev ]
[                               txe ]

My first thought was: Well, let's calc. the width needed by the layout
and shift the final text position to the right by (max_width -
layout_width). This seemed to work totally fine, until I discovered what
happens when you mix RTL and LTR layouts. You may well up with something
like:

[                         alephbeth ]
[ somemorelatintext                 ]

So a simple offset will break your layout. A PangoLayout with a width of
max_width will never be appropriate for arbitrary mixtures of LTR/RTL,
because sometimes you just can't get the offset right.

Setting the width *twice* instead of just setting the text is required
because according to the pango source code under some circumstances the
pixel_extents retval will depend on the layout width. Setting the width
to -1 before the measurement, calling get_pixel_extents and then setting
the width to MIN (extents, max_width) may work as well, in this case
you'll have to refetch the height of the layout.

-- 
Christian Neumair <chris gnome-de org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]