[pango/pango2-cleanups: 60/70] Clean up font classes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2-cleanups: 60/70] Clean up font classes
- Date: Thu, 17 Feb 2022 20:36:17 +0000 (UTC)
commit 47133fbb6e2a4136b5cd4e09b755cddbd6d83c14
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 12 14:41:18 2022 -0500
Clean up font classes
Do away with class privates.
pango/fonts.c | 44 ++++++++-----------------
pango/pango-font-face-private.h | 16 +++-------
pango/pango-font-family-private.h | 17 +++-------
pango/pango-font-private.h | 67 ++++++++++++++++-----------------------
pango/pango-fontmap-private.h | 5 ---
pango/pangofc-font.c | 13 +++-----
6 files changed, 56 insertions(+), 106 deletions(-)
---
diff --git a/pango/fonts.c b/pango/fonts.c
index bb5b3626..9154355e 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -41,13 +41,8 @@ typedef struct {
hb_font_t *hb_font;
} PangoFontPrivate;
-#define PANGO_FONT_GET_CLASS_PRIVATE(font) ((PangoFontClassPrivate *) \
- g_type_class_get_private ((GTypeClass *) PANGO_FONT_GET_CLASS (font), \
- PANGO_TYPE_FONT))
-
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PangoFont, pango_font, G_TYPE_OBJECT,
- G_ADD_PRIVATE (PangoFont)
- g_type_add_class_private (g_define_type_id, sizeof
(PangoFontClassPrivate)))
+ G_ADD_PRIVATE (PangoFont))
static void
pango_font_finalize (GObject *object)
@@ -122,19 +117,16 @@ static void
pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- PangoFontClassPrivate *pclass;
object_class->finalize = pango_font_finalize;
- pclass = g_type_class_get_private ((GTypeClass *) class, PANGO_TYPE_FONT);
-
- pclass->get_languages = pango_font_default_get_languages;
- pclass->is_hinted = pango_font_default_is_hinted;
- pclass->get_scale_factors = pango_font_default_get_scale_factors;
- pclass->has_char = pango_font_default_has_char;
- pclass->get_face = pango_font_default_get_face;
- pclass->get_matrix = pango_font_default_get_matrix;
- pclass->get_absolute_size = pango_font_default_get_absolute_size;
+ class->get_languages = pango_font_default_get_languages;
+ class->is_hinted = pango_font_default_is_hinted;
+ class->get_scale_factors = pango_font_default_get_scale_factors;
+ class->has_char = pango_font_default_has_char;
+ class->get_face = pango_font_default_get_face;
+ class->get_matrix = pango_font_default_get_matrix;
+ class->get_absolute_size = pango_font_default_get_absolute_size;
}
static void
@@ -343,9 +335,7 @@ pango_font_get_font_map (PangoFont *font)
PangoFontFace *
pango_font_get_face (PangoFont *font)
{
- PangoFontClassPrivate *pclass = PANGO_FONT_GET_CLASS_PRIVATE (font);
-
- return pclass->get_face (font);
+ return PANGO_FONT_GET_CLASS (font)->get_face (font);
}
/**
@@ -395,9 +385,7 @@ gboolean
pango_font_has_char (PangoFont *font,
gunichar wc)
{
- PangoFontClassPrivate *pclass = PANGO_FONT_GET_CLASS_PRIVATE (font);
-
- return pclass->has_char (font, wc);
+ return PANGO_FONT_GET_CLASS (font)->has_char (font, wc);
}
/**
@@ -447,9 +435,7 @@ pango_font_get_features (PangoFont *font,
PangoLanguage **
pango_font_get_languages (PangoFont *font)
{
- PangoFontClassPrivate *pclass = PANGO_FONT_GET_CLASS_PRIVATE (font);
-
- return pclass->get_languages (font);
+ return PANGO_FONT_GET_CLASS (font)->get_languages (font);
}
/*< private >
@@ -462,9 +448,7 @@ void
pango_font_get_matrix (PangoFont *font,
PangoMatrix *matrix)
{
- PangoFontClassPrivate *pclass = PANGO_FONT_GET_CLASS_PRIVATE (font);
-
- pclass->get_matrix (font, matrix);
+ PANGO_FONT_GET_CLASS (font)->get_matrix (font, matrix);
}
/*< private >
@@ -478,7 +462,7 @@ pango_font_get_matrix (PangoFont *font,
gboolean
pango_font_is_hinted (PangoFont *font)
{
- return PANGO_FONT_GET_CLASS_PRIVATE (font)->is_hinted (font);
+ return PANGO_FONT_GET_CLASS (font)->is_hinted (font);
}
/*< private >
@@ -497,5 +481,5 @@ pango_font_get_scale_factors (PangoFont *font,
double *x_scale,
double *y_scale)
{
- PANGO_FONT_GET_CLASS_PRIVATE (font)->get_scale_factors (font, x_scale, y_scale);
+ PANGO_FONT_GET_CLASS (font)->get_scale_factors (font, x_scale, y_scale);
}
diff --git a/pango/pango-font-face-private.h b/pango/pango-font-face-private.h
index 299632e9..bf5a8519 100644
--- a/pango/pango-font-face-private.h
+++ b/pango/pango-font-face-private.h
@@ -35,18 +35,10 @@ struct _PangoFontFaceClass
{
GObjectClass parent_class;
- /*< public >*/
-
- const char * (*get_face_name) (PangoFontFace *face);
- PangoFontDescription * (*describe) (PangoFontFace *face);
- gboolean (*is_synthesized) (PangoFontFace *face);
- PangoFontFamily * (*get_family) (PangoFontFace *face);
-
- /*< private >*/
-
- /* Padding for future expansion */
- void (*_pango_reserved3) (void);
- void (*_pango_reserved4) (void);
+ const char * (* get_face_name) (PangoFontFace *face);
+ PangoFontDescription * (* describe) (PangoFontFace *face);
+ gboolean (* is_synthesized) (PangoFontFace *face);
+ PangoFontFamily * (* get_family) (PangoFontFace *face);
};
#define PANGO_FONT_FACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE,
PangoFontFaceClass))
diff --git a/pango/pango-font-family-private.h b/pango/pango-font-family-private.h
index b6ceacfe..ac7b7cc2 100644
--- a/pango/pango-font-family-private.h
+++ b/pango/pango-font-family-private.h
@@ -35,20 +35,13 @@ struct _PangoFontFamilyClass
{
GObjectClass parent_class;
- /*< public >*/
+ const char * (* get_name) (PangoFontFamily *family);
+ gboolean (* is_monospace) (PangoFontFamily *family);
+ gboolean (* is_variable) (PangoFontFamily *family);
- const char * (*get_name) (PangoFontFamily *family);
- gboolean (*is_monospace) (PangoFontFamily *family);
- gboolean (*is_variable) (PangoFontFamily *family);
+ PangoFontFace * (* get_face) (PangoFontFamily *family,
+ const char *name);
- PangoFontFace * (*get_face) (PangoFontFamily *family,
- const char *name);
-
-
- /*< private >*/
-
- /* Padding for future expansion */
- void (*_pango_reserved2) (void);
};
#define PANGO_FONT_FAMILY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY,
PangoFontFamilyClass))
diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h
index 6fcbb7aa..79250a03 100644
--- a/pango/pango-font-private.h
+++ b/pango/pango-font-private.h
@@ -41,48 +41,39 @@ struct _PangoFontClass
{
GObjectClass parent_class;
- /*< public >*/
-
- PangoFontDescription *(*describe) (PangoFont *font);
- PangoCoverage * (*get_coverage) (PangoFont *font,
- PangoLanguage *language);
- void (*get_glyph_extents) (PangoFont *font,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
- PangoFontMetrics * (*get_metrics) (PangoFont *font,
- PangoLanguage *language);
- PangoFontMap * (*get_font_map) (PangoFont *font);
- PangoFontDescription *(*describe_absolute) (PangoFont *font);
- void (*get_features) (PangoFont *font,
- hb_feature_t *features,
- guint len,
- guint *num_features);
- hb_font_t * (*create_hb_font) (PangoFont *font);
+ PangoFontDescription * (* describe) (PangoFont *font);
+ PangoCoverage * (* get_coverage) (PangoFont *font,
+ PangoLanguage *language);
+ void (* get_glyph_extents) (PangoFont *font,
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
+ PangoFontMetrics * (* get_metrics) (PangoFont *font,
+ PangoLanguage *language);
+ PangoFontMap * (* get_font_map) (PangoFont *font);
+ PangoFontDescription * (* describe_absolute) (PangoFont *font);
+ void (* get_features) (PangoFont *font,
+ hb_feature_t *features,
+ guint len,
+ guint *num_features);
+ hb_font_t * (* create_hb_font) (PangoFont *font);
+ PangoLanguage ** (* get_languages) (PangoFont *font);
+ gboolean (* is_hinted) (PangoFont *font);
+ void (* get_scale_factors) (PangoFont *font,
+ double *x_scale,
+ double *y_scale);
+ gboolean (* has_char) (PangoFont *font,
+ gunichar wc);
+ PangoFontFace * (* get_face) (PangoFont *font);
+ void (* get_matrix) (PangoFont *font,
+ PangoMatrix *matrix);
+ int (* get_absolute_size) (PangoFont *font);
};
#define PANGO_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass))
#define PANGO_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT))
#define PANGO_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass))
-
-typedef struct {
- PangoLanguage ** (* get_languages) (PangoFont *font);
-
- gboolean (* is_hinted) (PangoFont *font);
-
- void (* get_scale_factors) (PangoFont *font,
- double *x_scale,
- double *y_scale);
-
- gboolean (* has_char) (PangoFont *font,
- gunichar wc);
- PangoFontFace * (* get_face) (PangoFont *font);
- void (* get_matrix) (PangoFont *font,
- PangoMatrix *matrix);
- int (* get_absolute_size) (PangoFont *font);
-} PangoFontClassPrivate;
-
gboolean pango_font_is_hinted (PangoFont *font);
void pango_font_get_scale_factors (PangoFont *font,
double *x_scale,
@@ -92,9 +83,7 @@ void pango_font_get_matrix (PangoFont *font,
static inline int pango_font_get_absolute_size (PangoFont *font)
{
- GTypeClass *klass = (GTypeClass *) PANGO_FONT_GET_CLASS (font);
- PangoFontClassPrivate *priv = g_type_class_get_private (klass, PANGO_TYPE_FONT);
- return priv->get_absolute_size (font);
+ return PANGO_FONT_GET_CLASS (font)->get_absolute_size (font);
}
G_END_DECLS
diff --git a/pango/pango-fontmap-private.h b/pango/pango-fontmap-private.h
index 34e997e3..3c14c656 100644
--- a/pango/pango-fontmap-private.h
+++ b/pango/pango-fontmap-private.h
@@ -43,14 +43,9 @@ struct _PangoFontMapClass
{
GObjectClass parent_class;
- /*< public >*/
-
PangoFont * (*load_font) (PangoFontMap *fontmap,
PangoContext *context,
const PangoFontDescription *desc);
- void (*list_families) (PangoFontMap *fontmap,
- PangoFontFamily ***families,
- int *n_families);
PangoFontset *(*load_fontset) (PangoFontMap *fontmap,
PangoContext *context,
const PangoFontDescription *desc,
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 9dc5e98d..a5b20968 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -91,7 +91,6 @@ pango_fc_font_class_init (PangoFcFontClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
PangoFontClass *font_class = PANGO_FONT_CLASS (class);
- PangoFontClassPrivate *pclass;
class->has_char = pango_fc_font_real_has_char;
class->get_glyph = pango_fc_font_real_get_glyph;
@@ -108,13 +107,11 @@ pango_fc_font_class_init (PangoFcFontClass *class)
font_class->get_features = pango_fc_font_get_features;
font_class->create_hb_font = pango_fc_font_create_hb_font;
- pclass = g_type_class_get_private ((GTypeClass *) class, PANGO_TYPE_FONT);
-
- pclass->get_languages = _pango_fc_font_get_languages;
- pclass->is_hinted = _pango_fc_font_is_hinted;
- pclass->get_scale_factors = _pango_fc_font_get_scale_factors;
- pclass->get_matrix = pango_fc_font_get_matrix;
- pclass->get_absolute_size = pango_fc_font_get_absolute_size;
+ font_class->get_languages = _pango_fc_font_get_languages;
+ font_class->is_hinted = _pango_fc_font_is_hinted;
+ font_class->get_scale_factors = _pango_fc_font_get_scale_factors;
+ font_class->get_matrix = pango_fc_font_get_matrix;
+ font_class->get_absolute_size = pango_fc_font_get_absolute_size;
/**
* PangoFcFont:pattern:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]