diff options
Diffstat (limited to 'pango/pango-font.c')
-rw-r--r-- | pango/pango-font.c | 260 |
1 files changed, 130 insertions, 130 deletions
diff --git a/pango/pango-font.c b/pango/pango-font.c index d8f081ad..cdf2fc42 100644 --- a/pango/pango-font.c +++ b/pango/pango-font.c @@ -1,4 +1,4 @@ -/* Pango +/* Pango2 * fonts.c: * * Copyright (C) 1999 Red Hat Software @@ -35,14 +35,14 @@ #include <hb-gobject.h> /** - * PangoFont: + * Pango2Font: * - * A `PangoFont` is used to represent a font in a + * A `Pango2Font` is used to represent a font in a * rendering-system-independent manner. */ /* }}} */ -/* {{{ PangoFont implementation */ +/* {{{ Pango2Font implementation */ enum { PROP_FACE = 1, @@ -55,26 +55,26 @@ enum { static GParamSpec *properties[N_PROPERTIES] = { NULL, }; -G_DEFINE_ABSTRACT_TYPE (PangoFont, pango_font, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE (Pango2Font, pango2_font, G_TYPE_OBJECT) static void -pango_font_finalize (GObject *object) +pango2_font_finalize (GObject *object) { - PangoFont *font = PANGO_FONT (object); + Pango2Font *font = PANGO2_FONT (object); g_object_unref (font->face); hb_font_destroy (font->hb_font); - G_OBJECT_CLASS (pango_font_parent_class)->finalize (object); + G_OBJECT_CLASS (pango2_font_parent_class)->finalize (object); } static void -pango_font_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) +pango2_font_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - PangoFont *font = PANGO_FONT (object); + Pango2Font *font = PANGO2_FONT (object); switch (property_id) { @@ -83,7 +83,7 @@ pango_font_get_property (GObject *object, break; case PROP_HB_FONT: - g_value_set_boxed (value, pango_font_get_hb_font (font)); + g_value_set_boxed (value, pango2_font_get_hb_font (font)); break; case PROP_SIZE: @@ -104,49 +104,49 @@ pango_font_get_property (GObject *object, } static gboolean -pango_font_default_is_hinted (PangoFont *font) +pango2_font_default_is_hinted (Pango2Font *font) { return FALSE; } static void -pango_font_default_get_scale_factors (PangoFont *font, - double *x_scale, - double *y_scale) +pango2_font_default_get_scale_factors (Pango2Font *font, + double *x_scale, + double *y_scale) { *x_scale = *y_scale = 1.0; } static void -pango_font_default_get_transform (PangoFont *font, - PangoMatrix *matrix) +pango2_font_default_get_transform (Pango2Font *font, + Pango2Matrix *matrix) { - *matrix = (PangoMatrix) PANGO_MATRIX_INIT; + *matrix = (Pango2Matrix) PANGO2_MATRIX_INIT; } static void -pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED) +pango2_font_class_init (Pango2FontClass *class G_GNUC_UNUSED) { GObjectClass *object_class = G_OBJECT_CLASS (class); - object_class->finalize = pango_font_finalize; - object_class->get_property = pango_font_get_property; + object_class->finalize = pango2_font_finalize; + object_class->get_property = pango2_font_get_property; - class->is_hinted = pango_font_default_is_hinted; - class->get_scale_factors = pango_font_default_get_scale_factors; - class->get_transform = pango_font_default_get_transform; + class->is_hinted = pango2_font_default_is_hinted; + class->get_scale_factors = pango2_font_default_get_scale_factors; + class->get_transform = pango2_font_default_get_transform; /** - * PangoFont:face: (attributes org.gtk.Property.get=pango_font_get_face) + * Pango2Font:face: (attributes org.gtk.Property.get=pango2_font_get_face) * * The face to which the font belongs. */ properties[PROP_FACE] = - g_param_spec_object ("face", NULL, NULL, PANGO_TYPE_FONT_FACE, + g_param_spec_object ("face", NULL, NULL, PANGO2_TYPE_FONT_FACE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); /** - * PangoFont:hb-font: (attributes org.gtk.Property.get=pango_font_get_hb_font) + * Pango2Font:hb-font: (attributes org.gtk.Property.get=pango2_font_get_hb_font) * * A `hb_font_t` object backing this font. */ @@ -155,16 +155,16 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); /** - * PangoFont:size: (attributes org.gtk.Property.get=pango_font_get_size) + * Pango2Font:size: (attributes org.gtk.Property.get=pango2_font_get_size) * - * The size of the font, scaled by `PANGO_SCALE`. + * The size of the font, scaled by `PANGO2_SCALE`. */ properties[PROP_SIZE] = g_param_spec_int ("size", NULL, NULL, 0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); /** - * PangoFont:dpi: + * Pango2Font:dpi: * * The resolution at which the font is rendered. * @@ -177,59 +177,59 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); /** - * PangoFont:gravity: (attributes org.gtk.Property.get=pango_font_get_gravity) + * Pango2Font:gravity: (attributes org.gtk.Property.get=pango2_font_get_gravity) * * The gravity of the font. */ properties[PROP_GRAVITY] = - g_param_spec_enum ("gravity", NULL, NULL, PANGO_TYPE_GRAVITY, - PANGO_GRAVITY_AUTO, + g_param_spec_enum ("gravity", NULL, NULL, PANGO2_TYPE_GRAVITY, + PANGO2_GRAVITY_AUTO, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, N_PROPERTIES, properties); } static void -pango_font_init (PangoFont *font) +pango2_font_init (Pango2Font *font) { - font->gravity = PANGO_GRAVITY_AUTO; - font->ctm = (PangoMatrix) PANGO_MATRIX_INIT; + font->gravity = PANGO2_GRAVITY_AUTO; + font->ctm = (Pango2Matrix) PANGO2_MATRIX_INIT; } /* }}} */ /* {{{ Private API */ /*< private > - * pango_font_get_transform: - * @font: a `PangoFont` + * pango2_font_get_transform: + * @font: a `Pango2Font` * @matrix: the matrix to fill in * * Gets the matrix for the transformation from 'font space' to 'user space'. */ void -pango_font_get_transform (PangoFont *font, - PangoMatrix *matrix) +pango2_font_get_transform (Pango2Font *font, + Pango2Matrix *matrix) { - PANGO_FONT_GET_CLASS (font)->get_transform (font, matrix); + PANGO2_FONT_GET_CLASS (font)->get_transform (font, matrix); } /*< private > - * pango_font_is_hinted: - * @font: a `PangoFont` + * pango2_font_is_hinted: + * @font: a `Pango2Font` * * Gets whether this font is hinted. * * Returns: %TRUE if @font is hinted */ gboolean -pango_font_is_hinted (PangoFont *font) +pango2_font_is_hinted (Pango2Font *font) { - return PANGO_FONT_GET_CLASS (font)->is_hinted (font); + return PANGO2_FONT_GET_CLASS (font)->is_hinted (font); } /*< private > - * pango_font_get_scale_factors: - * @font: a `PangoFont` + * pango2_font_get_scale_factors: + * @font: a `Pango2Font` * @x_scale: return location for X scale * @y_scale: return location for Y scale * @@ -239,62 +239,62 @@ pango_font_is_hinted (PangoFont *font) * loaded for. */ void -pango_font_get_scale_factors (PangoFont *font, - double *x_scale, - double *y_scale) +pango2_font_get_scale_factors (Pango2Font *font, + double *x_scale, + double *y_scale) { - PANGO_FONT_GET_CLASS (font)->get_scale_factors (font, x_scale, y_scale); + PANGO2_FONT_GET_CLASS (font)->get_scale_factors (font, x_scale, y_scale); } /* }}} */ /* {{{ Public API */ /** - * pango_font_describe: - * @font: a `PangoFont` + * pango2_font_describe: + * @font: a `Pango2Font` * * Returns a description of the font, with font size set in points. * - * Use [method@Pango.Font.describe_with_absolute_size] if you want + * Use [method@Pango2.Font.describe_with_absolute_size] if you want * the font size in device units. * - * Return value: a newly-allocated `PangoFontDescription` object. + * Return value: a newly-allocated `Pango2FontDescription` object. */ -PangoFontDescription * -pango_font_describe (PangoFont *font) +Pango2FontDescription * +pango2_font_describe (Pango2Font *font) { g_return_val_if_fail (font != NULL, NULL); - return PANGO_FONT_GET_CLASS (font)->describe (font); + return PANGO2_FONT_GET_CLASS (font)->describe (font); } /** - * pango_font_describe_with_absolute_size: - * @font: a `PangoFont` + * pango2_font_describe_with_absolute_size: + * @font: a `Pango2Font` * * Returns a description of the font, with absolute font size set * in device units. * - * Use [method@Pango.Font.describe] if you want the font size in points. + * Use [method@Pango2.Font.describe] if you want the font size in points. * - * Return value: a newly-allocated `PangoFontDescription` object. + * Return value: a newly-allocated `Pango2FontDescription` object. */ -PangoFontDescription * -pango_font_describe_with_absolute_size (PangoFont *font) +Pango2FontDescription * +pango2_font_describe_with_absolute_size (Pango2Font *font) { - PangoFontDescription *desc; + Pango2FontDescription *desc; g_return_val_if_fail (font != NULL, NULL); - desc = pango_font_describe (font); - pango_font_description_set_absolute_size (desc, font->size * font->dpi / 72.); + desc = pango2_font_describe (font); + pango2_font_description_set_absolute_size (desc, font->size * font->dpi / 72.); return desc; } /** - * pango_font_get_glyph_extents: - * @font: (nullable): a `PangoFont` + * pango2_font_get_glyph_extents: + * @font: (nullable): a `Pango2Font` * @glyph: the glyph index * @ink_rect: (out) (optional): rectangle used to store the extents of the glyph as drawn * @logical_rect: (out) (optional): rectangle used to store the logical extents of the glyph @@ -303,45 +303,45 @@ pango_font_describe_with_absolute_size (PangoFont *font) * * The coordinate system for each rectangle has its origin at the * base line and horizontal origin of the character with increasing - * coordinates extending to the right and down. The macros PANGO_ASCENT(), - * PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert + * coordinates extending to the right and down. The macros PANGO2_ASCENT(), + * PANGO2_DESCENT(), PANGO2_LBEARING(), and PANGO2_RBEARING() can be used to convert * from the extents rectangle to more traditional font metrics. The units - * of the rectangles are in 1/PANGO_SCALE of a device unit. + * of the rectangles are in 1/PANGO2_SCALE of a device unit. * * If @font is %NULL, this function gracefully sets some sane values in the * output variables and returns. */ void -pango_font_get_glyph_extents (PangoFont *font, - PangoGlyph glyph, - PangoRectangle *ink_rect, - PangoRectangle *logical_rect) +pango2_font_get_glyph_extents (Pango2Font *font, + Pango2Glyph glyph, + Pango2Rectangle *ink_rect, + Pango2Rectangle *logical_rect) { if (G_UNLIKELY (!font)) { if (ink_rect) { - ink_rect->x = PANGO_SCALE; - ink_rect->y = - (PANGO_UNKNOWN_GLYPH_HEIGHT - 1) * PANGO_SCALE; - ink_rect->height = (PANGO_UNKNOWN_GLYPH_HEIGHT - 2) * PANGO_SCALE; - ink_rect->width = (PANGO_UNKNOWN_GLYPH_WIDTH - 2) * PANGO_SCALE; + ink_rect->x = PANGO2_SCALE; + ink_rect->y = - (PANGO2_UNKNOWN_GLYPH_HEIGHT - 1) * PANGO2_SCALE; + ink_rect->height = (PANGO2_UNKNOWN_GLYPH_HEIGHT - 2) * PANGO2_SCALE; + ink_rect->width = (PANGO2_UNKNOWN_GLYPH_WIDTH - 2) * PANGO2_SCALE; } if (logical_rect) { logical_rect->x = 0; - logical_rect->y = - PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE; - logical_rect->height = PANGO_UNKNOWN_GLYPH_HEIGHT * PANGO_SCALE; - logical_rect->width = PANGO_UNKNOWN_GLYPH_WIDTH * PANGO_SCALE; + logical_rect->y = - PANGO2_UNKNOWN_GLYPH_HEIGHT * PANGO2_SCALE; + logical_rect->height = PANGO2_UNKNOWN_GLYPH_HEIGHT * PANGO2_SCALE; + logical_rect->width = PANGO2_UNKNOWN_GLYPH_WIDTH * PANGO2_SCALE; } return; } - PANGO_FONT_GET_CLASS (font)->get_glyph_extents (font, glyph, ink_rect, logical_rect); + PANGO2_FONT_GET_CLASS (font)->get_glyph_extents (font, glyph, ink_rect, logical_rect); } /** - * pango_font_get_metrics: - * @font: (nullable): a `PangoFont` + * pango2_font_get_metrics: + * @font: (nullable): a `Pango2Font` * @language: (nullable): language tag used to determine which script * to get the metrics for, or %NULL to indicate to get the metrics for * the entire font. @@ -355,52 +355,52 @@ pango_font_get_glyph_extents (PangoFont *font, * If @font is %NULL, this function gracefully sets some sane values in the * output variables and returns. * - * Return value: a `PangoFontMetrics` object. The caller must call - * [method@Pango.FontMetrics.free] when finished using the object. + * Return value: a `Pango2FontMetrics` object. The caller must call + * [method@Pango2.FontMetrics.free] when finished using the object. */ -PangoFontMetrics * -pango_font_get_metrics (PangoFont *font, - PangoLanguage *language) +Pango2FontMetrics * +pango2_font_get_metrics (Pango2Font *font, + Pango2Language *language) { if (G_UNLIKELY (!font)) { - PangoFontMetrics *metrics = pango_font_metrics_new (); + Pango2FontMetrics *metrics = pango2_font_metrics_new (); - metrics->ascent = PANGO_SCALE * PANGO_UNKNOWN_GLYPH_HEIGHT; + metrics->ascent = PANGO2_SCALE * PANGO2_UNKNOWN_GLYPH_HEIGHT; metrics->descent = 0; metrics->height = 0; - metrics->approximate_char_width = PANGO_SCALE * PANGO_UNKNOWN_GLYPH_WIDTH; - metrics->approximate_digit_width = PANGO_SCALE * PANGO_UNKNOWN_GLYPH_WIDTH; - metrics->underline_position = -PANGO_SCALE; - metrics->underline_thickness = PANGO_SCALE; - metrics->strikethrough_position = PANGO_SCALE * PANGO_UNKNOWN_GLYPH_HEIGHT / 2; - metrics->strikethrough_thickness = PANGO_SCALE; + metrics->approximate_char_width = PANGO2_SCALE * PANGO2_UNKNOWN_GLYPH_WIDTH; + metrics->approximate_digit_width = PANGO2_SCALE * PANGO2_UNKNOWN_GLYPH_WIDTH; + metrics->underline_position = -PANGO2_SCALE; + metrics->underline_thickness = PANGO2_SCALE; + metrics->strikethrough_position = PANGO2_SCALE * PANGO2_UNKNOWN_GLYPH_HEIGHT / 2; + metrics->strikethrough_thickness = PANGO2_SCALE; return metrics; } - return PANGO_FONT_GET_CLASS (font)->get_metrics (font, language); + return PANGO2_FONT_GET_CLASS (font)->get_metrics (font, language); } /** - * pango_font_get_face: - * @font: a `PangoFont` + * pango2_font_get_face: + * @font: a `Pango2Font` * - * Gets the `PangoFontFace` to which the font belongs. + * Gets the `Pango2FontFace` to which the font belongs. * - * Returns: (transfer none): the `PangoFontFace` + * Returns: (transfer none): the `Pango2FontFace` */ -PangoFontFace * -pango_font_get_face (PangoFont *font) +Pango2FontFace * +pango2_font_get_face (Pango2Font *font) { - g_return_val_if_fail (PANGO_IS_FONT (font), NULL); + g_return_val_if_fail (PANGO2_IS_FONT (font), NULL); return font->face; } /** - * pango_font_get_hb_font: - * @font: a `PangoFont` + * pango2_font_get_hb_font: + * @font: a `Pango2Font` * * Get a `hb_font_t` object backing this font. * @@ -412,13 +412,13 @@ pango_font_get_face (PangoFont *font) * backing the font */ hb_font_t * -pango_font_get_hb_font (PangoFont *font) +pango2_font_get_hb_font (Pango2Font *font) { - g_return_val_if_fail (PANGO_IS_FONT (font), NULL); + g_return_val_if_fail (PANGO2_IS_FONT (font), NULL); if (!font->hb_font) { - font->hb_font = PANGO_FONT_GET_CLASS (font)->create_hb_font (font); + font->hb_font = PANGO2_FONT_GET_CLASS (font)->create_hb_font (font); hb_font_make_immutable (font->hb_font); } @@ -426,49 +426,49 @@ pango_font_get_hb_font (PangoFont *font) } /** - * pango_font_get_size: - * @font: a `PangoFont` + * pango2_font_get_size: + * @font: a `Pango2Font` * - * Returns the size of the font, scaled by `PANGO_SCALE`. + * Returns the size of the font, scaled by `PANGO2_SCALE`. * * Return value: the size of the font */ int -pango_font_get_size (PangoFont *font) +pango2_font_get_size (Pango2Font *font) { - g_return_val_if_fail (PANGO_IS_FONT (font), 0); + g_return_val_if_fail (PANGO2_IS_FONT (font), 0); return font->size; } /** - * pango_font_get_absolute_size: - * @font: a `PangoFont` + * pango2_font_get_absolute_size: + * @font: a `Pango2Font` * - * Returns the pixel size of the font, scaled by `PANGO_SCALE`. + * Returns the pixel size of the font, scaled by `PANGO2_SCALE`. * * Return value: the pixel size of the font */ double -pango_font_get_absolute_size (PangoFont *font) +pango2_font_get_absolute_size (Pango2Font *font) { - g_return_val_if_fail (PANGO_IS_FONT (font), 0.); + g_return_val_if_fail (PANGO2_IS_FONT (font), 0.); return font->size * font->dpi / 72.; } /** - * pango_font_get_gravity: - * @font: a `PangoFont` + * pango2_font_get_gravity: + * @font: a `Pango2Font` * * Returns the gravity of the font. * * Return value: the gravity of the font */ -PangoGravity -pango_font_get_gravity (PangoFont *font) +Pango2Gravity +pango2_font_get_gravity (Pango2Font *font) { - g_return_val_if_fail (PANGO_IS_FONT (font), PANGO_GRAVITY_SOUTH); + g_return_val_if_fail (PANGO2_IS_FONT (font), PANGO2_GRAVITY_SOUTH); return font->gravity; } |