[pango/pango2: 70/195] Split off PangoFontFace




commit 72aaf0e962a093e0b40ee0326929abd98af99435
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 12 10:45:33 2022 -0500

    Split off PangoFontFace

 pango/fonts.c                   | 140 -----------------------------------
 pango/meson.build               |   2 +
 pango/pango-context.c           |   1 +
 pango/pango-font-description.h  |   1 -
 pango/pango-font-face-private.h |  54 ++++++++++++++
 pango/pango-font-face.c         | 160 ++++++++++++++++++++++++++++++++++++++++
 pango/pango-font-face.h         |  49 ++++++++++++
 pango/pango-font-family.c       |  14 +---
 pango/pango-font-private.h      |  32 --------
 pango/pango-font.h              |  31 --------
 pango/pango-types.h             |   2 +
 pango/pango.h                   |   1 +
 pango/pangofc-fontmap.c         |   2 +
 13 files changed, 272 insertions(+), 217 deletions(-)
---
diff --git a/pango/fonts.c b/pango/fonts.c
index bf7133cf..7e85ecef 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -380,146 +380,6 @@ pango_font_get_hb_font (PangoFont *font)
   return priv->hb_font;
 }
 
-/*
- * PangoFontFace
- */
-
-G_DEFINE_ABSTRACT_TYPE (PangoFontFace, pango_font_face, G_TYPE_OBJECT)
-
-static void
-pango_font_face_class_init (PangoFontFaceClass *class G_GNUC_UNUSED)
-{
-}
-
-static void
-pango_font_face_init (PangoFontFace *face G_GNUC_UNUSED)
-{
-}
-
-/**
- * pango_font_face_describe:
- * @face: a `PangoFontFace`
- *
- * Returns a font description that matches the face.
- *
- * The resulting font description will have the family, style,
- * variant, weight and stretch of the face, but its size field
- * will be unset.
- *
- * Return value: a newly-created `PangoFontDescription` structure
- *   holding the description of the face. Use [method Pango FontDescription free]
- *   to free the result.
- */
-PangoFontDescription *
-pango_font_face_describe (PangoFontFace *face)
-{
-  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
-
-  return PANGO_FONT_FACE_GET_CLASS (face)->describe (face);
-}
-
-/**
- * pango_font_face_is_synthesized:
- * @face: a `PangoFontFace`
- *
- * Returns whether a `PangoFontFace` is synthesized.
- *
- * This will be the case if the underlying font rendering engine
- * creates this face from another face, by shearing, emboldening,
- * lightening or modifying it in some other way.
- *
- * Return value: whether @face is synthesized
- *
- * Since: 1.18
- */
-gboolean
-pango_font_face_is_synthesized (PangoFontFace  *face)
-{
-  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), FALSE);
-
-  if (PANGO_FONT_FACE_GET_CLASS (face)->is_synthesized != NULL)
-    return PANGO_FONT_FACE_GET_CLASS (face)->is_synthesized (face);
-  else
-    return FALSE;
-}
-
-/**
- * pango_font_face_get_face_name:
- * @face: a `PangoFontFace`.
- *
- * Gets a name representing the style of this face.
- *
- * Note that a font family may contain multiple faces
- * with the same name (e.g. a variable and a non-variable
- * face for the same style).
- *
- * Return value: the face name for the face. This string is
- *   owned by the face object and must not be modified or freed.
- */
-const char *
-pango_font_face_get_face_name (PangoFontFace *face)
-{
-  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
-
-  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`
- *
- * Gets the `PangoFontFamily` that @face belongs to.
- *
- * Returns: (transfer none): the `PangoFontFamily`
- *
- * Since: 1.46
- */
-PangoFontFamily *
-pango_font_face_get_family (PangoFontFace *face)
-{
-  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
-
-  return PANGO_FONT_FACE_GET_CLASS (face)->get_family (face);
-}
-
 /**
  * pango_font_has_char:
  * @font: a `PangoFont`
diff --git a/pango/meson.build b/pango/meson.build
index 1bb845b5..377b4a59 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -11,6 +11,7 @@ pango_sources = [
   'pango-coverage.c',
   'pango-emoji.c',
   'pango-font-description.c',
+  'pango-font-face.c',
   'pango-font-family.c',
   'pango-font-metrics.c',
   'pango-fontmap.c',
@@ -44,6 +45,7 @@ pango_headers = [
   'pango-direction.h',
   'pango-font.h',
   'pango-font-description.h',
+  'pango-font-face.h',
   'pango-font-family.h',
   'pango-font-metrics.h',
   'pango-fontmap.h',
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 985b8ff0..52cce104 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -27,6 +27,7 @@
 #include "pango-context-private.h"
 #include "pango-impl-utils.h"
 
+#include "pango-font-private.h"
 #include "pango-font-metrics-private.h"
 #include "pango-item-private.h"
 #include "pango-fontset.h"
diff --git a/pango/pango-font-description.h b/pango/pango-font-description.h
index b7eeb0b4..31c5b4a4 100644
--- a/pango/pango-font-description.h
+++ b/pango/pango-font-description.h
@@ -36,7 +36,6 @@ G_BEGIN_DECLS
  * available on the system and also for specifying the characteristics of
  * a font to load.
  */
-typedef struct _PangoFontDescription PangoFontDescription;
 
 /**
  * PangoStyle:
diff --git a/pango/pango-font-face-private.h b/pango/pango-font-face-private.h
new file mode 100644
index 00000000..fbe271d7
--- /dev/null
+++ b/pango/pango-font-face-private.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2022 Red Hat, Inc.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <pango/pango-font-face.h>
+
+
+struct _PangoFontFace
+{
+  GObject parent_instance;
+};
+
+typedef struct _PangoFontFaceClass PangoFontFaceClass;
+
+struct _PangoFontFaceClass
+{
+  GObjectClass parent_class;
+
+  /*< public >*/
+
+  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);
+
+  /*< private >*/
+
+  /* Padding for future expansion */
+  void (*_pango_reserved3) (void);
+  void (*_pango_reserved4) (void);
+};
+
+#define PANGO_FONT_FACE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, 
PangoFontFaceClass))
+#define PANGO_FONT_FACE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, 
PangoFontFaceClass))
diff --git a/pango/pango-font-face.c b/pango/pango-font-face.c
new file mode 100644
index 00000000..55591919
--- /dev/null
+++ b/pango/pango-font-face.c
@@ -0,0 +1,160 @@
+/* Pango
+ *
+ * Copyright (C) 1999 Red Hat Software
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "pango-font-face-private.h"
+
+
+G_DEFINE_ABSTRACT_TYPE (PangoFontFace, pango_font_face, G_TYPE_OBJECT)
+
+static void
+pango_font_face_class_init (PangoFontFaceClass *class G_GNUC_UNUSED)
+{
+}
+
+static void
+pango_font_face_init (PangoFontFace *face G_GNUC_UNUSED)
+{
+}
+
+/**
+ * pango_font_face_describe:
+ * @face: a `PangoFontFace`
+ *
+ * Returns a font description that matches the face.
+ *
+ * The resulting font description will have the family, style,
+ * variant, weight and stretch of the face, but its size field
+ * will be unset.
+ *
+ * Return value: a newly-created `PangoFontDescription` structure
+ *   holding the description of the face. Use [method Pango FontDescription free]
+ *   to free the result.
+ */
+PangoFontDescription *
+pango_font_face_describe (PangoFontFace *face)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
+
+  return PANGO_FONT_FACE_GET_CLASS (face)->describe (face);
+}
+
+/**
+ * pango_font_face_is_synthesized:
+ * @face: a `PangoFontFace`
+ *
+ * Returns whether a `PangoFontFace` is synthesized.
+ *
+ * This will be the case if the underlying font rendering engine
+ * creates this face from another face, by shearing, emboldening,
+ * lightening or modifying it in some other way.
+ *
+ * Return value: whether @face is synthesized
+ *
+ * Since: 1.18
+ */
+gboolean
+pango_font_face_is_synthesized (PangoFontFace  *face)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), FALSE);
+
+  if (PANGO_FONT_FACE_GET_CLASS (face)->is_synthesized != NULL)
+    return PANGO_FONT_FACE_GET_CLASS (face)->is_synthesized (face);
+  else
+    return FALSE;
+}
+
+/**
+ * pango_font_face_get_face_name:
+ * @face: a `PangoFontFace`.
+ *
+ * Gets a name representing the style of this face.
+ *
+ * Note that a font family may contain multiple faces
+ * with the same name (e.g. a variable and a non-variable
+ * face for the same style).
+ *
+ * Return value: the face name for the face. This string is
+ *   owned by the face object and must not be modified or freed.
+ */
+const char *
+pango_font_face_get_face_name (PangoFontFace *face)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
+
+  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`
+ *
+ * Gets the `PangoFontFamily` that @face belongs to.
+ *
+ * Returns: (transfer none): the `PangoFontFamily`
+ *
+ * Since: 1.46
+ */
+PangoFontFamily *
+pango_font_face_get_family (PangoFontFace *face)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
+
+  return PANGO_FONT_FACE_GET_CLASS (face)->get_family (face);
+}
diff --git a/pango/pango-font-face.h b/pango/pango-font-face.h
new file mode 100644
index 00000000..335ab7f8
--- /dev/null
+++ b/pango/pango-font-face.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2000 Red Hat Software
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <pango/pango-types.h>
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+
+#define PANGO_TYPE_FONT_FACE              (pango_font_face_get_type ())
+
+PANGO_AVAILABLE_IN_ALL
+PANGO_DECLARE_INTERNAL_TYPE (PangoFontFace, pango_font_face, PANGO, FONT_FACE, GObject)
+
+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;
+
+PANGO_AVAILABLE_IN_1_46
+PangoFontFamily *       pango_font_face_get_family     (PangoFontFace  *face);
+
+
+G_END_DECLS
diff --git a/pango/pango-font-family.c b/pango/pango-font-family.c
index 2c983eb2..e77efa2d 100644
--- a/pango/pango-font-family.c
+++ b/pango/pango-font-family.c
@@ -21,21 +21,9 @@
 #include "config.h"
 
 #include "pango-font-family-private.h"
+#include "pango-font-face.h"
 #include "pango-font.h"
 
-#if 0
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include <gio/gio.h>
-
-#include "pango-types.h"
-#include "pango-font-private.h"
-#include "pango-fontmap.h"
-#include "pango-impl-utils.h"
-#endif
-
 
 static GType
 pango_font_family_get_item_type (GListModel *list)
diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h
index 1e49617c..6fcbb7aa 100644
--- a/pango/pango-font-private.h
+++ b/pango/pango-font-private.h
@@ -31,38 +31,6 @@
 
 G_BEGIN_DECLS
 
-struct _PangoFontFace
-{
-  GObject parent_instance;
-};
-
-typedef struct _PangoFontFaceClass PangoFontFaceClass;
-
-struct _PangoFontFaceClass
-{
-  GObjectClass parent_class;
-
-  /*< public >*/
-
-  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);
-
-  /*< private >*/
-
-  /* Padding for future expansion */
-  void (*_pango_reserved3) (void);
-  void (*_pango_reserved4) (void);
-};
-
-#define PANGO_FONT_FACE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, 
PangoFontFaceClass))
-#define PANGO_IS_FONT_FACE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE))
-#define PANGO_FONT_FACE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, 
PangoFontFaceClass))
-
 struct _PangoFont
 {
   GObject parent_instance;
diff --git a/pango/pango-font.h b/pango/pango-font.h
index d931715f..a0fa50ce 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -33,36 +33,6 @@
 
 G_BEGIN_DECLS
 
-/*
- * PangoFontFace
- */
-
-#define PANGO_TYPE_FONT_FACE              (pango_font_face_get_type ())
-#define PANGO_FONT_FACE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, 
PangoFontFace))
-#define PANGO_IS_FONT_FACE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE))
-
-
-PANGO_AVAILABLE_IN_ALL
-GType      pango_font_face_get_type       (void) G_GNUC_CONST;
-
-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;
-
-PANGO_AVAILABLE_IN_1_46
-PangoFontFamily *     pango_font_face_get_family     (PangoFontFace  *face);
-
-
-/*
- * PangoFont
- */
 
 #define PANGO_TYPE_FONT              (pango_font_get_type ())
 #define PANGO_FONT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont))
@@ -167,7 +137,6 @@ PangoFont *           pango_font_deserialize       (PangoContext     *context,
 #endif
 #endif
 
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoFontFace, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoFont, g_object_unref)
 
 G_END_DECLS
diff --git a/pango/pango-types.h b/pango/pango-types.h
index 2d2003a5..5d1b30df 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -31,6 +31,8 @@ G_BEGIN_DECLS
 
 typedef struct _PangoLogAttr PangoLogAttr;
 
+typedef struct _PangoFontDescription PangoFontDescription;
+
 typedef struct _PangoFont PangoFont;
 typedef struct _PangoFontFace PangoFontFace;
 typedef struct _PangoFontFamily PangoFontFamily;
diff --git a/pango/pango.h b/pango/pango.h
index 7004610a..b5200b8f 100644
--- a/pango/pango.h
+++ b/pango/pango.h
@@ -32,6 +32,7 @@
 #include <pango/pango-features.h>
 #include <pango/pango-font.h>
 #include <pango/pango-font-description.h>
+#include <pango/pango-font-face.h>
 #include <pango/pango-font-family.h>
 #include <pango/pango-font-metrics.h>
 #include <pango/pango-fontmap.h>
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 866798a5..ba1e81f5 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -38,6 +38,8 @@
 #include <gio/gio.h>
 
 #include "pango-context.h"
+#include "pango-font-family-private.h"
+#include "pango-font-face-private.h"
 #include "pango-font-private.h"
 #include "pango-font-family-private.h"
 #include "pangofc-fontmap-private.h"


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