diff options
| author | Dana Jansens <danakj@orodu.net> | 2007-05-09 21:41:16 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2007-05-09 21:41:16 +0000 |
| commit | c4385c098fb5547dd80b06636c946676f274d396 (patch) | |
| tree | 9e503e5da19f4a791bf55dd79884cd140eb2ac58 | |
| parent | fa67faf88c6e9c62dcbac838b6dc1c572ea9831a (diff) | |
use pango 1.16 stuff if its there. and use the old stuff if not. also! save it in static variable so we dont have to update it over and over.
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | render/font.c | 20 |
2 files changed, 19 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 2f4c0e0a..b6c7803f 100644 --- a/configure.ac +++ b/configure.ac @@ -74,7 +74,7 @@ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.6.0]) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) -PKG_CHECK_MODULES(PANGO, [pango >= 1.16.0 pangoxft >= 1.8.0]) +PKG_CHECK_MODULES(PANGO, [pango >= 1.8.0 pangoxft >= 1.8.0]) AC_SUBST(PANGO_CFLAGS) AC_SUBST(PANGO_LIBS) diff --git a/render/font.c b/render/font.c index 7a6338b0..166b9abb 100644 --- a/render/font.c +++ b/render/font.c @@ -34,13 +34,29 @@ static void measure_font(const RrInstance *inst, RrFont *f) { PangoFontMetrics *metrics; + static PangoLanguage *lang = NULL; + + if (lang == NULL) { +#if PANGO_VERSION_CHECK(1,16,0) + 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, |
