[pango/pango2: 45/63] Drop some font family apis
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 45/63] Drop some font family apis
- Date: Fri, 10 Jun 2022 03:41:34 +0000 (UTC)
commit 3fc3e677e15d547ecf603aec1cd3ff25b31293f9
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 7 21:56:29 2022 -0400
Drop some font family apis
Drop pango_font_family_is_monospace/variable/generic,
since these are better as face apis.
pango/pango-font-face.c | 4 +-
pango/pango-font-family-private.h | 4 --
pango/pango-font-family.c | 89 ---------------------------------------
pango/pango-font-family.h | 6 ---
pango/pango-generic-family.c | 23 ----------
pango/pango-hbfamily.c | 34 ---------------
tests/test-font.c | 30 +------------
tests/testhbfont.c | 6 ---
utils/pango-list.c | 21 ++-------
9 files changed, 6 insertions(+), 211 deletions(-)
---
diff --git a/pango/pango-font-face.c b/pango/pango-font-face.c
index 5165a9b0..cbe0d3e4 100644
--- a/pango/pango-font-face.c
+++ b/pango/pango-font-face.c
@@ -29,13 +29,13 @@ G_DEFINE_ABSTRACT_TYPE (PangoFontFace, pango_font_face, G_TYPE_OBJECT)
static gboolean
pango_font_face_default_is_monospace (PangoFontFace *face)
{
- return pango_font_family_is_monospace (pango_font_face_get_family (face));
+ return FALSE;
}
static gboolean
pango_font_face_default_is_variable (PangoFontFace *face)
{
- return pango_font_family_is_variable (pango_font_face_get_family (face));
+ return FALSE;
}
static gboolean
diff --git a/pango/pango-font-family-private.h b/pango/pango-font-family-private.h
index c7f3b6c2..186df77b 100644
--- a/pango/pango-font-family-private.h
+++ b/pango/pango-font-family-private.h
@@ -34,10 +34,6 @@ struct _PangoFontFamilyClass
GObjectClass parent_class;
const char * (* get_name) (PangoFontFamily *family);
- gboolean (* is_generic) (PangoFontFamily *family);
- gboolean (* is_monospace) (PangoFontFamily *family);
- gboolean (* is_variable) (PangoFontFamily *family);
-
PangoFontFace * (* get_face) (PangoFontFamily *family,
const char *name);
diff --git a/pango/pango-font-family.c b/pango/pango-font-family.c
index 11c46b31..8168ed8c 100644
--- a/pango/pango-font-family.c
+++ b/pango/pango-font-family.c
@@ -60,30 +60,9 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PangoFontFamily, pango_font_family, G_TYPE_OBJ
static PangoFontFace *pango_font_family_real_get_face (PangoFontFamily *family,
const char *name);
-static gboolean
-pango_font_family_default_is_generic (PangoFontFamily *family)
-{
- return FALSE;
-}
-
-static gboolean
-pango_font_family_default_is_monospace (PangoFontFamily *family)
-{
- return FALSE;
-}
-
-static gboolean
-pango_font_family_default_is_variable (PangoFontFamily *family)
-{
- return FALSE;
-}
-
static void
pango_font_family_class_init (PangoFontFamilyClass *class G_GNUC_UNUSED)
{
- class->is_generic = pango_font_family_default_is_generic;
- 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;
}
@@ -156,71 +135,3 @@ pango_font_family_get_face (PangoFontFamily *family,
return PANGO_FONT_FAMILY_GET_CLASS (family)->get_face (family, name);
}
-
-/**
- * pango_font_family_is_generic:
- * @family: a `PangoFontFamily`
- *
- * A generic family is using a generic name such as 'sans' or
- * 'monospace', and collects fonts matching those characteristics.
- *
- * Generic families are often used as fallback.
- *
- * Return value: %TRUE if the family is generic
- */
-gboolean
-pango_font_family_is_generic (PangoFontFamily *family)
-{
- g_return_val_if_fail (PANGO_IS_FONT_FAMILY (family), FALSE);
-
- return PANGO_FONT_FAMILY_GET_CLASS (family)->is_generic (family);
-}
-
-/**
- * pango_font_family_is_monospace:
- * @family: a `PangoFontFamily`
- *
- * A monospace font is a font designed for text display where the the
- * characters form a regular grid.
- *
- * For Western languages this would
- * mean that the advance width of all characters are the same, but
- * this categorization also includes Asian fonts which include
- * double-width characters: characters that occupy two grid cells.
- * g_unichar_iswide() returns a result that indicates whether a
- * character is typically double-width in a monospace font.
- *
- * The best way to find out the grid-cell size is to call
- * [method@Pango.FontMetrics.get_approximate_digit_width], since the
- * results of [method@Pango.FontMetrics.get_approximate_char_width] may
- * be affected by double-width characters.
- *
- * Return value: %TRUE if the family is monospace.
- */
-gboolean
-pango_font_family_is_monospace (PangoFontFamily *family)
-{
- g_return_val_if_fail (PANGO_IS_FONT_FAMILY (family), FALSE);
-
- return PANGO_FONT_FAMILY_GET_CLASS (family)->is_monospace (family);
-}
-
-/**
- * pango_font_family_is_variable:
- * @family: a `PangoFontFamily`
- *
- * A variable font is a font which has axes that can be modified to
- * produce different faces.
- *
- * Such axes are also known as _variations_; see
- * [method@Pango.FontDescription.set_variations] for more information.
- *
- * Return value: %TRUE if the family is variable
- */
-gboolean
-pango_font_family_is_variable (PangoFontFamily *family)
-{
- g_return_val_if_fail (PANGO_IS_FONT_FAMILY (family), FALSE);
-
- return PANGO_FONT_FAMILY_GET_CLASS (family)->is_variable (family);
-}
diff --git a/pango/pango-font-family.h b/pango/pango-font-family.h
index 8ec9bbf6..3e7709f6 100644
--- a/pango/pango-font-family.h
+++ b/pango/pango-font-family.h
@@ -34,12 +34,6 @@ PANGO_DECLARE_INTERNAL_TYPE (PangoFontFamily, pango_font_family, PANGO, FONT_FAM
PANGO_AVAILABLE_IN_ALL
const char * pango_font_family_get_name (PangoFontFamily *family) G_GNUC_PURE;
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_font_family_is_generic (PangoFontFamily *family) G_GNUC_PURE;
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_font_family_is_monospace (PangoFontFamily *family) G_GNUC_PURE;
-PANGO_AVAILABLE_IN_ALL
-gboolean pango_font_family_is_variable (PangoFontFamily *family) G_GNUC_PURE;
PANGO_AVAILABLE_IN_ALL
PangoFontFace * pango_font_family_get_face (PangoFontFamily *family,
diff --git a/pango/pango-generic-family.c b/pango/pango-generic-family.c
index 99e3dc1a..565a9930 100644
--- a/pango/pango-generic-family.c
+++ b/pango/pango-generic-family.c
@@ -129,26 +129,6 @@ pango_generic_family_get_name (PangoFontFamily *family)
return self->name;
}
-static gboolean
-pango_generic_family_is_generic (PangoFontFamily *family)
-{
- return TRUE;
-}
-
-static gboolean
-pango_generic_family_is_monospace (PangoFontFamily *family)
-{
- PangoGenericFamily *self = PANGO_GENERIC_FAMILY (family);
-
- return strcmp (self->name, "monospace") == 0;
-}
-
-static gboolean
-pango_generic_family_is_variable (PangoFontFamily *family)
-{
- return FALSE;
-}
-
static void
pango_generic_family_class_init (PangoGenericFamilyClass *class)
{
@@ -158,9 +138,6 @@ pango_generic_family_class_init (PangoGenericFamilyClass *class)
object_class->finalize = pango_generic_family_finalize;
family_class->get_name = pango_generic_family_get_name;
- family_class->is_generic = pango_generic_family_is_generic;
- family_class->is_monospace = pango_generic_family_is_monospace;
- family_class->is_variable = pango_generic_family_is_variable;
}
/* }}} */
diff --git a/pango/pango-hbfamily.c b/pango/pango-hbfamily.c
index 66ea27e2..3a8ea7ab 100644
--- a/pango/pango-hbfamily.c
+++ b/pango/pango-hbfamily.c
@@ -164,38 +164,6 @@ pango_hb_family_get_face (PangoFontFamily *family,
return NULL;
}
-static gboolean
-pango_hb_family_is_monospace (PangoFontFamily *family)
-{
- PangoHbFamily *self = PANGO_HB_FAMILY (family);
-
- for (int i = 0; i < self->faces->len; i++)
- {
- PangoFontFace *face = g_ptr_array_index (self->faces, i);
-
- if (pango_font_face_is_monospace (face))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-pango_hb_family_is_variable (PangoFontFamily *family)
-{
- PangoHbFamily *self = PANGO_HB_FAMILY (family);
-
- for (int i = 0; i < self->faces->len; i++)
- {
- PangoFontFace *face = g_ptr_array_index (self->faces, i);
-
- if (pango_font_face_is_variable (face))
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
pango_hb_family_class_init (PangoHbFamilyClass *class)
{
@@ -206,8 +174,6 @@ pango_hb_family_class_init (PangoHbFamilyClass *class)
family_class->get_name = pango_hb_family_get_name;
family_class->get_face = pango_hb_family_get_face;
- family_class->is_monospace = pango_hb_family_is_monospace;
- family_class->is_variable = pango_hb_family_is_variable;
}
/* }}} */
diff --git a/tests/test-font.c b/tests/test-font.c
index f5f3eb84..4981154c 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -436,10 +436,7 @@ static void
test_font_models (void)
{
PangoFontMap *map = pango_cairo_font_map_get_default ();
- gboolean monospace_found = FALSE;
int n_families = 0;
- int n_variable_families = 0;
- int n_monospace_families = 0;
g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (map)) == PANGO_TYPE_FONT_FAMILY);
@@ -451,46 +448,21 @@ test_font_models (void)
g_assert_true (g_list_model_get_item_type (G_LIST_MODEL (obj)) == PANGO_TYPE_FONT_FACE);
- if (g_ascii_strcasecmp (pango_font_family_get_name (PANGO_FONT_FAMILY (obj)), "monospace") == 0)
- {
- g_assert_true (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)));
- }
-
n_families++;
- if (pango_font_family_is_variable (PANGO_FONT_FAMILY (obj)))
- n_variable_families++;
-
- if (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)))
- n_monospace_families++;
-
for (guint j = 0; j < g_list_model_get_n_items (G_LIST_MODEL (obj)); j++)
{
GObject *obj2 = g_list_model_get_item (G_LIST_MODEL (obj), j);
g_assert_true (PANGO_IS_FONT_FACE (obj2));
- if (!pango_font_family_is_generic (PANGO_FONT_FAMILY (obj)))
- g_assert_true (pango_font_face_get_family (PANGO_FONT_FACE (obj2)) == PANGO_FONT_FAMILY (obj));
-
- if (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)))
- {
- if (pango_font_face_is_synthesized (PANGO_FONT_FACE (obj2)))
- {
- monospace_found = TRUE;
- }
- }
-
g_object_unref (obj2);
}
g_object_unref (obj);
}
- g_assert_true (monospace_found);
-
- g_print ("# %d font families, %d monospace, %d variable\n",
- n_families, n_monospace_families, n_variable_families);
+ g_print ("# %d font families\n", n_families);
}
static void
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
index 29254618..b56f8730 100644
--- a/tests/testhbfont.c
+++ b/tests/testhbfont.c
@@ -46,13 +46,9 @@ test_hbfont_monospace (void)
family = pango_font_map_get_family (PANGO_FONT_MAP (map), "Cantarell");
g_assert_nonnull (family);
- g_assert_false (pango_font_family_is_variable (family));
- g_assert_false (pango_font_family_is_monospace (family));
pango_hb_font_map_add_face (map, PANGO_FONT_FACE (pango_hb_face_new_from_file (path, 0, -2, NULL, NULL)));
- g_assert_true (pango_font_family_is_variable (family));
-
g_free (path);
path = g_test_build_filename (G_TEST_DIST, "fonts", "DejaVuSansMono.ttf", NULL);
@@ -62,8 +58,6 @@ test_hbfont_monospace (void)
family = pango_font_map_get_family (PANGO_FONT_MAP (map), "DejaVu Sans Mono");
g_assert_nonnull (family);
- g_assert_false (pango_font_family_is_variable (family));
- g_assert_true (pango_font_family_is_monospace (family));
g_object_unref (map);
}
diff --git a/utils/pango-list.c b/utils/pango-list.c
index ab19bddb..87bb77b8 100644
--- a/utils/pango-list.c
+++ b/utils/pango-list.c
@@ -155,20 +155,7 @@ main (int argc,
g_object_unref (family);
- if (pango_font_family_is_monospace (family))
- {
- if (pango_font_family_is_variable (family))
- kind = "(monospace, variable)";
- else
- kind = "(monospace)";
- }
- else
- {
- if (pango_font_family_is_variable (family))
- kind = "(variable)";
- else
- kind = "";
- }
+ kind = "";
g_print ("%s %s\n", family_name, kind);
@@ -179,8 +166,7 @@ main (int argc,
const char *face_name = pango_font_face_get_face_name (face);
gboolean is_synth = pango_font_face_is_synthesized (face);
const char *synth_str = is_synth ? "*" : "";
- gboolean is_variable = pango_font_face_is_variable (face);
- const char *variable_str = is_variable ? "@" : "";
+ const char *variable_str = "";
width = MAX (width, strlen (synth_str) + strlen (variable_str) + strlen (face_name));
g_object_unref (face);
}
@@ -222,8 +208,7 @@ main (int argc,
pango_font_metrics_unref (metrics);
}
- if (opt_variations &&
- pango_font_family_is_variable (family))
+ if (opt_variations)
{
PangoFont *font;
hb_font_t *hb_font;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]