[gimp] app: render the selection char-by-char
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: render the selection char-by-char
- Date: Sun, 21 Feb 2010 19:13:01 +0000 (UTC)
commit 4ec38099e5418674d3a09b29f765c57edfa2621a
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 21 20:11:13 2010 +0100
app: render the selection char-by-char
so it's correct for all kinds of mixed text directions. Still looks
like crap because all the rectangles are separate, but should be
logically correct now.
app/tools/gimptexttool.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index eb6fff0..263e8b2 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -777,7 +777,7 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool,
GimpTextTool *text_tool = GIMP_TEXT_TOOL (draw_tool);
GtkTextBuffer *buffer = text_tool->text_buffer;
PangoLayout *layout;
- PangoLayoutIter *line_iter;
+ PangoLayoutIter *iter;
GtkTextIter start;
GtkTextIter sel_start, sel_end;
gint min, max;
@@ -812,7 +812,38 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool,
first_x = PANGO_PIXELS (first_tmp) + logical_off_x;
last_x = PANGO_PIXELS (last_tmp) + logical_off_x;
- line_iter = pango_layout_get_iter (layout);
+ iter = pango_layout_get_iter (layout);
+
+ do
+ {
+ if (! pango_layout_iter_get_run (iter))
+ continue;
+
+ i = pango_layout_iter_get_index (iter);
+
+ if (i >= min && i < max)
+ {
+ PangoRectangle rect;
+
+ g_printerr ("index %d is selected\n", i);
+
+ pango_layout_iter_get_char_extents (iter, &rect);
+ pango_extents_to_pixels (&rect, NULL);
+
+ gimp_text_layout_transform_rect (text_tool->layout, &rect);
+
+ rect.x += logical_off_x;
+ rect.y += logical_off_y;
+
+ gimp_draw_tool_draw_rectangle (draw_tool, TRUE,
+ rect.x, rect.y,
+ rect.width, rect.height,
+ TRUE);
+ }
+ }
+ while (pango_layout_iter_next_char (iter));
+
+#if 0
i = 0;
do
@@ -821,7 +852,7 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool,
{
PangoRectangle crect;
- pango_layout_iter_get_line_extents (line_iter, NULL, &crect);
+ pango_layout_iter_get_line_extents (iter, NULL, &crect);
pango_extents_to_pixels (&crect, NULL);
gimp_text_layout_transform_rect (text_tool->layout, &crect);
@@ -848,9 +879,10 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool,
i++;
}
- while (pango_layout_iter_next_line (line_iter));
+ while (pango_layout_iter_next_line (iter));
+#endif
- pango_layout_iter_free (line_iter);
+ pango_layout_iter_free (iter);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]