X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Ffont.c;h=3755c1ff7652c8d0aa013b0c96b41115bdcc4b66;hb=770360278c9acd563149b3d6bb2bbcc2f4f1b99b;hp=7a6338b0e9c86674c62b5a2756ff1397cb9ac8ba;hpb=ef4bec071b1b18ea937cef2da6e6ba8aebbe35c6;p=chaz%2Fopenbox diff --git a/render/font.c b/render/font.c index 7a6338b0..3755c1ff 100644 --- a/render/font.c +++ b/render/font.c @@ -34,13 +34,30 @@ static void measure_font(const RrInstance *inst, RrFont *f) { PangoFontMetrics *metrics; + static PangoLanguage *lang = NULL; + + if (lang == NULL) { +#if PANGO_VERSION_MAJOR > 1 || \ + (PANGO_VERSION_MAJOR == 1 && PANGO_VERSION_MINOR >= 16) + lang = pango_language_get_default(); +#else + gchar *locale, *p; + /* get the default language from the locale + (based on gtk_get_default_language in gtkmain.c) */ + locale = g_strdup(setlocale(LC_CTYPE, NULL)); + if ((p = strchr(locale, '.'))) *p = '\0'; /* strip off the . */ + if ((p = strchr(locale, '@'))) *p = '\0'; /* strip off the @ */ + lang = pango_language_from_string(locale); + g_free(locale); +#endif + } /* measure the ascent and descent */ - metrics = pango_context_get_metrics(inst->pango, f->font_desc, - pango_language_get_default()); + metrics = pango_context_get_metrics(inst->pango, f->font_desc, lang); f->ascent = pango_font_metrics_get_ascent(metrics); f->descent = pango_font_metrics_get_descent(metrics); pango_font_metrics_unref(metrics); + } RrFont *RrFontOpen(const RrInstance *inst, const gchar *name, gint size,