[pango/pango2: 109/115] Thin out pangocairo code
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 109/115] Thin out pangocairo code
- Date: Thu, 9 Jun 2022 11:24:45 +0000 (UTC)
commit b79ae146a98d6b89ed980091f144bee3b7e4b348
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 8 21:21:58 2022 -0400
Thin out pangocairo code
We don't use the PangoCairoFontmap or PangoCairoFont
interfaces anymore. A bunch of code can go.
pango/pangocairo-context.c | 2 +-
pango/pangocairo-font.c | 532 ++-------------------------------------------
pango/pangocairo-private.h | 38 +---
pango/pangocairo.h | 34 ---
4 files changed, 19 insertions(+), 587 deletions(-)
---
diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c
index 30541c13..21dce46d 100644
--- a/pango/pangocairo-context.c
+++ b/pango/pangocairo-context.c
@@ -1,5 +1,5 @@
/* Pango
- * pangocairo-fontmap.c: Cairo font handling
+ * pangocairo-context.c: Cairo context handling
*
* Copyright (C) 2000-2005 Red Hat Software
*
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 89cf3368..c9cb6c1c 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -48,13 +48,16 @@
G_STRUCT_MEMBER_P (font, \
PANGO_CAIRO_FONT_GET_IFACE(PANGO_CAIRO_FONT(font))->cf_priv_offset)))
-typedef PangoCairoFontIface PangoCairoFontInterface;
-G_DEFINE_INTERFACE (PangoCairoFont, pango_cairo_font, PANGO_TYPE_FONT)
+static PangoCairoFontPrivate * _pango_font_get_cairo_font_private (PangoFont *font);
+static cairo_scaled_font_t * _pango_font_get_scaled_font (PangoFont *font);
+static void _pango_cairo_font_private_initialize (PangoCairoFontPrivate *cf_priv,
+ PangoFont *font,
+ PangoGravity gravity,
+ const cairo_font_options_t *font_options,
+ const PangoMatrix *pango_ctm,
+ const cairo_matrix_t *font_matrix);
+static void _pango_cairo_font_private_finalize (PangoCairoFontPrivate *cf_priv);
-static void
-pango_cairo_font_default_init (PangoCairoFontIface *iface)
-{
-}
static PangoCairoFontPrivateScaledFontData *
@@ -198,7 +201,7 @@ create_font_face_for_hb_font (PangoHbFont *font)
return cairo_face;
}
-cairo_scaled_font_t *
+static cairo_scaled_font_t *
_pango_cairo_font_private_get_scaled_font (PangoCairoFontPrivate *cf_priv)
{
cairo_font_face_t *font_face;
@@ -214,9 +217,7 @@ _pango_cairo_font_private_get_scaled_font (PangoCairoFontPrivate *cf_priv)
return NULL;
}
- if (PANGO_IS_CAIRO_FONT (cf_priv->cfont))
- font_face = (* PANGO_CAIRO_FONT_GET_IFACE (cf_priv->cfont)->create_font_face) (cf_priv->cfont);
- else if (PANGO_IS_HB_FONT (cf_priv->cfont))
+ if (PANGO_IS_HB_FONT (cf_priv->cfont))
font_face = create_font_face_for_hb_font (PANGO_HB_FONT (cf_priv->cfont));
else if (PANGO_IS_USER_FONT (cf_priv->cfont))
font_face = create_font_face_for_user_font (PANGO_USER_FONT (cf_priv->cfont));
@@ -236,7 +237,7 @@ done:
if (G_UNLIKELY (cf_priv->scaled_font == NULL || cairo_scaled_font_status (cf_priv->scaled_font) !=
CAIRO_STATUS_SUCCESS))
{
cairo_scaled_font_t *scaled_font = cf_priv->scaled_font;
- PangoFont *font = PANGO_FONT (cf_priv->cfont);
+ PangoFont *font = cf_priv->cfont;
static GQuark warned_quark = 0; /* MT-safe */
if (!warned_quark)
warned_quark = g_quark_from_static_string ("pangocairo-scaledfont-warned");
@@ -279,30 +280,6 @@ done:
return cf_priv->scaled_font;
}
-/**
- * pango_cairo_font_get_scaled_font:
- * @font: (nullable): a `PangoFont` from a `PangoCairoFontMap`
- *
- * Gets the `cairo_scaled_font_t` used by @font.
- * The scaled font can be referenced and kept using
- * cairo_scaled_font_reference().
- *
- * Return value: (transfer none) (nullable): the `cairo_scaled_font_t`
- * used by @font
- */
-cairo_scaled_font_t *
-pango_cairo_font_get_scaled_font (PangoCairoFont *cfont)
-{
- PangoCairoFontPrivate *cf_priv;
-
- if (G_UNLIKELY (!cfont))
- return NULL;
-
- cf_priv = PANGO_CAIRO_FONT_PRIVATE (cfont);
-
- return _pango_cairo_font_private_get_scaled_font (cf_priv);
-}
-
cairo_scaled_font_t *
_pango_font_get_scaled_font (PangoFont *font)
{
@@ -342,193 +319,6 @@ _pango_cairo_font_install (PangoFont *font,
return TRUE;
}
-static int
-max_glyph_width (PangoLayout *layout)
-{
- PangoLines *lines;
- PangoLine **l;
- int max_width = 0;
-
- lines = pango_layout_get_lines (layout);
- l = pango_lines_get_lines (lines);
-
- for (int i = 0; i < pango_lines_get_line_count (lines); i++)
- {
- PangoRun **runs = pango_line_get_runs (l[i]);
- int n_runs = pango_line_get_run_count (l[i]);
-
- for (int j = 0; j < n_runs; j++)
- {
- PangoGlyphString *glyphs = pango_run_get_glyphs (runs[j]);
-
- for (int i = 0; i < glyphs->num_glyphs; i++)
- {
- if (glyphs->glyphs[i].geometry.width > max_width)
- max_width = glyphs->glyphs[i].geometry.width;
- }
- }
- }
-
- return max_width;
-}
-
-typedef struct _PangoCairoFontMetricsInfo
-{
- const char *sample_str;
- PangoFontMetrics *metrics;
-} PangoCairoFontMetricsInfo;
-
-PangoFontMetrics *
-_pango_cairo_font_get_metrics (PangoFont *font,
- PangoLanguage *language)
-{
- PangoCairoFont *cfont = (PangoCairoFont *) font;
- PangoCairoFontPrivate *cf_priv = PANGO_CAIRO_FONT_PRIVATE (font);
- PangoCairoFontMetricsInfo *info = NULL; /* Quiet gcc */
- GSList *tmp_list;
- static int in_get_metrics;
-
- const char *sample_str = pango_language_get_sample_string (language);
-
- tmp_list = cf_priv->metrics_by_lang;
- while (tmp_list)
- {
- info = tmp_list->data;
-
- if (info->sample_str == sample_str) /* We _don't_ need strcmp */
- break;
-
- tmp_list = tmp_list->next;
- }
-
- if (!tmp_list)
- {
- PangoFontMap *fontmap;
- PangoContext *context;
- cairo_font_options_t *font_options;
- PangoLayout *layout;
- PangoRectangle extents;
- PangoFontDescription *desc;
- cairo_scaled_font_t *scaled_font;
- cairo_matrix_t cairo_matrix;
- PangoMatrix pango_matrix;
- PangoMatrix identity = PANGO_MATRIX_INIT;
- glong sample_str_width;
-
- int height, shift;
-
- /* XXX this is racy. need a ref'ing getter... */
- fontmap = pango_font_get_font_map (font);
- if (!fontmap)
- return pango_font_metrics_new ();
- fontmap = g_object_ref (fontmap);
-
- info = g_slice_new0 (PangoCairoFontMetricsInfo);
-
- cf_priv->metrics_by_lang = g_slist_prepend (cf_priv->metrics_by_lang, info);
-
- info->sample_str = sample_str;
-
- scaled_font = _pango_cairo_font_private_get_scaled_font (cf_priv);
-
- context = pango_font_map_create_context (fontmap);
- pango_context_set_language (context, language);
-
- font_options = cairo_font_options_create ();
- cairo_scaled_font_get_font_options (scaled_font, font_options);
- pango_cairo_context_set_font_options (context, font_options);
- cairo_font_options_destroy (font_options);
-
- info->metrics = (* PANGO_CAIRO_FONT_GET_IFACE (font)->create_base_metrics_for_context) (cfont,
context);
-
- /* We now need to adjust the base metrics for ctm */
- cairo_scaled_font_get_ctm (scaled_font, &cairo_matrix);
- pango_matrix.xx = cairo_matrix.xx;
- pango_matrix.yx = cairo_matrix.yx;
- pango_matrix.xy = cairo_matrix.xy;
- pango_matrix.yy = cairo_matrix.yy;
- pango_matrix.x0 = 0;
- pango_matrix.y0 = 0;
- if (G_UNLIKELY (0 != memcmp (&identity, &pango_matrix, 4 * sizeof (double))))
- {
- double xscale = pango_matrix_get_font_scale_factor (&pango_matrix);
- if (xscale) xscale = 1 / xscale;
-
- info->metrics->ascent *= xscale;
- info->metrics->descent *= xscale;
- info->metrics->height *= xscale;
- info->metrics->underline_position *= xscale;
- info->metrics->underline_thickness *= xscale;
- info->metrics->strikethrough_position *= xscale;
- info->metrics->strikethrough_thickness *= xscale;
- }
-
- /* Set the matrix on the context so we don't have to adjust the derived
- * metrics. */
- pango_context_set_matrix (context, &pango_matrix);
-
- /* Ugly. We need to prevent recursion when we call into
- * PangoLayout to determine approximate char width.
- */
- if (!in_get_metrics)
- {
- in_get_metrics = 1;
-
- /* Update approximate_*_width now */
- layout = pango_layout_new (context);
- desc = pango_font_describe_with_absolute_size (font);
- pango_layout_set_font_description (layout, desc);
- pango_font_description_free (desc);
-
- pango_layout_set_text (layout, sample_str, -1);
- pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &extents);
-
- sample_str_width = pango_utf8_strwidth (sample_str);
- g_assert (sample_str_width > 0);
- info->metrics->approximate_char_width = extents.width / sample_str_width;
-
- pango_layout_set_text (layout, "0123456789", -1);
- info->metrics->approximate_digit_width = max_glyph_width (layout);
-
- g_object_unref (layout);
- in_get_metrics = 0;
- }
-
- /* We may actually reuse ascent/descent we got from cairo here. that's
- * in cf_priv->font_extents.
- */
- height = info->metrics->ascent + info->metrics->descent;
- switch (cf_priv->gravity)
- {
- default:
- case PANGO_GRAVITY_AUTO:
- case PANGO_GRAVITY_SOUTH:
- break;
- case PANGO_GRAVITY_NORTH:
- info->metrics->ascent = info->metrics->descent;
- break;
- case PANGO_GRAVITY_EAST:
- case PANGO_GRAVITY_WEST:
- {
- int ascent = height / 2;
- if (cf_priv->is_hinted)
- ascent = PANGO_UNITS_ROUND (ascent);
- info->metrics->ascent = ascent;
- }
- }
- shift = (height - info->metrics->ascent) - info->metrics->descent;
- info->metrics->descent += shift;
- info->metrics->underline_position -= shift;
- info->metrics->strikethrough_position -= shift;
- info->metrics->ascent = height - info->metrics->descent;
-
- g_object_unref (context);
- g_object_unref (fontmap);
- }
-
- return pango_font_metrics_ref (info->metrics);
-}
-
static PangoCairoFontHexBoxInfo *
_pango_cairo_font_private_get_hex_box_info (PangoCairoFontPrivate *cf_priv)
{
@@ -568,7 +358,7 @@ _pango_cairo_font_private_get_hex_box_info (PangoCairoFontPrivate *cf_priv)
is_hinted = cf_priv->is_hinted;
font_options = cairo_font_options_create ();
- desc = pango_font_describe_with_absolute_size ((PangoFont *)cf_priv->cfont);
+ desc = pango_font_describe_with_absolute_size (cf_priv->cfont);
/*gravity = pango_font_description_get_gravity (desc);*/
cairo_scaled_font_get_ctm (scaled_font, &cairo_ctm);
@@ -622,7 +412,7 @@ _pango_cairo_font_private_get_hex_box_info (PangoCairoFontPrivate *cf_priv)
PangoContext *context;
/* XXX this is racy. need a ref'ing getter... */
- fontmap = pango_font_get_font_map ((PangoFont *)cf_priv->cfont);
+ fontmap = pango_font_get_font_map (cf_priv->cfont);
if (!fontmap)
return NULL;
fontmap = g_object_ref (fontmap);
@@ -754,14 +544,11 @@ free_cairo_font_private (gpointer data)
g_free (data);
}
-PangoCairoFontPrivate *
+static PangoCairoFontPrivate *
_pango_font_get_cairo_font_private (PangoFont *font)
{
PangoCairoFontPrivate *cf_priv;
- if (PANGO_IS_CAIRO_FONT (font))
- return PANGO_CAIRO_FONT_PRIVATE (font);
-
cf_priv = g_object_get_data (G_OBJECT (font), "pango-hb-font-cairo_private");
if (!cf_priv)
{
@@ -801,7 +588,7 @@ _pango_font_get_cairo_font_private (PangoFont *font)
cf_priv = g_new0 (PangoCairoFontPrivate, 1);
_pango_cairo_font_private_initialize (cf_priv,
- (PangoCairoFont *)font,
+ font,
cf->gravity,
font_options,
&cf->matrix,
@@ -826,7 +613,7 @@ _pango_cairo_font_get_hex_box_info (PangoFont *font)
void
_pango_cairo_font_private_initialize (PangoCairoFontPrivate *cf_priv,
- PangoCairoFont *cfont,
+ PangoFont *cfont,
PangoGravity gravity,
const cairo_font_options_t *font_options,
const PangoMatrix *pango_ctm,
@@ -864,15 +651,6 @@ _pango_cairo_font_private_initialize (PangoCairoFontPrivate *cf_priv,
cf_priv->scaled_font = NULL;
cf_priv->hbi = NULL;
- cf_priv->glyph_extents_cache = NULL;
- cf_priv->metrics_by_lang = NULL;
-}
-
-static void
-free_metrics_info (PangoCairoFontMetricsInfo *info)
-{
- pango_font_metrics_unref (info->metrics);
- g_slice_free (PangoCairoFontMetricsInfo, info);
}
void
@@ -886,280 +664,4 @@ _pango_cairo_font_private_finalize (PangoCairoFontPrivate *cf_priv)
_pango_cairo_font_hex_box_info_destroy (cf_priv->hbi);
cf_priv->hbi = NULL;
-
- if (cf_priv->glyph_extents_cache)
- g_free (cf_priv->glyph_extents_cache);
- cf_priv->glyph_extents_cache = NULL;
-
- g_slist_foreach (cf_priv->metrics_by_lang, (GFunc)free_metrics_info, NULL);
- g_slist_free (cf_priv->metrics_by_lang);
- cf_priv->metrics_by_lang = NULL;
-}
-
-gboolean
-_pango_cairo_font_private_is_metrics_hinted (PangoCairoFontPrivate *cf_priv)
-{
- return cf_priv->is_hinted;
-}
-
-
-static void
-get_space_extents (PangoCairoFontPrivate *cf_priv,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
-{
- /* See https://docs.microsoft.com/en-us/typography/develop/character-design-standards/whitespace */
-
- int width = pango_font_get_absolute_size (PANGO_FONT (cf_priv->cfont)) / 4;
-
- if (ink_rect)
- {
- ink_rect->x = ink_rect->y = ink_rect->height = 0;
- ink_rect->width = width;
- }
- if (logical_rect)
- {
- *logical_rect = cf_priv->font_extents;
- logical_rect->width = width;
- }
-}
-
-static void
-_pango_cairo_font_private_get_glyph_extents_missing (PangoCairoFontPrivate *cf_priv,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
-{
- PangoCairoFontHexBoxInfo *hbi;
- gunichar ch;
- gint rows, cols;
-
- ch = glyph & ~PANGO_GLYPH_UNKNOWN_FLAG;
-
- if (ch == 0x20 || ch == 0x2423)
- {
- get_space_extents (cf_priv, ink_rect, logical_rect);
- return;
- }
-
- hbi = _pango_cairo_font_private_get_hex_box_info (cf_priv);
- if (!hbi)
- {
- pango_font_get_glyph_extents (NULL, glyph, ink_rect, logical_rect);
- return;
- }
-
- if (G_UNLIKELY (glyph == PANGO_GLYPH_INVALID_INPUT || ch > 0x10FFFF))
- {
- rows = hbi->rows;
- cols = 1;
- }
- else if (pango_get_ignorable_size (ch, &rows, &cols))
- {
- /* We special-case ignorables when rendering hex boxes */
- }
- else
- {
- rows = hbi->rows;
- cols = ((glyph & ~PANGO_GLYPH_UNKNOWN_FLAG) > 0xffff ? 6 : 4) / rows;
- }
-
- if (ink_rect)
- {
- ink_rect->x = PANGO_SCALE * hbi->pad_x;
- ink_rect->y = PANGO_SCALE * (hbi->box_descent - hbi->box_height);
- ink_rect->width = PANGO_SCALE * (3 * hbi->pad_x + cols * (hbi->digit_width + hbi->pad_x));
- ink_rect->height = PANGO_SCALE * hbi->box_height;
- }
-
- if (logical_rect)
- {
- logical_rect->x = 0;
- logical_rect->y = PANGO_SCALE * (hbi->box_descent - (hbi->box_height + hbi->pad_y));
- logical_rect->width = PANGO_SCALE * (5 * hbi->pad_x + cols * (hbi->digit_width + hbi->pad_x));
- logical_rect->height = PANGO_SCALE * (hbi->box_height + 2 * hbi->pad_y);
- }
-}
-
-#define GLYPH_CACHE_NUM_ENTRIES 256 /* should be power of two */
-#define GLYPH_CACHE_MASK (GLYPH_CACHE_NUM_ENTRIES - 1)
-/* An entry in the fixed-size cache for the glyph->extents mapping.
- * The cache is indexed by the lower N bits of the glyph (see
- * GLYPH_CACHE_NUM_ENTRIES). For scripts with few glyphs,
- * this should provide pretty much instant lookups.
- */
-struct _PangoCairoFontGlyphExtentsCacheEntry
-{
- PangoGlyph glyph;
- int width;
- PangoRectangle ink_rect;
-};
-
-static gboolean
-_pango_cairo_font_private_glyph_extents_cache_init (PangoCairoFontPrivate *cf_priv)
-{
- hb_font_extents_t extents;
-
- hb_font_get_h_extents (pango_font_get_hb_font (PANGO_FONT (cf_priv->cfont)),
- &extents);
-
- cf_priv->font_extents.x = 0;
- cf_priv->font_extents.width = 0;
- cf_priv->font_extents.height = extents.ascender - extents.descender;
-
- switch (cf_priv->gravity)
- {
- default:
- case PANGO_GRAVITY_AUTO:
- case PANGO_GRAVITY_SOUTH:
- cf_priv->font_extents.y = - extents.ascender;
- break;
- case PANGO_GRAVITY_NORTH:
- cf_priv->font_extents.y = extents.descender;
- break;
- case PANGO_GRAVITY_EAST:
- case PANGO_GRAVITY_WEST:
- {
- int ascent = cf_priv->font_extents.height / 2;
- if (cf_priv->is_hinted)
- ascent = PANGO_UNITS_ROUND (ascent);
- cf_priv->font_extents.y = - ascent;
- }
- break;
- }
-
- if (cf_priv->is_hinted)
- {
- if (cf_priv->font_extents.y < 0)
- cf_priv->font_extents.y = PANGO_UNITS_FLOOR (cf_priv->font_extents.y);
- else
- cf_priv->font_extents.y = PANGO_UNITS_CEIL (cf_priv->font_extents.y);
- if (cf_priv->font_extents.height < 0)
- cf_priv->font_extents.height = PANGO_UNITS_FLOOR (extents.ascender) - PANGO_UNITS_CEIL
(extents.descender);
- else
- cf_priv->font_extents.height = PANGO_UNITS_CEIL (extents.ascender) - PANGO_UNITS_FLOOR
(extents.descender);
- }
-
- if (PANGO_GRAVITY_IS_IMPROPER (cf_priv->gravity))
- {
- cf_priv->font_extents.y = - cf_priv->font_extents.y;
- cf_priv->font_extents.height = - cf_priv->font_extents.height;
- }
-
- if (!cf_priv->glyph_extents_cache)
- {
- cf_priv->glyph_extents_cache = g_new0 (PangoCairoFontGlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES);
- /* Make sure all cache entries are invalid initially */
- cf_priv->glyph_extents_cache[0].glyph = 1; /* glyph 1 cannot happen in bucket 0 */
- }
-
- return TRUE;
-}
-
-
-/* Fills in the glyph extents cache entry
- */
-static void
-compute_glyph_extents (PangoCairoFontPrivate *cf_priv,
- PangoGlyph glyph,
- PangoCairoFontGlyphExtentsCacheEntry *entry)
-{
- cairo_text_extents_t extents;
- cairo_glyph_t cairo_glyph;
-
- cairo_glyph.index = glyph;
- cairo_glyph.x = 0;
- cairo_glyph.y = 0;
-
- cairo_scaled_font_glyph_extents (_pango_cairo_font_private_get_scaled_font (cf_priv),
- &cairo_glyph, 1, &extents);
-
- entry->glyph = glyph;
- if (PANGO_GRAVITY_IS_VERTICAL (cf_priv->gravity))
- entry->width = pango_units_from_double (extents.y_advance);
- else
- entry->width = pango_units_from_double (extents.x_advance);
- entry->ink_rect.x = pango_units_from_double (extents.x_bearing);
- entry->ink_rect.y = pango_units_from_double (extents.y_bearing);
- entry->ink_rect.width = pango_units_from_double (extents.width);
- entry->ink_rect.height = pango_units_from_double (extents.height);
-}
-
-static PangoCairoFontGlyphExtentsCacheEntry *
-_pango_cairo_font_private_get_glyph_extents_cache_entry (PangoCairoFontPrivate *cf_priv,
- PangoGlyph glyph)
-{
- PangoCairoFontGlyphExtentsCacheEntry *entry;
- guint idx;
-
- idx = glyph & GLYPH_CACHE_MASK;
- entry = cf_priv->glyph_extents_cache + idx;
-
- if (entry->glyph != glyph)
- {
- compute_glyph_extents (cf_priv, glyph, entry);
- }
-
- return entry;
-}
-
-void
-_pango_cairo_font_private_get_glyph_extents (PangoCairoFontPrivate *cf_priv,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
-{
- PangoCairoFontGlyphExtentsCacheEntry *entry;
-
- if (!cf_priv ||
- (cf_priv->glyph_extents_cache == NULL &&
- !_pango_cairo_font_private_glyph_extents_cache_init (cf_priv)))
- {
- /* Get generic unknown-glyph extents. */
- pango_font_get_glyph_extents (NULL, glyph, ink_rect, logical_rect);
- return;
- }
-
- if (glyph == PANGO_GLYPH_EMPTY)
- {
- if (ink_rect)
- ink_rect->x = ink_rect->y = ink_rect->width = ink_rect->height = 0;
- if (logical_rect)
- *logical_rect = cf_priv->font_extents;
- return;
- }
- else if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
- {
- _pango_cairo_font_private_get_glyph_extents_missing (cf_priv, glyph, ink_rect, logical_rect);
- return;
- }
-
- entry = _pango_cairo_font_private_get_glyph_extents_cache_entry (cf_priv, glyph);
-
- if (ink_rect)
- *ink_rect = entry->ink_rect;
- if (logical_rect)
- {
- *logical_rect = cf_priv->font_extents;
- switch (cf_priv->gravity)
- {
- case PANGO_GRAVITY_SOUTH:
- logical_rect->width = entry->width;
- break;
- case PANGO_GRAVITY_EAST:
- logical_rect->width = cf_priv->font_extents.height;
- logical_rect->x = - logical_rect->width;
- break;
- case PANGO_GRAVITY_NORTH:
- logical_rect->width = entry->width;
- break;
- case PANGO_GRAVITY_WEST:
- logical_rect->width = - cf_priv->font_extents.height;
- logical_rect->x = - logical_rect->width;
- break;
- case PANGO_GRAVITY_AUTO:
- default:
- g_assert_not_reached ();
- }
- }
}
diff --git a/pango/pangocairo-private.h b/pango/pangocairo-private.h
index 57081f43..7c16cf8c 100644
--- a/pango/pangocairo-private.h
+++ b/pango/pangocairo-private.h
@@ -22,13 +22,9 @@
#include <pango/pangocairo.h>
#include <pango/pango-renderer.h>
-#define PANGO_CAIRO_FONT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PANGO_TYPE_CAIRO_FONT,
PangoCairoFontIface))
-
-typedef struct _PangoCairoFontIface PangoCairoFontIface;
typedef struct _PangoCairoFontPrivate PangoCairoFontPrivate;
typedef struct _HexBoxInfo PangoCairoFontHexBoxInfo;
typedef struct _PangoCairoFontPrivateScaledFontData PangoCairoFontPrivateScaledFontData;
-typedef struct _PangoCairoFontGlyphExtentsCacheEntry PangoCairoFontGlyphExtentsCacheEntry;
struct _PangoCairoFontPrivateScaledFontData
{
@@ -39,7 +35,7 @@ struct _PangoCairoFontPrivateScaledFontData
struct _PangoCairoFontPrivate
{
- PangoCairoFont *cfont;
+ PangoFont *cfont;
PangoCairoFontPrivateScaledFontData *data;
@@ -50,43 +46,11 @@ struct _PangoCairoFontPrivate
PangoGravity gravity;
PangoRectangle font_extents;
- PangoCairoFontGlyphExtentsCacheEntry *glyph_extents_cache;
-
- GSList *metrics_by_lang;
-};
-
-struct _PangoCairoFontIface
-{
- GTypeInterface g_iface;
-
- cairo_font_face_t *(*create_font_face) (PangoCairoFont *cfont);
- PangoFontMetrics *(*create_base_metrics_for_context) (PangoCairoFont *cfont,
- PangoContext *context);
-
- gssize cf_priv_offset;
};
gboolean _pango_cairo_font_install (PangoFont *font,
cairo_t *cr);
-PangoFontMetrics * _pango_cairo_font_get_metrics (PangoFont *font,
- PangoLanguage *language);
PangoCairoFontHexBoxInfo *_pango_cairo_font_get_hex_box_info (PangoFont *font);
-PangoCairoFontPrivate *_pango_font_get_cairo_font_private (PangoFont *font);
-cairo_scaled_font_t *_pango_font_get_scaled_font (PangoFont *font);
-
-void _pango_cairo_font_private_initialize (PangoCairoFontPrivate *cf_priv,
- PangoCairoFont *font,
- PangoGravity gravity,
- const cairo_font_options_t *font_options,
- const PangoMatrix *pango_ctm,
- const cairo_matrix_t *font_matrix);
-void _pango_cairo_font_private_finalize (PangoCairoFontPrivate *cf_priv);
-cairo_scaled_font_t *_pango_cairo_font_private_get_scaled_font (PangoCairoFontPrivate *cf_priv);
-gboolean _pango_cairo_font_private_is_metrics_hinted (PangoCairoFontPrivate *cf_priv);
-void _pango_cairo_font_private_get_glyph_extents (PangoCairoFontPrivate *cf_priv,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect);
#define PANGO_TYPE_CAIRO_RENDERER (pango_cairo_renderer_get_type())
#define PANGO_CAIRO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object),
PANGO_TYPE_CAIRO_RENDERER, PangoCairoRenderer))
diff --git a/pango/pangocairo.h b/pango/pangocairo.h
index 477d0eb9..51a5f5ea 100644
--- a/pango/pangocairo.h
+++ b/pango/pangocairo.h
@@ -24,40 +24,6 @@
G_BEGIN_DECLS
-/**
- * PangoCairoFont:
- *
- * `PangoCairoFont` is an interface exported by fonts for
- * use with Cairo.
- *
- * The actual type of the font will depend on the particular
- * font technology Cairo was compiled to use.
- */
-typedef struct _PangoCairoFont PangoCairoFont;
-
-/* This is a hack because PangoCairo is hijacking the Pango namespace, but
- * consumers of the PangoCairo API expect these symbols to live under the
- * PangoCairo namespace.
- */
-#ifdef __GI_SCANNER__
-#define PANGO_CAIRO_TYPE_FONT (pango_cairo_font_get_type())
-#define PANGO_CAIRO_FONT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANGO_CAIRO_TYPE_FONT,
PangoCairoFont))
-#define PANGO_CAIRO_IS_FONT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANGO_CAIRO_TYPE_FONT))
-#else
-#define PANGO_TYPE_CAIRO_FONT (pango_cairo_font_get_type ())
-#define PANGO_CAIRO_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_CAIRO_FONT,
PangoCairoFont))
-#define PANGO_IS_CAIRO_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_CAIRO_FONT))
-#endif
-
-/*
- * PangoCairoFont
- */
-PANGO_AVAILABLE_IN_ALL
-GType pango_cairo_font_get_type (void) G_GNUC_CONST;
-
-PANGO_AVAILABLE_IN_ALL
-cairo_scaled_font_t *pango_cairo_font_get_scaled_font (PangoCairoFont *font);
-
/* Update a Pango context for the current state of a cairo context
*/
PANGO_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]