diff options
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-fontmap.c | 30 | ||||
-rw-r--r-- | pango/pango-fontmap.h | 8 | ||||
-rw-r--r-- | pango/pango.def | 1 | ||||
-rw-r--r-- | pango/pangocairo-coretext.h | 1 | ||||
-rw-r--r-- | pango/pangocairo-coretextfontmap.c | 15 | ||||
-rw-r--r-- | pango/pangocairo-fc.h | 1 | ||||
-rw-r--r-- | pango/pangocairo-fcfontmap.c | 22 | ||||
-rw-r--r-- | pango/pangocairo-win32.h | 1 | ||||
-rw-r--r-- | pango/pangocairo-win32fontmap.c | 14 | ||||
-rw-r--r-- | pango/pangocoretext-fontmap.c | 10 | ||||
-rw-r--r-- | pango/pangocoretext-private.h | 1 | ||||
-rw-r--r-- | pango/pangoft2-fontmap.c | 20 | ||||
-rw-r--r-- | pango/pangoxft-fontmap.c | 25 |
13 files changed, 143 insertions, 6 deletions
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c index 6e90ada1..e1d6bb0f 100644 --- a/pango/pango-fontmap.c +++ b/pango/pango-fontmap.c @@ -284,3 +284,33 @@ pango_font_map_get_shape_engine_type (PangoFontMap *fontmap) return PANGO_FONT_MAP_GET_CLASS (fontmap)->shape_engine_type; } +/** + * pango_font_map_get_serial: + * @fontmap: a #PangoFontMap + * + * Returns the current serial number of @fontmap. The serial number is + * initialized to an small number larger than zero when a new fontmap + * is created and is increased whenever the fontmap is changed. It may + * wrap, but will never have the value 0. Since it can wrap, never compare + * it with "less than", always use "not equals". + * + * The fontmap can only be changed using backend-specific API, like changing + * fontmap resolution. + * + * This can be used to automatically detect changes to a #PangoFontMap, like + * in #PangoContext. + * + * Return value: The current serial number of @fontmap. + * + * Since: 1.32.4 + **/ +guint +pango_font_map_get_serial (PangoFontMap *fontmap) +{ + g_return_val_if_fail (PANGO_IS_FONT_MAP (fontmap), 0); + + if (PANGO_FONT_MAP_GET_CLASS (fontmap)->get_serial) + return PANGO_FONT_MAP_GET_CLASS (fontmap)->get_serial (fontmap); + else + return 1; +} diff --git a/pango/pango-fontmap.h b/pango/pango-fontmap.h index 602ec9fe..0f028baa 100644 --- a/pango/pango-fontmap.h +++ b/pango/pango-fontmap.h @@ -45,6 +45,7 @@ PangoFontset *pango_font_map_load_fontset (PangoFontMap *fontma void pango_font_map_list_families (PangoFontMap *fontmap, PangoFontFamily ***families, int *n_families); +guint pango_font_map_get_serial (PangoFontMap *fontmap); #ifdef PANGO_ENABLE_BACKEND @@ -76,7 +77,9 @@ struct _PangoFontMapClass const PangoFontDescription *desc, PangoLanguage *language); - const char *shape_engine_type; + const char *shape_engine_type; + + guint (*get_serial) (PangoFontMap *fontmap); /*< private >*/ @@ -84,10 +87,9 @@ struct _PangoFontMapClass void (*_pango_reserved1) (void); void (*_pango_reserved2) (void); void (*_pango_reserved3) (void); - void (*_pango_reserved4) (void); }; -const char *pango_font_map_get_shape_engine_type (PangoFontMap *fontmap); +G_CONST_RETURN char *pango_font_map_get_shape_engine_type (PangoFontMap *fontmap); #endif /* PANGO_ENABLE_BACKEND */ diff --git a/pango/pango.def b/pango/pango.def index ba1289ce..66e70d3b 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -151,6 +151,7 @@ EXPORTS pango_font_get_type pango_font_map_create_context pango_font_map_get_shape_engine_type + pango_font_map_get_serial pango_font_map_get_type pango_font_map_list_families pango_font_map_load_font diff --git a/pango/pangocairo-coretext.h b/pango/pangocairo-coretext.h index 4310f45f..31faf9be 100644 --- a/pango/pangocairo-coretext.h +++ b/pango/pangocairo-coretext.h @@ -39,6 +39,7 @@ struct _PangoCairoCoreTextFontMap { PangoCoreTextFontMap parent_instance; + guint serial; gdouble dpi; }; diff --git a/pango/pangocairo-coretextfontmap.c b/pango/pangocairo-coretextfontmap.c index cd1f3f25..5561358b 100644 --- a/pango/pangocairo-coretextfontmap.c +++ b/pango/pangocairo-coretextfontmap.c @@ -34,12 +34,23 @@ struct _PangoCairoCoreTextFontMapClass PangoCoreTextFontMapClass parent_class; }; +static guint +pango_cairo_core_text_font_map_get_serial (PangoFontMap *fontmap) +{ + PangoCairoCoreTextFontMap *cafontmap = PANGO_CAIRO_CORE_TEXT_FONT_MAP (fontmap); + + return cafontmap->serial; +} + static void pango_cairo_core_text_font_map_set_resolution (PangoCairoFontMap *cfontmap, double dpi) { PangoCairoCoreTextFontMap *cafontmap = PANGO_CAIRO_CORE_TEXT_FONT_MAP (cfontmap); + cafontmap->serial++; + if (cafontmap->serial == 0) + cafontmap->serial++; cafontmap->dpi = dpi; } @@ -144,10 +155,13 @@ static void pango_cairo_core_text_font_map_class_init (PangoCairoCoreTextFontMapClass *class) { PangoCoreTextFontMapClass *ctfontmapclass = (PangoCoreTextFontMapClass *)class; + PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class); GObjectClass *object_class = (GObjectClass *)class; object_class->finalize = pango_cairo_core_text_font_map_finalize; + fontmap_class->get_serial = pango_cairo_core_text_font_map_get_serial; + ctfontmapclass->get_resolution = pango_cairo_core_text_font_map_get_resolution_core_text; ctfontmapclass->create_font = pango_cairo_core_text_font_map_create_font; ctfontmapclass->context_key_get = pango_cairo_core_text_font_map_context_key_get; @@ -160,5 +174,6 @@ pango_cairo_core_text_font_map_class_init (PangoCairoCoreTextFontMapClass *class static void pango_cairo_core_text_font_map_init (PangoCairoCoreTextFontMap *cafontmap) { + cafontmap->serial = 1; cafontmap->dpi = 72.; } diff --git a/pango/pangocairo-fc.h b/pango/pangocairo-fc.h index ea4fccbc..8873d5b3 100644 --- a/pango/pangocairo-fc.h +++ b/pango/pangocairo-fc.h @@ -37,6 +37,7 @@ struct _PangoCairoFcFontMap { PangoFcFontMap parent_instance; + guint serial; double dpi; FT_Library library; diff --git a/pango/pangocairo-fcfontmap.c b/pango/pangocairo-fcfontmap.c index c2b410ee..69fe4929 100644 --- a/pango/pangocairo-fcfontmap.c +++ b/pango/pangocairo-fcfontmap.c @@ -33,15 +33,29 @@ struct _PangoCairoFcFontMapClass PangoFcFontMapClass parent_class; }; +static guint +pango_cairo_fc_font_map_get_serial (PangoFontMap *fontmap) +{ + PangoCairoFcFontMap *cffontmap = (PangoCairoFcFontMap *) (fontmap); + + return cffontmap->serial; +} + static void pango_cairo_fc_font_map_set_resolution (PangoCairoFontMap *cfontmap, double dpi) { PangoCairoFcFontMap *cffontmap = (PangoCairoFcFontMap *) (cfontmap); - cffontmap->dpi = dpi; + if (dpi != cffontmap->dpi) + { + cffontmap->serial++; + if (cffontmap->serial == 0) + cffontmap->serial++; + cffontmap->dpi = dpi; - pango_fc_font_map_cache_clear ((PangoFcFontMap *) (cfontmap)); + pango_fc_font_map_cache_clear ((PangoFcFontMap *) (cfontmap)); + } } static double @@ -162,10 +176,13 @@ static void pango_cairo_fc_font_map_class_init (PangoCairoFcFontMapClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); + PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class); PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class); gobject_class->finalize = pango_cairo_fc_font_map_finalize; + fontmap_class->get_serial = pango_cairo_fc_font_map_get_serial; + fcfontmap_class->fontset_key_substitute = pango_cairo_fc_font_map_fontset_key_substitute; fcfontmap_class->get_resolution = pango_cairo_fc_font_map_get_resolution_fc; @@ -188,6 +205,7 @@ pango_cairo_fc_font_map_init (PangoCairoFcFontMap *cffontmap) if (error != FT_Err_Ok) g_critical ("pango_cairo_font_map_init: Could not initialize freetype"); + cffontmap->serial = 1; cffontmap->dpi = 96.0; } diff --git a/pango/pangocairo-win32.h b/pango/pangocairo-win32.h index 7a71c0a2..33d0ee45 100644 --- a/pango/pangocairo-win32.h +++ b/pango/pangocairo-win32.h @@ -38,6 +38,7 @@ struct _PangoCairoWin32FontMap { PangoWin32FontMap parent_instance; + guint serial; double dpi; }; diff --git a/pango/pangocairo-win32fontmap.c b/pango/pangocairo-win32fontmap.c index c5ec6cd2..cd4e12ee 100644 --- a/pango/pangocairo-win32fontmap.c +++ b/pango/pangocairo-win32fontmap.c @@ -33,12 +33,23 @@ struct _PangoCairoWin32FontMapClass PangoWin32FontMapClass parent_class; }; +static guint +pango_cairo_win32_font_map_get_serial (PangoFontMap *fontmap) +{ + PangoCairoWin32FontMap *cwfontmap = PANGO_CAIRO_WIN32_FONT_MAP (fontmap); + + return cwfontmap->serial; +} + static void pango_cairo_win32_font_map_set_resolution (PangoCairoFontMap *cfontmap, double dpi) { PangoCairoWin32FontMap *cwfontmap = PANGO_CAIRO_WIN32_FONT_MAP (cfontmap); + cwfontmap->serial++; + if (cwfontmap->serial == 0) + cwfontmap->serial++; cwfontmap->dpi = dpi; } @@ -89,14 +100,17 @@ static void pango_cairo_win32_font_map_class_init (PangoCairoWin32FontMapClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); + PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class); PangoWin32FontMapClass *win32fontmap_class = PANGO_WIN32_FONT_MAP_CLASS (class); gobject_class->finalize = pango_cairo_win32_font_map_finalize; + fontmap_class->get_serial = pango_cairo_win32_font_map_get_serial; win32fontmap_class->find_font = pango_cairo_win32_font_map_find_font; } static void pango_cairo_win32_font_map_init (PangoCairoWin32FontMap *cwfontmap) { + cwfontmap->serial = 1; cwfontmap->dpi = GetDeviceCaps (pango_win32_get_dc (), LOGPIXELSY); } diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c index a8a9b518..7993d59e 100644 --- a/pango/pangocoretext-fontmap.c +++ b/pango/pangocoretext-fontmap.c @@ -1191,6 +1191,14 @@ get_first_font (PangoFontset *fontset G_GNUC_UNUSED, return TRUE; } +static guint +pango_core_text_font_map_get_serial (PangoFontMap *fontmap) +{ + PangoCoreTextFontMap *ctfontmap = PANGO_CORE_TEXT_FONT_MAP (fontmap); + + return ctfontmap->serial; +} + static PangoFont * pango_core_text_font_map_load_font (PangoFontMap *fontmap, PangoContext *context, @@ -1370,6 +1378,7 @@ pango_core_text_font_map_init (PangoCoreTextFontMap *ctfontmap) CFArrayRef ctfaces; CFIndex i, count; + ctfontmap->serial = 1; ctfontmap->families = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); @@ -1461,6 +1470,7 @@ pango_core_text_font_map_class_init (PangoCoreTextFontMapClass *class) fontmap_class->list_families = pango_core_text_font_map_list_families; fontmap_class->load_fontset = pango_core_text_font_map_load_fontset; fontmap_class->shape_engine_type = PANGO_RENDER_TYPE_CORE_TEXT; + fontmap_class->get_serial = pango_core_text_font_map_get_serial; } /* diff --git a/pango/pangocoretext-private.h b/pango/pangocoretext-private.h index 3e0dafdc..8076eaea 100644 --- a/pango/pangocoretext-private.h +++ b/pango/pangocoretext-private.h @@ -51,6 +51,7 @@ struct _PangoCoreTextFontMap { PangoFontMap parent_instance; + guint serial; GHashTable *fontset_hash; GHashTable *font_hash; diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c index 662b8ad9..996bbb1f 100644 --- a/pango/pangoft2-fontmap.c +++ b/pango/pangoft2-fontmap.c @@ -43,6 +43,7 @@ struct _PangoFT2FontMap FT_Library library; + guint serial; double dpi_x; double dpi_y; @@ -66,6 +67,7 @@ static PangoFcFont * pango_ft2_font_map_new_font (PangoFcFontMap FcPattern *pattern); static double pango_ft2_font_map_get_resolution (PangoFcFontMap *fcfontmap, PangoContext *context); +static guint pango_ft2_font_map_get_serial (PangoFontMap *fontmap); static PangoFT2FontMap *pango_ft2_global_fontmap = NULL; /* MT-safe */ @@ -75,9 +77,11 @@ static void pango_ft2_font_map_class_init (PangoFT2FontMapClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); + PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class); PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class); gobject_class->finalize = pango_ft2_font_map_finalize; + fontmap_class->get_serial = pango_ft2_font_map_get_serial; fcfontmap_class->default_substitute = _pango_ft2_font_map_default_substitute; fcfontmap_class->new_font = pango_ft2_font_map_new_font; fcfontmap_class->get_resolution = pango_ft2_font_map_get_resolution; @@ -86,6 +90,7 @@ pango_ft2_font_map_class_init (PangoFT2FontMapClass *class) static void pango_ft2_font_map_init (PangoFT2FontMap *fontmap) { + fontmap->serial = 1; fontmap->library = NULL; fontmap->dpi_x = 72.0; fontmap->dpi_y = 72.0; @@ -139,6 +144,14 @@ pango_ft2_font_map_new (void) return (PangoFontMap *)ft2fontmap; } +static guint +pango_ft2_font_map_get_serial (PangoFontMap *fontmap) +{ + PangoFT2FontMap *ft2fontmap = PANGO_FT2_FONT_MAP (fontmap); + + return ft2fontmap->serial; +} + /** * pango_ft2_font_map_set_default_substitute: * @fontmap: a #PangoFT2FontMap @@ -160,6 +173,10 @@ pango_ft2_font_map_set_default_substitute (PangoFT2FontMap *fontmap, gpointer data, GDestroyNotify notify) { + fontmap->serial++; + if (fontmap->serial == 0) + fontmap->serial++; + if (fontmap->substitute_destroy) fontmap->substitute_destroy (fontmap->substitute_data); @@ -185,6 +202,9 @@ pango_ft2_font_map_set_default_substitute (PangoFT2FontMap *fontmap, void pango_ft2_font_map_substitute_changed (PangoFT2FontMap *fontmap) { + fontmap->serial++; + if (fontmap->serial == 0) + fontmap->serial++; pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (fontmap)); } diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c index 9d210b50..aa891c54 100644 --- a/pango/pangoxft-fontmap.c +++ b/pango/pangoxft-fontmap.c @@ -41,6 +41,8 @@ struct _PangoXftFontMap { PangoFcFontMap parent_instance; + guint serial; + Display *display; int screen; @@ -59,6 +61,7 @@ struct _PangoXftFontMapClass PangoFcFontMapClass parent_class; }; +static guint pango_xft_font_map_get_serial (PangoFontMap *fontmap); static void pango_xft_font_map_default_substitute (PangoFcFontMap *fcfontmap, FcPattern *pattern); static PangoFcFont * pango_xft_font_map_new_font (PangoFcFontMap *fcfontmap, @@ -74,16 +77,21 @@ static void pango_xft_font_map_class_init (PangoXftFontMapClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); + PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class); PangoFcFontMapClass *fcfontmap_class = PANGO_FC_FONT_MAP_CLASS (class); gobject_class->finalize = pango_xft_font_map_finalize; + + fontmap_class->get_serial = pango_xft_font_map_get_serial; + fcfontmap_class->default_substitute = pango_xft_font_map_default_substitute; fcfontmap_class->new_font = pango_xft_font_map_new_font; } static void -pango_xft_font_map_init (PangoXftFontMap *xftfontmap G_GNUC_UNUSED) +pango_xft_font_map_init (PangoXftFontMap *xftfontmap) { + xftfontmap->serial = 1; } static void @@ -105,6 +113,14 @@ pango_xft_font_map_finalize (GObject *object) } +static guint +pango_xft_font_map_get_serial (PangoFontMap *fontmap) +{ + PangoXftFontMap *xftfontmap = PANGO_XFT_FONT_MAP (fontmap); + + return xftfontmap->serial; +} + static PangoFontMap * pango_xft_find_font_map (Display *display, int screen) @@ -283,6 +299,10 @@ pango_xft_set_default_substitute (Display *display, { PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen); + xftfontmap->serial++; + if (xftfontmap->serial == 0) + xftfontmap->serial++; + if (xftfontmap->substitute_destroy) xftfontmap->substitute_destroy (xftfontmap->substitute_data); @@ -312,6 +332,9 @@ pango_xft_substitute_changed (Display *display, { PangoXftFontMap *xftfontmap = (PangoXftFontMap *)pango_xft_get_font_map (display, screen); + xftfontmap->serial++; + if (xftfontmap->serial == 0) + xftfontmap->serial++; pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (xftfontmap)); } |