mirror of https://github.com/GNOME/gimp.git
app: take the rendering direction into account when adjusting the x-offset
Move the layout to the right edge of the bounding box if LTR and RIGHT *or* RTL and LEFT.
This commit is contained in:
parent
3befe0df59
commit
ea7495a95c
|
@ -82,7 +82,7 @@ gimp_text_vectors_new (GimpImage *image,
|
|||
cr = cairo_create (surface);
|
||||
|
||||
layout = gimp_text_layout_new (text, image);
|
||||
gimp_text_layout_render (layout, cr, TRUE);
|
||||
gimp_text_layout_render (layout, cr, text->base_dir, TRUE);
|
||||
g_object_unref (layout);
|
||||
|
||||
gimp_text_render_vectors (cr, &context);
|
||||
|
|
|
@ -632,7 +632,7 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
|
|||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
gimp_text_layout_render (layout, cr, FALSE);
|
||||
gimp_text_layout_render (layout, cr, layer->text->base_dir, FALSE);
|
||||
|
||||
mask = tile_manager_new ( width, height, 1);
|
||||
pixel_region_init (&maskPR, mask, 0, 0, width, height, TRUE);
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
|
||||
|
||||
void
|
||||
gimp_text_layout_render (GimpTextLayout *layout,
|
||||
cairo_t *cr,
|
||||
gboolean path)
|
||||
gimp_text_layout_render (GimpTextLayout *layout,
|
||||
cairo_t *cr,
|
||||
GimpTextDirection base_dir,
|
||||
gboolean path)
|
||||
{
|
||||
PangoLayout *pango_layout;
|
||||
cairo_matrix_t trafo;
|
||||
|
@ -48,29 +49,27 @@ gimp_text_layout_render (GimpTextLayout *layout,
|
|||
|
||||
pango_layout = gimp_text_layout_get_pango_layout (layout);
|
||||
|
||||
/* If the width of the layout is > 0, then the text-box is FIXED
|
||||
* and the layout position should be offset if the alignment
|
||||
* is centered or right-aligned*/
|
||||
/* If the width of the layout is > 0, then the text-box is FIXED and
|
||||
* the layout position should be offset if the alignment is centered
|
||||
* or right-aligned, also adjust for RTL text direction.
|
||||
*/
|
||||
if (pango_layout_get_width (pango_layout) > 0)
|
||||
{
|
||||
gint width;
|
||||
PangoAlignment align = pango_layout_get_alignment (pango_layout);
|
||||
gint width;
|
||||
|
||||
pango_layout_get_pixel_size (pango_layout, &width, NULL);
|
||||
|
||||
switch (pango_layout_get_alignment (pango_layout))
|
||||
if ((base_dir == GIMP_TEXT_DIRECTION_LTR && align == PANGO_ALIGN_RIGHT) ||
|
||||
(base_dir == GIMP_TEXT_DIRECTION_RTL && align == PANGO_ALIGN_LEFT))
|
||||
{
|
||||
case PANGO_ALIGN_LEFT:
|
||||
break;
|
||||
|
||||
case PANGO_ALIGN_RIGHT:
|
||||
x += PANGO_PIXELS (pango_layout_get_width (pango_layout)) - width;
|
||||
break;
|
||||
|
||||
case PANGO_ALIGN_CENTER:
|
||||
}
|
||||
else if (align == PANGO_ALIGN_CENTER)
|
||||
{
|
||||
x += (PANGO_PIXELS (pango_layout_get_width (pango_layout))
|
||||
- width) / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cairo_translate (cr, x, y);
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
#define __GIMP_TEXT_LAYOUT_RENDER_H__
|
||||
|
||||
|
||||
void gimp_text_layout_render (GimpTextLayout *layout,
|
||||
cairo_t *cr,
|
||||
gboolean path);
|
||||
void gimp_text_layout_render (GimpTextLayout *layout,
|
||||
cairo_t *cr,
|
||||
GimpTextDirection base_dir,
|
||||
gboolean path);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_LAYOUT_RENDER_H__ */
|
||||
|
|
Loading…
Reference in New Issue