Getting the resolved direction out of a PangoLayout
Submitted by Owen Taylor
Link to original bug (#135843)
Description
Had to write:
static PangoDirection get_cursor_direction (GtkLabel *label) { PangoDirection last_direction; GSList *lines;
g_assert (label->select_info);
gtk_label_ensure_layout (label);
for (l = pango_layout_get_lines (label->layout);; l; l = l->next) { PangoLayoutLine *line = l->data;
/* If label->select_info->selection_end is at the very end of
* the line, we don't know if the cursor is on this line or
* the next without looking ahead at the next line. (End
* of paragraph is different from line break.) But it's
* definitely in this paragraph, which is good enough
* to figure out the resolved direction.
*/
if (line->start_index + line->length >=
label->select_info->selection_end) return line->resolved_dir; }
return PANGO_DIRECTION_LTR; }
Should be in Pango.
Version: 1.4.x