diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-02-12 10:45:33 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-02-17 14:01:45 -0600 |
commit | a819b4ac9ab3a7af4ac0e8595145ca57dc62111d (patch) | |
tree | b72f1251784ccdc03081928d89396fc6c62fe15d | |
parent | 435f55d0c7fd2d455647a300081bf5106bcc36ac (diff) | |
download | pango-a819b4ac9ab3a7af4ac0e8595145ca57dc62111d.tar.gz |
Split off PangoFontFace
-rw-r--r-- | pango/fonts.c | 140 | ||||
-rw-r--r-- | pango/meson.build | 2 | ||||
-rw-r--r-- | pango/pango-context.c | 1 | ||||
-rw-r--r-- | pango/pango-font-description.h | 1 | ||||
-rw-r--r-- | pango/pango-font-face-private.h | 59 | ||||
-rw-r--r-- | pango/pango-font-face.c | 174 | ||||
-rw-r--r-- | pango/pango-font-face.h | 55 | ||||
-rw-r--r-- | pango/pango-font-family.c | 14 | ||||
-rw-r--r-- | pango/pango-font-private.h | 32 | ||||
-rw-r--r-- | pango/pango-font.h | 31 | ||||
-rw-r--r-- | pango/pango-types.h | 2 | ||||
-rw-r--r-- | pango/pango.h | 1 | ||||
-rw-r--r-- | pango/pangofc-font.c | 1 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 2 |
14 files changed, 298 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 e560e27b..eb9ea62e 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 27bb2e00..52cce104 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -28,6 +28,7 @@ #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" #include "pango-fontmap-private.h" diff --git a/pango/pango-font-description.h b/pango/pango-font-description.h index 44aedcc4..5bc17ce7 100644 --- a/pango/pango-font-description.h +++ b/pango/pango-font-description.h @@ -39,7 +39,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..87fc8002 --- /dev/null +++ b/pango/pango-font-face-private.h @@ -0,0 +1,59 @@ +/* Pango + * + * Copyright (C) 2000 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. + */ + +#pragma once + +#include <pango/pango-font-face.h> + +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)) + +G_END_DECLS diff --git a/pango/pango-font-face.c b/pango/pango-font-face.c new file mode 100644 index 00000000..92493186 --- /dev/null +++ b/pango/pango-font-face.c @@ -0,0 +1,174 @@ +/* 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" + +#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-font-metrics-private.h" +#include "pango-fontmap.h" +#include "pango-impl-utils.h" +#endif + + +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..81874440 --- /dev/null +++ b/pango/pango-font-face.h @@ -0,0 +1,55 @@ +/* Pango + * + * Copyright (C) 2000 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. + */ + +#pragma once + +#include <pango/pango-types.h> + +#include <glib-object.h> + +G_BEGIN_DECLS + + +#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); + + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoFontFace, g_object_unref) + +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 810929fd..e12d8814 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-font.c b/pango/pangofc-font.c index 9f54cd7a..9dc5e98d 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -22,6 +22,7 @@ #include "config.h" #include "pango-font-private.h" +#include "pango-font-metrics-private.h" #include "pangofc-font-private.h" #include "pangofc-fontmap.h" #include "pangofc-private.h" diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 19436aae..2ef5f31f 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 "pangofc-fontmap-private.h" #include "pangofc-private.h" |