diff options
-rw-r--r-- | pango/fonts.c | 57 | ||||
-rw-r--r-- | pango/pango-fontmap.c | 59 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 2 | ||||
-rw-r--r-- | tests/layouts/valid-20.layout | 8 |
4 files changed, 121 insertions, 5 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index 004089fc..e7bd4780 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -2385,13 +2385,68 @@ pango_font_family_default_list_faces (PangoFontFamily *family, *n_faces = 0; } +enum { + PROP_ITEM_TYPE = 1, + PROP_N_ITEMS, + N_PROPERTIES +}; + +static GParamSpec *font_family_properties[N_PROPERTIES] = { NULL }; + static void -pango_font_family_class_init (PangoFontFamilyClass *class G_GNUC_UNUSED) +pango_font_family_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { + switch (property_id) + { + case PROP_ITEM_TYPE: + g_value_set_gtype (value, PANGO_TYPE_FONT); + break; + + case PROP_N_ITEMS: + g_value_set_uint (value, pango_font_family_get_n_items (G_LIST_MODEL (object))); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +pango_font_family_class_init (PangoFontFamilyClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + + gobject_class->get_property = pango_font_family_get_property; + class->is_monospace = pango_font_family_default_is_monospace; class->is_variable = pango_font_family_default_is_variable; class->get_face = pango_font_family_real_get_face; class->list_faces = pango_font_family_default_list_faces; + + /** + * PangoFontFamily:item-type: + * + * The type of items contained in this list. + */ + font_family_properties[PROP_ITEM_TYPE] = + g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + /** + * PangoFontFamily:n-items: + * + * The number of items contained in this list. + */ + font_family_properties[PROP_N_ITEMS] = + g_param_spec_uint ("n-items", "", "", 0, G_MAXUINT, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (gobject_class, + N_PROPERTIES, + font_family_properties); } static void diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c index 71e3e20c..20ecb93e 100644 --- a/pango/pango-fontmap.c +++ b/pango/pango-fontmap.c @@ -39,22 +39,79 @@ static PangoFontFamily *pango_font_map_real_get_family (PangoFontMap *fontmap, static void pango_font_map_real_changed (PangoFontMap *fontmap); +static guint pango_font_map_get_n_items (GListModel *list); + static void pango_font_map_list_model_init (GListModelInterface *iface); typedef struct { guint n_families; } PangoFontMapPrivate; +enum +{ + PROP_0, + PROP_ITEM_TYPE, + PROP_N_ITEMS, + N_PROPERTIES +}; + +static GParamSpec *properties[N_PROPERTIES] = { NULL, }; + G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PangoFontMap, pango_font_map, G_TYPE_OBJECT, G_ADD_PRIVATE (PangoFontMap) G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, pango_font_map_list_model_init)) static void +pango_font_map_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) + { + case PROP_ITEM_TYPE: + g_value_set_gtype (value, PANGO_TYPE_FONT_FAMILY); + break; + + case PROP_N_ITEMS: + g_value_set_uint (value, pango_font_map_get_n_items (G_LIST_MODEL (object))); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void pango_font_map_class_init (PangoFontMapClass *class) { + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->get_property = pango_font_map_get_property; + class->load_fontset = pango_font_map_real_load_fontset; class->get_family = pango_font_map_real_get_family; class->changed = pango_font_map_real_changed; + + /** + * PangoFontMap:item-type: + * + * The type of items contained in this list. + */ + properties[PROP_ITEM_TYPE] = + g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + /** + * PangoFontMap:n-items: + * + * The number of items contained in this list. + */ + properties[PROP_N_ITEMS] = + g_param_spec_uint ("n-items", "", "", 0, G_MAXUINT, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPERTIES, properties); } static void @@ -355,6 +412,8 @@ pango_font_map_real_changed (PangoFontMap *fontmap) added = g_list_model_get_n_items (G_LIST_MODEL (fontmap)); g_list_model_items_changed (G_LIST_MODEL (fontmap), 0, removed, added); + if (removed != added) + g_object_notify_by_pspec (G_OBJECT (fontmap), properties[PROP_N_ITEMS]); } /** diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 4c39ea1f..e21032f3 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -2292,6 +2292,8 @@ pango_fc_font_map_cache_clear (PangoFcFontMap *fcfontmap) added = fcfontmap->priv->n_families; g_list_model_items_changed (G_LIST_MODEL (fcfontmap), 0, removed, added); + if (removed != added) + g_object_notify (G_OBJECT (fcfontmap), "n-items"); pango_font_map_changed (PANGO_FONT_MAP (fcfontmap)); } diff --git a/tests/layouts/valid-20.layout b/tests/layouts/valid-20.layout index 5b2bcf15..db692b73 100644 --- a/tests/layouts/valid-20.layout +++ b/tests/layouts/valid-20.layout @@ -40,7 +40,7 @@ "is-wrapped" : false, "is-ellipsized" : false, "unknown-glyphs" : 0, - "width" : 76800, + "width" : 67584, "height" : 25600, "log-attrs" : [ { @@ -138,7 +138,7 @@ "glyphs" : [ { "glyph" : 244, - "width" : 18432, + "width" : 15360, "x-offset" : 14764, "y-offset" : 3845, "is-cluster-start" : true, @@ -146,7 +146,7 @@ }, { "glyph" : 272, - "width" : 18432, + "width" : 15360, "x-offset" : 14764, "y-offset" : 4280, "is-cluster-start" : true, @@ -154,7 +154,7 @@ }, { "glyph" : 273, - "width" : 18432, + "width" : 15360, "x-offset" : 14764, "y-offset" : 3507, "is-cluster-start" : true, |