- text = g_string_new(t->string);
-#ifndef USE_PANGO
- l = g_utf8_strlen(text->str, -1);
- font_measure_full(t->font, text->str, &mw, &mh);
- while (l && mw > area->width) {
- shortened = TRUE;
- /* remove a character from the middle */
- text = g_string_erase(text, l-- / 2, 1);
- /* if the elipses are too large, don't show them at all */
- if (ELIPSES_LENGTH(t->font) > area->width)
- shortened = FALSE;
- font_measure_full(t->font, text->str, &mw, &mh);
- mw += ELIPSES_LENGTH(t->font);
- }
- if (shortened) {
- text = g_string_insert(text, (l + 1) / 2, ELIPSES);
- l += 3;
- }
- if (!l) return;
-
- l = strlen(text->str); /* number of bytes */
-
-#else
- pango_layout_set_text(pl, text->str, -1);
- pango_layout_set_font_description(pl, t->font->pango_font_description);
- pango_layout_set_single_paragraph_mode(pl, TRUE);
- pango_layout_set_width(pl, w * PANGO_SCALE);
- pango_layout_set_ellipsize(pl, PANGO_ELLIPSIZE_MIDDLE);
- /* This doesn't work with layout_line() of course */
-/* pango_layout_set_alignment(pl, (PangoAlignment)(t->justify)); */
- pango_layout_get_pixel_extents(pl, NULL, &rect);
- mw = rect.width;