]> Dogcows Code - chaz/openbox/commitdiff
Update the pango code
authorMikael Magnusson <mikachu@comhem.se>
Fri, 11 Mar 2005 21:49:07 +0000 (21:49 +0000)
committerMikael Magnusson <mikachu@comhem.se>
Fri, 11 Mar 2005 21:49:07 +0000 (21:49 +0000)
render/font.c

index b6e5026b2239731285e8ad6d1788ab664e3e32a1..57d5aa9b11bf4f721e4a6456ee9820378137783c 100644 (file)
@@ -251,14 +251,12 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     XftColor c;
     GString *text;
     gint mw, mh;
+#ifndef USE_PANGO
     size_t l;
     gboolean shortened = FALSE;
-
-#ifdef USE_PANGO
+#else
     PangoLayout *pl;
-    PangoLayoutLine *pll;
     PangoContext *context;
-    GSList *p;
 
     context = pango_xft_get_context (RrDisplay(t->font->inst), RrScreen(t->font->inst));
     pl = pango_layout_new (context);
@@ -273,6 +271,7 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
     h = area->height;
 
     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) {
@@ -304,17 +303,16 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
 
     l = strlen(text->str); /* number of bytes */
 
-#ifdef USE_PANGO
-    pango_layout_set_text(pl, text->str, l);
+#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);
-    pll = pango_layout_get_line(pl, 0);
+    pango_layout_set_width(pl, w * PANGO_SCALE);
+    pango_layout_set_ellipsize(pl, PANGO_ELLIPSIZE_MIDDLE);
+    pango_layout_set_alignment(pl, (PangoAlignment)(t->justify));
 #endif /* USE_PANGO */
 
     if (t->font->shadow) {
-#ifdef USE_PANGO
-        int x2 = x;
-#endif /* USE_PANGO */
         if (t->font->tint >= 0) {
             c.color.red = 0;
             c.color.green = 0;
@@ -330,26 +328,15 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
             c.pixel = WhitePixel(RrDisplay(t->font->inst),
                                  RrScreen(t->font->inst));
 #ifndef USE_PANGO
-        }  
+        }
         XftDrawStringUtf8(d, &c, t->font->xftfont, x + t->font->offset,
                           t->font->xftfont->ascent + y + t->font->offset,
                           (FcChar8*)text->str, l);
-    }  
+    }
 #else /* USE_PANGO */
         }
-
-    for (p = pll->runs; p != NULL; p = p->next)
-        {
-            PangoLayoutRun *run = p->data;
-            PangoFont *font = run->item->analysis.font;
-            PangoGlyphString *glyphs = run->glyphs;
-            PangoRectangle rect;
-
-            pango_glyph_string_extents (glyphs, font, NULL, &rect);
-            pango_xft_render (d, &c, font, glyphs, x2 + t->font->offset,
-                              t->font->xftfont->ascent + y + t->font->offset);
-            x2 += rect.width / PANGO_SCALE;
-        }
+    pango_xft_render_layout(d, &c, pl, (x + t->font->offset) * PANGO_SCALE,
+                            (y + t->font->offset) * PANGO_SCALE);
     }
 #endif /* USE_PANGO */
     c.color.red = t->color->r | t->color->r << 8;
@@ -363,22 +350,10 @@ void RrFontDraw(XftDraw *d, RrTextureText *t, RrRect *area)
                       t->font->xftfont->ascent + y,
                       (FcChar8*)text->str, l);
 #else /* USE_PANGO */
-    for (p = pll->runs; p != NULL; p = p->next)
-        {
-            PangoLayoutRun *run = p->data;
-            PangoFont *font = run->item->analysis.font;
-            PangoGlyphString *glyphs = run->glyphs;
-            PangoRectangle rect;
-
-            pango_glyph_string_extents (glyphs, font, NULL, &rect);
-            pango_xft_render (d, &c, font, glyphs, x, t->font->xftfont->ascent + y);
-            x += rect.width / PANGO_SCALE;
-        }
-
-    //    pango_layout_line_unref(pll);
-        g_object_unref(pl);
-        g_object_unref(context);
-#endif /* USE_PANGO */
+    pango_xft_render_layout(d, &c, pl, x * PANGO_SCALE, y * PANGO_SCALE);
+    g_object_unref(pl);
+    g_object_unref(context);
+#endif
 
     g_string_free(text, TRUE);
     return;
This page took 0.02545 seconds and 4 git commands to generate.