[pango/pango2-cleanups: 59/70] Drop size listing api




commit ce2581fb39ebf5c1897681595dec12676fe4a36f
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 12 14:26:23 2022 -0500

    Drop size listing api

 pango/pango-font-face-private.h |  3 --
 pango/pango-font-face.c         | 38 ----------------
 pango/pango-font-face.h         |  4 --
 pango/pangofc-fontmap.c         | 99 -----------------------------------------
 tests/test-font.c               |  6 ---
 5 files changed, 150 deletions(-)
---
diff --git a/pango/pango-font-face-private.h b/pango/pango-font-face-private.h
index 87fc8002..299632e9 100644
--- a/pango/pango-font-face-private.h
+++ b/pango/pango-font-face-private.h
@@ -39,9 +39,6 @@ struct _PangoFontFaceClass
 
   const char           * (*get_face_name)  (PangoFontFace *face);
   PangoFontDescription * (*describe)       (PangoFontFace *face);
-  void                   (*list_sizes)     (PangoFontFace  *face,
-                                            int           **sizes,
-                                            int            *n_sizes);
   gboolean               (*is_synthesized) (PangoFontFace *face);
   PangoFontFamily *      (*get_family)     (PangoFontFace *face);
 
diff --git a/pango/pango-font-face.c b/pango/pango-font-face.c
index 92493186..585db6c1 100644
--- a/pango/pango-font-face.c
+++ b/pango/pango-font-face.c
@@ -117,44 +117,6 @@ pango_font_face_get_face_name (PangoFontFace *face)
   return PANGO_FONT_FACE_GET_CLASS (face)->get_face_name (face);
 }
 
-/**
- * pango_font_face_list_sizes:
- * @face: a `PangoFontFace`.
- * @sizes: (out) (array length=n_sizes) (nullable) (optional):
- *   location to store a pointer to an array of int. This array
- *   should be freed with g_free().
- * @n_sizes: location to store the number of elements in @sizes
- *
- * List the available sizes for a font.
- *
- * This is only applicable to bitmap fonts. For scalable fonts, stores
- * %NULL at the location pointed to by @sizes and 0 at the location pointed
- * to by @n_sizes. The sizes returned are in Pango units and are sorted
- * in ascending order.
- *
- * Since: 1.4
- */
-void
-pango_font_face_list_sizes (PangoFontFace  *face,
-                            int           **sizes,
-                            int            *n_sizes)
-{
-  g_return_if_fail (PANGO_IS_FONT_FACE (face));
-  g_return_if_fail (sizes == NULL || n_sizes != NULL);
-
-  if (n_sizes == NULL)
-    return;
-
-  if (PANGO_FONT_FACE_GET_CLASS (face)->list_sizes != NULL)
-    PANGO_FONT_FACE_GET_CLASS (face)->list_sizes (face, sizes, n_sizes);
-  else
-    {
-      if (sizes != NULL)
-        *sizes = NULL;
-      *n_sizes = 0;
-    }
-}
-
 /**
  * pango_font_face_get_family:
  * @face: a `PangoFontFace`
diff --git a/pango/pango-font-face.h b/pango/pango-font-face.h
index 81874440..4abf4a2e 100644
--- a/pango/pango-font-face.h
+++ b/pango/pango-font-face.h
@@ -39,10 +39,6 @@ PANGO_AVAILABLE_IN_ALL
 PangoFontDescription *  pango_font_face_describe       (PangoFontFace  *face);
 PANGO_AVAILABLE_IN_ALL
 const char *            pango_font_face_get_face_name  (PangoFontFace  *face) G_GNUC_PURE;
-PANGO_AVAILABLE_IN_1_4
-void                    pango_font_face_list_sizes     (PangoFontFace  *face,
-                                                        int           **sizes,
-                                                        int            *n_sizes);
 PANGO_AVAILABLE_IN_1_18
 gboolean                pango_font_face_is_synthesized (PangoFontFace  *face) G_GNUC_PURE;
 
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 62140bbe..ec48f41a 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -2914,104 +2914,6 @@ pango_fc_face_get_face_name (PangoFontFace *face)
   return fcface->style;
 }
 
-static int
-compare_ints (gconstpointer ap,
-             gconstpointer bp)
-{
-  int a = *(int *)ap;
-  int b = *(int *)bp;
-
-  if (a == b)
-    return 0;
-  else if (a > b)
-    return 1;
-  else
-    return -1;
-}
-
-static void
-pango_fc_face_list_sizes (PangoFontFace  *face,
-                         int           **sizes,
-                         int            *n_sizes)
-{
-  PangoFcFace *fcface = PANGO_FC_FACE (face);
-  FcPattern *pattern;
-  FcFontSet *fontset;
-  FcObjectSet *objectset;
-  FcFontSet *fonts;
-
-  if (sizes)
-    *sizes = NULL;
-  *n_sizes = 0;
-  if (G_UNLIKELY (!fcface->family || !fcface->family->fontmap))
-    return;
-
-  pattern = FcPatternCreate ();
-  FcPatternAddString (pattern, FC_FAMILY, (FcChar8*)(void*)fcface->family->family_name);
-  FcPatternAddString (pattern, FC_STYLE, (FcChar8*)(void*)fcface->style);
-
-  objectset = FcObjectSetCreate ();
-  FcObjectSetAdd (objectset, FC_PIXEL_SIZE);
-
-  fonts = pango_fc_font_map_get_config_fonts (fcface->family->fontmap);
-  fontset = FcFontSetList (fcface->family->fontmap->priv->config, &fonts, 1, pattern, objectset);
-
-  if (fontset)
-    {
-      GArray *size_array;
-      double size, dpi = -1.0;
-      int i, size_i, j;
-
-      size_array = g_array_new (FALSE, FALSE, sizeof (int));
-
-      for (i = 0; i < fontset->nfont; i++)
-       {
-         for (j = 0;
-              FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, j, &size) == FcResultMatch;
-              j++)
-           {
-             if (dpi < 0)
-               dpi = pango_fc_font_map_get_resolution (fcface->family->fontmap, NULL);
-
-             size_i = (int) (PANGO_SCALE * size * 72.0 / dpi);
-             g_array_append_val (size_array, size_i);
-           }
-       }
-
-      g_array_sort (size_array, compare_ints);
-
-      if (size_array->len == 0)
-       {
-         *n_sizes = 0;
-         if (sizes)
-           *sizes = NULL;
-         g_array_free (size_array, TRUE);
-       }
-      else
-       {
-         *n_sizes = size_array->len;
-         if (sizes)
-           {
-             *sizes = (int *) size_array->data;
-             g_array_free (size_array, FALSE);
-           }
-         else
-           g_array_free (size_array, TRUE);
-       }
-
-      FcFontSetDestroy (fontset);
-    }
-  else
-    {
-      *n_sizes = 0;
-      if (sizes)
-       *sizes = NULL;
-    }
-
-  FcPatternDestroy (pattern);
-  FcObjectSetDestroy (objectset);
-}
-
 static gboolean
 pango_fc_face_is_synthesized (PangoFontFace *face)
 {
@@ -3053,7 +2955,6 @@ pango_fc_face_class_init (PangoFcFaceClass *class)
 
   class->describe = pango_fc_face_describe;
   class->get_face_name = pango_fc_face_get_face_name;
-  class->list_sizes = pango_fc_face_list_sizes;
   class->is_synthesized = pango_fc_face_is_synthesized;
   class->get_family = pango_fc_face_get_family;
 }
diff --git a/tests/test-font.c b/tests/test-font.c
index 3a1e2d98..373467b4 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -450,17 +450,11 @@ test_font_models (void)
       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);
-          int *sizes;
-          int n_sizes;
 
           g_assert_true (PANGO_IS_FONT_FACE (obj2));
 
           g_assert_true (pango_font_face_get_family (PANGO_FONT_FACE (obj2)) == (PangoFontFamily *)obj);
 
-          pango_font_face_list_sizes (PANGO_FONT_FACE (obj2), &sizes, &n_sizes);
-          g_assert_true ((sizes == NULL) == (n_sizes == 0));
-          g_free (sizes);
-
           if (pango_font_family_is_monospace (PANGO_FONT_FAMILY (obj)))
             {
               if (pango_font_face_is_synthesized (PANGO_FONT_FACE (obj2)))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]