static gboolean layout_is_ellipsized(PangoLayout *layout) { /* pango_layout_is_ellipsized() is a new function in Pango-1.16; we * emulate it here by trying to look for the ellipsis run */ PangoLogAttr *log_attrs; int n_attrs; PangoLayoutIter *iter; gboolean result = FALSE; /* Short circuit when we aren't ellipsizing at all */ if (pango_layout_get_ellipsize(layout) == PANGO_ELLIPSIZE_NONE) return FALSE; pango_layout_get_log_attrs(layout, &log_attrs, &n_attrs); iter = pango_layout_get_iter(layout); do { PangoGlyphItem *run; int n_glyphs; int start_index; int n_graphemes; int i; run = pango_layout_iter_get_run(iter); if (!run) continue; n_glyphs = run->glyphs->num_glyphs; start_index = pango_layout_iter_get_index(iter); /* Check the number of clusters in the run ... if it is greater * than 1, then it isn't an ellipsis */ if (run->glyphs->log_clusters[0] != run->glyphs->log_clusters[n_glyphs - 1]) continue; /* Now check the number of graphemes in the run ... if it is less * than 3, it's probably an isolated 'fi' ligature or something * like that rather than an ellipsis. */ n_graphemes = 0; for (i = 0; i < run->item->num_chars && i + start_index < n_attrs; i++) if (log_attrs[i + start_index].is_cursor_position) n_graphemes++; if (n_graphemes < 3) continue; /* OK, at this point it is probably an ellipsis; it's possible that * the text consists of just the letters 'ffi' and the font has a ligature * for that or something, but it's not too likely. */ result = TRUE; break; } while (pango_layout_iter_next_run(iter)); pango_layout_iter_free(iter); g_free(log_attrs); return result; }
static VALUE rg_ellipsize(VALUE self) { return GENUM2RVAL(pango_layout_get_ellipsize(_SELF(self)), PANGO_TYPE_ELLIPSIZE_MODE); }
static VALUE rg_ellipsize(VALUE self) { return PANGOELLIPSIZEMODE2RVAL(pango_layout_get_ellipsize(_SELF(self))); }