[gimp] app: take the rendering direction into account when adjusting the x-offset
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: take the rendering direction into account when adjusting the x-offset
- Date: Sun, 21 Feb 2010 16:48:42 +0000 (UTC)
commit ea7495a95ca51eb1df0f236c390af73b5a038313
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 21 17:47:21 2010 +0100
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.
app/text/gimptext-vectors.c | 2 +-
app/text/gimptextlayer.c | 2 +-
app/text/gimptextlayout-render.c | 33 ++++++++++++++++-----------------
app/text/gimptextlayout-render.h | 7 ++++---
4 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/app/text/gimptext-vectors.c b/app/text/gimptext-vectors.c
index 21ae7d3..a2a4ccd 100644
--- a/app/text/gimptext-vectors.c
+++ b/app/text/gimptext-vectors.c
@@ -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);
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index f0f2e67..1122827 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -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);
diff --git a/app/text/gimptextlayout-render.c b/app/text/gimptextlayout-render.c
index aa7241d..058744f 100644
--- a/app/text/gimptextlayout-render.c
+++ b/app/text/gimptextlayout-render.c
@@ -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);
diff --git a/app/text/gimptextlayout-render.h b/app/text/gimptextlayout-render.h
index 76b6a79..ec0c31a 100644
--- a/app/text/gimptextlayout-render.h
+++ b/app/text/gimptextlayout-render.h
@@ -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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]