From e51c4481fb73dffca8d16841ab3a61faccdb5251 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 25 Feb 2019 11:36:18 +0100 Subject: [PATCH] pango: prevent deprecation warning --- kivy/core/text/_text_pango.pyx | 6 +----- kivy/lib/pango/pangoft2.h | 9 +++++++++ kivy/lib/pango/pangoft2.pxi | 6 +++--- setup.py | 4 +++- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 kivy/lib/pango/pangoft2.h diff --git a/kivy/core/text/_text_pango.pyx b/kivy/core/text/_text_pango.pyx index 96c0a59a6..1d4f2a31d 100644 --- a/kivy/core/text/_text_pango.pyx +++ b/kivy/core/text/_text_pango.pyx @@ -434,11 +434,7 @@ cdef ContextContainer _get_or_create_cc(bytes font_context, bytes font_name_r): pango_ft2_font_map_set_default_substitute(PANGO_FT2_FONT_MAP(cc.fontmap), &_ft2subst_callback, &cc.ft2subst_callback_data, NULL) - # FIXME: Can we avoid deprecation warning? - if PANGO_VERSION_CHECK(1, 22, 0): - cc.context = pango_font_map_create_context(cc.fontmap) - else: - cc.context = pango_ft2_font_map_create_context(PANGO_FT2_FONT_MAP(cc.fontmap)) + cc.context = _pango_font_map_create_context(cc.fontmap) if not cc.context: Logger.warn("_text_pango: Could not create pango context") return diff --git a/kivy/lib/pango/pangoft2.h b/kivy/lib/pango/pangoft2.h new file mode 100644 index 000000000..a4bc753d8 --- /dev/null +++ b/kivy/lib/pango/pangoft2.h @@ -0,0 +1,9 @@ +// needed to prevent warning during compilation + +#if PANGO_VERSION_CHECK(1, 22, 0) +#define _pango_font_map_create_context(fontmap) \ + pango_font_map_create_context(fontmap) +#else +#define _pango_font_map_create_context(fontmap) \ + pango_ft2_font_map_create_context(PANGO_FT2_FONT_MAP(fontmap)) +#endif diff --git a/kivy/lib/pango/pangoft2.pxi b/kivy/lib/pango/pangoft2.pxi index fb258131a..09383bc38 100644 --- a/kivy/lib/pango/pangoft2.pxi +++ b/kivy/lib/pango/pangoft2.pxi @@ -15,7 +15,6 @@ cdef extern from "glib.h" nogil: # gpointer GUINT_TO_POINTER(guint u) # guint GPOINTER_TO_UINT(gpointer p) - # https://www.freetype.org/freetype2/docs/reference/ft2-index.html cdef extern from "../../lib/pango/freetype2.h" nogil: int FREETYPE_MAJOR @@ -229,7 +228,6 @@ cdef extern from "pango/pangoft2.h" nogil: void pango_ft2_render_layout(FT_Bitmap *bitmap, PangoLayout *layout, int x, int y) void pango_ft2_render_layout_subpixel(FT_Bitmap *bitmap, PangoLayout *layout, int x, int y) void pango_ft2_font_map_set_default_substitute(PangoFT2FontMap *fontmap, PangoFT2SubstituteFunc func, gpointer data, GDestroyNotify notify) - PangoContext *pango_ft2_font_map_create_context(PangoFT2FontMap *fontmap) # < v1.22, now pango_font_map_create_context void pango_ft2_font_map_substitute_changed(PangoFT2FontMap *fontmap) @@ -269,7 +267,6 @@ cdef extern from "pango/pango-font.h" nogil: pass PangoFontMap *pango_ft2_font_map_new() - PangoContext *pango_font_map_create_context(PangoFontMap *fontmap) PangoFontDescription* pango_font_description_new() PangoFontDescription* pango_font_description_from_string(const char *string) void pango_font_description_free(PangoFontDescription *desc) @@ -364,3 +361,6 @@ cdef extern from "pango/pango-layout.h" nogil: gboolean pango_layout_get_justify(PangoLayout *layout) void pango_layout_set_single_paragraph_mode(PangoLayout *layout, gboolean setting) gboolean pango_layout_get_single_paragraph_mode(PangoLayout *layout) + +cdef extern from "../../lib/pango/pangoft2.h" nogil: + PangoContext *_pango_font_map_create_context(PangoFontMap *fontmap) diff --git a/setup.py b/setup.py index 43caa85b3..bf9e9d112 100644 --- a/setup.py +++ b/setup.py @@ -856,7 +856,9 @@ if c_options['use_pangoft2'] in (None, True) and platform not in ( if pango_flags and 'libraries' in pango_flags: print('Pango: pangoft2 found via pkg-config') c_options['use_pangoft2'] = True - pango_depends = {'depends': ['lib/pango/pangoft2.pxi']} + pango_depends = {'depends': [ + 'lib/pango/pangoft2.pxi', + 'lib/pango/pangoft2.h']} sources['core/text/_text_pango.pyx'] = merge( base_flags, pango_flags, pango_depends) print(sources['core/text/_text_pango.pyx'])