summaryrefslogtreecommitdiff
path: root/pango/pango-hbfont.c
diff options
context:
space:
mode:
Diffstat (limited to 'pango/pango-hbfont.c')
-rw-r--r--pango/pango-hbfont.c464
1 files changed, 232 insertions, 232 deletions
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index fd523a98..a8876224 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -1,4 +1,4 @@
-/* Pango
+/* Pango2
*
* Copyright (C) 2021 Matthias Clasen
*
@@ -32,14 +32,14 @@
#include <hb-ot.h>
/**
- * PangoHbFont:
+ * Pango2HbFont:
*
- * `PangoHbFont` is a `PangoFont` implementation that wraps
- * a `hb_font_t` object and implements all of the `PangoFont`
+ * `Pango2HbFont` is a `Pango2Font` implementation that wraps
+ * a `hb_font_t` object and implements all of the `Pango2Font`
* functionality using HarfBuzz.
*
- * In addition to a `PangoHbFace` and a size, a number of optional
- * parameters can be tweaked when creating a `PangoHbFont`. First
+ * In addition to a `Pango2HbFace` and a size, a number of optional
+ * parameters can be tweaked when creating a `Pango2HbFont`. First
* there are OpenType font features, which can be used to e.g.
* select Small Caps. If the face has variation axes, then
* coordinates for these axes can be provided. Finally, there are
@@ -50,37 +50,37 @@
/* {{{ Utilities */
static int
-get_average_char_width (PangoFont *font,
+get_average_char_width (Pango2Font *font,
const char *text)
{
- hb_font_t *hb_font = pango_font_get_hb_font (font);
+ hb_font_t *hb_font = pango2_font_get_hb_font (font);
int width = 0;
for (const char *p = text; *p; p = g_utf8_next_char (p))
{
gunichar wc;
hb_codepoint_t glyph;
- PangoRectangle extents;
+ Pango2Rectangle extents;
wc = g_utf8_get_char (p);
if (!hb_font_get_nominal_glyph (hb_font, wc, &glyph))
continue;
- pango_font_get_glyph_extents (font, glyph, &extents, NULL);
+ pango2_font_get_glyph_extents (font, glyph, &extents, NULL);
width += extents.x + extents.width;
}
- return width / pango_utf8_strwidth (text);
+ return width / pango2_utf8_strwidth (text);
}
static void
-get_max_char_size (PangoFont *font,
+get_max_char_size (Pango2Font *font,
const char *text,
int *width,
int *height)
{
- hb_font_t *hb_font = pango_font_get_hb_font (font);
+ hb_font_t *hb_font = pango2_font_get_hb_font (font);
int w = 0;
int h = 0;
@@ -88,13 +88,13 @@ get_max_char_size (PangoFont *font,
{
gunichar wc;
hb_codepoint_t glyph;
- PangoRectangle extents;
+ Pango2Rectangle extents;
wc = g_utf8_get_char (p);
if (!hb_font_get_nominal_glyph (hb_font, wc, &glyph))
continue;
- pango_font_get_glyph_extents (font, glyph, &extents, NULL);
+ pango2_font_get_glyph_extents (font, glyph, &extents, NULL);
w = MAX (w, extents.x + extents.width);
h = MAX (h, extents.height);
@@ -107,11 +107,11 @@ get_max_char_size (PangoFont *font,
*height = h;
}
-static PangoVariant
-pango_variant_from_features (hb_feature_t *features,
- unsigned int n_features)
+static Pango2Variant
+pango2_variant_from_features (hb_feature_t *features,
+ unsigned int n_features)
{
- PangoVariant variant = PANGO_VARIANT_NORMAL;
+ Pango2Variant variant = PANGO2_VARIANT_NORMAL;
gboolean all_caps = FALSE;
for (int i = 0; i < n_features; i++)
@@ -123,33 +123,33 @@ pango_variant_from_features (hb_feature_t *features,
{
case HB_TAG('s','m','c','p'):
if (all_caps)
- variant = PANGO_VARIANT_ALL_SMALL_CAPS;
+ variant = PANGO2_VARIANT_ALL_SMALL_CAPS;
else
- variant = PANGO_VARIANT_SMALL_CAPS;
+ variant = PANGO2_VARIANT_SMALL_CAPS;
break;
case HB_TAG('c','2','s','c'):
- if (variant == PANGO_VARIANT_SMALL_CAPS)
- variant = PANGO_VARIANT_ALL_SMALL_CAPS;
+ if (variant == PANGO2_VARIANT_SMALL_CAPS)
+ variant = PANGO2_VARIANT_ALL_SMALL_CAPS;
else
all_caps = TRUE;
break;
case HB_TAG('p','c','a','p'):
if (all_caps)
- variant = PANGO_VARIANT_ALL_PETITE_CAPS;
+ variant = PANGO2_VARIANT_ALL_PETITE_CAPS;
else
- variant = PANGO_VARIANT_PETITE_CAPS;
+ variant = PANGO2_VARIANT_PETITE_CAPS;
break;
case HB_TAG('c','2','p','c'):
- if (variant == PANGO_VARIANT_PETITE_CAPS)
- variant = PANGO_VARIANT_ALL_PETITE_CAPS;
+ if (variant == PANGO2_VARIANT_PETITE_CAPS)
+ variant = PANGO2_VARIANT_ALL_PETITE_CAPS;
else
all_caps = TRUE;
break;
case HB_TAG('u','n','i','c'):
- variant = PANGO_VARIANT_UNICASE;
+ variant = PANGO2_VARIANT_UNICASE;
break;
case HB_TAG('t','i','t','l'):
- variant = PANGO_VARIANT_TITLE_CAPS;
+ variant = PANGO2_VARIANT_TITLE_CAPS;
break;
default:
break;
@@ -160,10 +160,10 @@ pango_variant_from_features (hb_feature_t *features,
}
static void
-font_description_get_features (const PangoFontDescription *description,
- hb_feature_t *features,
- unsigned int length,
- unsigned int *n_features)
+font_description_get_features (const Pango2FontDescription *description,
+ hb_feature_t *features,
+ unsigned int length,
+ unsigned int *n_features)
{
#define ADD_FEATURE(name) \
@@ -176,29 +176,29 @@ font_description_get_features (const PangoFontDescription *description,
g_assert (length >= 2);
*n_features = 0;
- switch (pango_font_description_get_variant (description))
+ switch (pango2_font_description_get_variant (description))
{
- case PANGO_VARIANT_SMALL_CAPS:
+ case PANGO2_VARIANT_SMALL_CAPS:
ADD_FEATURE ("smcp");
break;
- case PANGO_VARIANT_ALL_SMALL_CAPS:
+ case PANGO2_VARIANT_ALL_SMALL_CAPS:
ADD_FEATURE ("smcp");
ADD_FEATURE ("c2sc");
break;
- case PANGO_VARIANT_PETITE_CAPS:
+ case PANGO2_VARIANT_PETITE_CAPS:
ADD_FEATURE ("pcap");
break;
- case PANGO_VARIANT_ALL_PETITE_CAPS:
+ case PANGO2_VARIANT_ALL_PETITE_CAPS:
ADD_FEATURE ("pcap");
ADD_FEATURE ("c2pc");
break;
- case PANGO_VARIANT_UNICASE:
+ case PANGO2_VARIANT_UNICASE:
ADD_FEATURE ("unic");
break;
- case PANGO_VARIANT_TITLE_CAPS:
+ case PANGO2_VARIANT_TITLE_CAPS:
ADD_FEATURE ("titl");
break;
- case PANGO_VARIANT_NORMAL:
+ case PANGO2_VARIANT_NORMAL:
break;
default:
g_assert_not_reached ();
@@ -329,12 +329,12 @@ collect_variations (hb_variation_t *variations,
/* This code needs to stay in sync with the hexbox rendering code in pangocairo-render.c */
static HexBoxInfo *
-create_hex_box_info (PangoHbFont *self)
+create_hex_box_info (Pango2HbFont *self)
{
- PangoFont *font = PANGO_FONT (self);
+ Pango2Font *font = PANGO2_FONT (self);
const char hexdigits[] = "0123456789ABCDEF";
hb_font_t *hb_font;
- PangoFont *mini_font;
+ Pango2Font *mini_font;
HexBoxInfo *hbi;
int rows;
double pad;
@@ -343,20 +343,20 @@ create_hex_box_info (PangoHbFont *self)
hb_font_extents_t font_extents;
double font_ascent, font_descent;
double mini_size;
- PangoFontDescription *desc;
- PangoContext *context;
- PangoFontMap *map;
+ Pango2FontDescription *desc;
+ Pango2Context *context;
+ Pango2FontMap *map;
- if (!PANGO_FONT_FACE (font->face)->family)
+ if (!PANGO2_FONT_FACE (font->face)->family)
return NULL;
- map = PANGO_FONT_FACE (font->face)->family->map;
+ map = PANGO2_FONT_FACE (font->face)->family->map;
if (!map)
return NULL;
- desc = pango_font_describe_with_absolute_size (font);
- hb_font = pango_font_get_hb_font (font);
+ desc = pango2_font_describe_with_absolute_size (font);
+ hb_font = pango2_font_get_hb_font (font);
/* Create mini_font description */
@@ -366,9 +366,9 @@ create_hex_box_info (PangoHbFont *self)
*/
/* We should rotate the box, not glyphs */
- pango_font_description_unset_fields (desc, PANGO_FONT_MASK_GRAVITY);
+ pango2_font_description_unset_fields (desc, PANGO2_FONT_MASK_GRAVITY);
- pango_font_description_set_family_static (desc, "monospace");
+ pango2_font_description_set_family_static (desc, "monospace");
rows = 2;
mini_size = font->size / 2.2;
@@ -379,34 +379,34 @@ create_hex_box_info (PangoHbFont *self)
mini_size = MIN (MAX (font->size - 1, 0), 6.0);
}
- pango_font_description_set_size (desc, mini_size);
+ pango2_font_description_set_size (desc, mini_size);
/* Load mini_font */
- context = pango_context_new_with_font_map (map);
- pango_context_set_matrix (context, &font->ctm);
- pango_context_set_language (context, pango_script_get_sample_language (G_UNICODE_SCRIPT_LATIN));
+ context = pango2_context_new_with_font_map (map);
+ pango2_context_set_matrix (context, &font->ctm);
+ pango2_context_set_language (context, pango2_script_get_sample_language (G_UNICODE_SCRIPT_LATIN));
- mini_font = pango_font_map_load_font (map, context, desc);
+ mini_font = pango2_font_map_load_font (map, context, desc);
g_object_unref (context);
- pango_font_description_free (desc);
+ pango2_font_description_free (desc);
get_max_char_size (mini_font, hexdigits, &width, &height);
hb_font_get_extents_for_direction (hb_font, HB_DIRECTION_LTR, &font_extents);
- font_ascent = font_extents.ascender / (double) PANGO_SCALE;
- font_descent = - font_extents.descender / (double) PANGO_SCALE;
+ font_ascent = font_extents.ascender / (double) PANGO2_SCALE;
+ font_descent = - font_extents.descender / (double) PANGO2_SCALE;
pad = (font_ascent + font_descent) / 43.;
- pad = MIN (pad, mini_size / (double) PANGO_SCALE);
+ pad = MIN (pad, mini_size / (double) PANGO2_SCALE);
hbi = g_new (HexBoxInfo, 1);
hbi->font = mini_font;
hbi->rows = rows;
- hbi->digit_width = width / (double) PANGO_SCALE;
- hbi->digit_height = height / (double) PANGO_SCALE;
+ hbi->digit_width = width / (double) PANGO2_SCALE;
+ hbi->digit_height = height / (double) PANGO2_SCALE;
hbi->pad_x = pad;
hbi->pad_y = pad;
@@ -426,17 +426,17 @@ create_hex_box_info (PangoHbFont *self)
}
static void
-get_space_extents (PangoHbFont *self,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+get_space_extents (Pango2HbFont *self,
+ Pango2Rectangle *ink_rect,
+ Pango2Rectangle *logical_rect)
{
- PangoFont *font = PANGO_FONT (self);
- hb_font_t *hb_font = pango_font_get_hb_font (font);
+ Pango2Font *font = PANGO2_FONT (self);
+ hb_font_t *hb_font = pango2_font_get_hb_font (font);
int width;
hb_direction_t direction;
hb_font_extents_t font_extents;
- direction = PANGO_GRAVITY_IS_VERTICAL (font->gravity)
+ direction = PANGO2_GRAVITY_IS_VERTICAL (font->gravity)
? HB_DIRECTION_TTB
: HB_DIRECTION_LTR;
@@ -462,16 +462,16 @@ get_space_extents (PangoHbFont *self,
}
static void
-get_glyph_extents_missing (PangoHbFont *self,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+get_glyph_extents_missing (Pango2HbFont *self,
+ Pango2Glyph glyph,
+ Pango2Rectangle *ink_rect,
+ Pango2Rectangle *logical_rect)
{
gunichar ch;
int rows, cols;
HexBoxInfo *hbi;
- ch = glyph & ~PANGO_GLYPH_UNKNOWN_FLAG;
+ ch = glyph & ~PANGO2_GLYPH_UNKNOWN_FLAG;
if (!self->hex_box_info)
self->hex_box_info = create_hex_box_info (self);
@@ -484,12 +484,12 @@ get_glyph_extents_missing (PangoHbFont *self,
hbi = self->hex_box_info;
- if (G_UNLIKELY (glyph == PANGO_GLYPH_INVALID_INPUT || ch > 0x10FFFF))
+ if (G_UNLIKELY (glyph == PANGO2_GLYPH_INVALID_INPUT || ch > 0x10FFFF))
{
rows = hbi->rows;
cols = 1;
}
- else if (pango_get_ignorable_size (ch, &rows, &cols))
+ else if (pango2_get_ignorable_size (ch, &rows, &cols))
{
/* We special-case ignorables when rendering hex boxes */
}
@@ -501,27 +501,27 @@ get_glyph_extents_missing (PangoHbFont *self,
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;
+ ink_rect->x = PANGO2_SCALE * hbi->pad_x;
+ ink_rect->y = PANGO2_SCALE * (hbi->box_descent - hbi->box_height);
+ ink_rect->width = PANGO2_SCALE * (3 * hbi->pad_x + cols * (hbi->digit_width + hbi->pad_x));
+ ink_rect->height = PANGO2_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);
+ logical_rect->y = PANGO2_SCALE * (hbi->box_descent - (hbi->box_height + hbi->pad_y));
+ logical_rect->width = PANGO2_SCALE * (5 * hbi->pad_x + cols * (hbi->digit_width + hbi->pad_x));
+ logical_rect->height = PANGO2_SCALE * (hbi->box_height + 2 * hbi->pad_y);
}
}
/* }}} */
-/* {{{ PangoFont implementation */
+/* {{{ Pango2Font implementation */
-struct _PangoHbFontClass
+struct _Pango2HbFontClass
{
- PangoFontClass parent_class;
+ Pango2FontClass parent_class;
};
enum {
@@ -531,10 +531,10 @@ enum {
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
-G_DEFINE_FINAL_TYPE (PangoHbFont, pango_hb_font, PANGO_TYPE_FONT)
+G_DEFINE_FINAL_TYPE (Pango2HbFont, pango2_hb_font, PANGO2_TYPE_FONT)
static void
-pango_hb_font_init (PangoHbFont *self)
+pango2_hb_font_init (Pango2HbFont *self)
{
}
@@ -546,24 +546,24 @@ hex_box_info_destroy (HexBoxInfo *hex_box_info)
}
static void
-pango_hb_font_finalize (GObject *object)
+pango2_hb_font_finalize (GObject *object)
{
- PangoHbFont *self = PANGO_HB_FONT (object);
+ Pango2HbFont *self = PANGO2_HB_FONT (object);
g_free (self->variations);
g_clear_pointer (&self->hex_box_info, hex_box_info_destroy);
- G_OBJECT_CLASS (pango_hb_font_parent_class)->finalize (object);
+ G_OBJECT_CLASS (pango2_hb_font_parent_class)->finalize (object);
}
static void
-pango_hb_font_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+pango2_hb_font_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- PangoHbFont *self = PANGO_HB_FONT (object);
+ Pango2HbFont *self = PANGO2_HB_FONT (object);
switch (property_id)
{
@@ -581,21 +581,21 @@ pango_hb_font_get_property (GObject *object,
}
}
-static PangoFontDescription *
-pango_hb_font_describe (PangoFont *font)
+static Pango2FontDescription *
+pango2_hb_font_describe (Pango2Font *font)
{
- PangoHbFont *self = PANGO_HB_FONT (font);
- PangoHbFace *face = PANGO_HB_FACE (font->face);
- PangoFontDescription *desc;
- PangoVariant variant;
-
- desc = pango_font_face_describe (font->face);
- pango_font_description_set_gravity (desc, font->gravity);
- pango_font_description_set_size (desc, font->size);
-
- variant = pango_variant_from_features (self->features, self->n_features);
- if (variant != PANGO_VARIANT_NORMAL)
- pango_font_description_set_variant (desc, variant);
+ Pango2HbFont *self = PANGO2_HB_FONT (font);
+ Pango2HbFace *face = PANGO2_HB_FACE (font->face);
+ Pango2FontDescription *desc;
+ Pango2Variant variant;
+
+ desc = pango2_font_face_describe (font->face);
+ pango2_font_description_set_gravity (desc, font->gravity);
+ pango2_font_description_set_size (desc, font->size);
+
+ variant = pango2_variant_from_features (self->features, self->n_features);
+ if (variant != PANGO2_VARIANT_NORMAL)
+ pango2_font_description_set_variant (desc, variant);
if (self->n_variations > 0 || face->n_variations > 0)
{
hb_variation_t *variations;
@@ -616,7 +616,7 @@ pango_hb_font_describe (PangoFont *font)
}
str = variations_to_string (variations, n_variations);
- pango_font_description_set_variations (desc, str);
+ pango2_font_description_set_variations (desc, str);
g_free (str);
}
@@ -624,25 +624,25 @@ pango_hb_font_describe (PangoFont *font)
}
static void
-pango_hb_font_get_glyph_extents (PangoFont *font,
- PangoGlyph glyph,
- PangoRectangle *ink_rect,
- PangoRectangle *logical_rect)
+pango2_hb_font_get_glyph_extents (Pango2Font *font,
+ Pango2Glyph glyph,
+ Pango2Rectangle *ink_rect,
+ Pango2Rectangle *logical_rect)
{
- PangoHbFont *self = PANGO_HB_FONT (font);
- PangoHbFace *face = PANGO_HB_FACE (font->face);
- hb_font_t *hb_font = pango_font_get_hb_font (font);
+ Pango2HbFont *self = PANGO2_HB_FONT (font);
+ Pango2HbFace *face = PANGO2_HB_FACE (font->face);
+ hb_font_t *hb_font = pango2_font_get_hb_font (font);
hb_glyph_extents_t extents;
hb_direction_t direction;
hb_font_extents_t font_extents;
- direction = PANGO_GRAVITY_IS_VERTICAL (font->gravity)
+ direction = PANGO2_GRAVITY_IS_VERTICAL (font->gravity)
? HB_DIRECTION_TTB
: HB_DIRECTION_LTR;
hb_font_get_extents_for_direction (hb_font, direction, &font_extents);
- if (glyph == PANGO_GLYPH_EMPTY)
+ if (glyph == PANGO2_GLYPH_EMPTY)
{
if (ink_rect)
ink_rect->x = ink_rect->y = ink_rect->width = ink_rect->height = 0;
@@ -656,7 +656,7 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
return;
}
- else if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ else if (glyph & PANGO2_GLYPH_UNKNOWN_FLAG)
{
get_glyph_extents_missing (self, glyph, ink_rect, logical_rect);
@@ -667,8 +667,8 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
if (ink_rect)
{
- PangoRectangle r;
- PangoMatrix m = PANGO_MATRIX_INIT;
+ Pango2Rectangle r;
+ Pango2Matrix m = PANGO2_MATRIX_INIT;
r.x = extents.x_bearing;
r.y = - extents.y_bearing;
@@ -682,31 +682,31 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
m.xy = - face->transform->xy;
m.yy = face->transform->yy;
- pango_matrix_transform_rectangle (&m, &r);
+ pango2_matrix_transform_rectangle (&m, &r);
}
switch (font->gravity)
{
- case PANGO_GRAVITY_AUTO:
- case PANGO_GRAVITY_SOUTH:
+ case PANGO2_GRAVITY_AUTO:
+ case PANGO2_GRAVITY_SOUTH:
ink_rect->x = r.x;
ink_rect->y = r.y;
ink_rect->width = r.width;
ink_rect->height = r.height;
break;
- case PANGO_GRAVITY_NORTH:
+ case PANGO2_GRAVITY_NORTH:
ink_rect->x = - r.x;
ink_rect->y = - r.y;
ink_rect->width = - r.width;
ink_rect->height = - r.height;
break;
- case PANGO_GRAVITY_EAST:
+ case PANGO2_GRAVITY_EAST:
ink_rect->x = r.y;
ink_rect->y = - r.x - r.width;
ink_rect->width = r.height;
ink_rect->height = r.width;
break;
- case PANGO_GRAVITY_WEST:
+ case PANGO2_GRAVITY_WEST:
ink_rect->x = - r.y - r.height;
ink_rect->y = r.x;
ink_rect->width = r.height;
@@ -716,11 +716,11 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
g_assert_not_reached ();
}
- if (PANGO_GRAVITY_IS_IMPROPER (font->gravity))
+ if (PANGO2_GRAVITY_IS_IMPROPER (font->gravity))
{
- PangoMatrix matrix = (PangoMatrix) PANGO_MATRIX_INIT;
- pango_matrix_scale (&matrix, -1, -1);
- pango_matrix_transform_rectangle (&matrix, ink_rect);
+ Pango2Matrix matrix = (Pango2Matrix) PANGO2_MATRIX_INIT;
+ pango2_matrix_scale (&matrix, -1, -1);
+ pango2_matrix_transform_rectangle (&matrix, ink_rect);
}
}
@@ -737,20 +737,20 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
switch (font->gravity)
{
- case PANGO_GRAVITY_AUTO:
- case PANGO_GRAVITY_SOUTH:
+ case PANGO2_GRAVITY_AUTO:
+ case PANGO2_GRAVITY_SOUTH:
logical_rect->y = - extents.ascender;
logical_rect->width = h_advance;
break;
- case PANGO_GRAVITY_NORTH:
+ case PANGO2_GRAVITY_NORTH:
logical_rect->y = extents.descender;
logical_rect->width = h_advance;
break;
- case PANGO_GRAVITY_EAST:
+ case PANGO2_GRAVITY_EAST:
logical_rect->y = - logical_rect->height / 2;
logical_rect->width = logical_rect->height;
break;
- case PANGO_GRAVITY_WEST:
+ case PANGO2_GRAVITY_WEST:
logical_rect->y = - logical_rect->height / 2;
logical_rect->width = - logical_rect->height;
break;
@@ -758,7 +758,7 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
g_assert_not_reached ();
}
- if (PANGO_GRAVITY_IS_IMPROPER (font->gravity))
+ if (PANGO2_GRAVITY_IS_IMPROPER (font->gravity))
{
logical_rect->height = - logical_rect->height;
logical_rect->y = - logical_rect->y;
@@ -766,17 +766,17 @@ pango_hb_font_get_glyph_extents (PangoFont *font,
}
}
-static PangoFontMetrics *
-pango_hb_font_get_metrics (PangoFont *font,
- PangoLanguage *language)
+static Pango2FontMetrics *
+pango2_hb_font_get_metrics (Pango2Font *font,
+ Pango2Language *language)
{
- PangoHbFont *self = PANGO_HB_FONT (font);
- hb_font_t *hb_font = pango_font_get_hb_font (font);
- PangoFontMetrics *metrics;
+ Pango2HbFont *self = PANGO2_HB_FONT (font);
+ hb_font_t *hb_font = pango2_font_get_hb_font (font);
+ Pango2FontMetrics *metrics;
hb_font_extents_t extents;
hb_position_t position;
- metrics = pango_font_metrics_new ();
+ metrics = pango2_font_metrics_new ();
hb_font_get_extents_for_direction (hb_font, HB_DIRECTION_LTR, &extents);
@@ -787,17 +787,17 @@ pango_hb_font_get_metrics (PangoFont *font,
if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &position) && position != 0)
metrics->underline_thickness = position;
else
- metrics->underline_thickness = PANGO_SCALE;
+ metrics->underline_thickness = PANGO2_SCALE;
if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &position) && position != 0)
metrics->underline_position = position;
else
- metrics->underline_position = - PANGO_SCALE;
+ metrics->underline_position = - PANGO2_SCALE;
if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, &position) && position != 0)
metrics->strikethrough_thickness = position;
else
- metrics->strikethrough_thickness = PANGO_SCALE;
+ metrics->strikethrough_thickness = PANGO2_SCALE;
if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &position) && position != 0)
metrics->strikethrough_position = position;
@@ -806,7 +806,7 @@ pango_hb_font_get_metrics (PangoFont *font,
if (self->approximate_char_width == 0 || self->approximate_char_lang != language)
{
- self->approximate_char_width = get_average_char_width (font, pango_language_get_sample_string (language));
+ self->approximate_char_width = get_average_char_width (font, pango2_language_get_sample_string (language));
self->approximate_char_lang = language;
}
@@ -820,10 +820,10 @@ pango_hb_font_get_metrics (PangoFont *font,
}
static hb_font_t *
-pango_hb_font_create_hb_font (PangoFont *font)
+pango2_hb_font_create_hb_font (Pango2Font *font)
{
- PangoHbFont *self = PANGO_HB_FONT (font);
- PangoHbFace *face = PANGO_HB_FACE (font->face);
+ Pango2HbFont *self = PANGO2_HB_FONT (font);
+ Pango2HbFace *face = PANGO2_HB_FACE (font->face);
hb_font_t *hb_font;
double x_scale, y_scale;
unsigned int n_axes;
@@ -831,23 +831,23 @@ pango_hb_font_create_hb_font (PangoFont *font)
float *coords;
int size;
- hb_font = hb_font_create (pango_hb_face_get_hb_face (face));
+ hb_font = hb_font_create (pango2_hb_face_get_hb_face (face));
size = font->size * font->dpi / 72.f;
x_scale = face->x_scale;
y_scale = face->y_scale;
- if (PANGO_GRAVITY_IS_IMPROPER (font->gravity))
+ if (PANGO2_GRAVITY_IS_IMPROPER (font->gravity))
{
x_scale = - x_scale;
y_scale = - y_scale;
}
hb_font_set_scale (hb_font, size * x_scale, size * y_scale);
- hb_font_set_ptem (hb_font, font->size / PANGO_SCALE);
+ hb_font_set_ptem (hb_font, font->size / PANGO2_SCALE);
#if HB_VERSION_ATLEAST (3, 3, 0)
- hb_font_set_synthetic_slant (hb_font, pango_matrix_get_slant_ratio (face->transform));
+ hb_font_set_synthetic_slant (hb_font, pango2_matrix_get_slant_ratio (face->transform));
#endif
if (face->instance_id >= 0)
@@ -879,37 +879,37 @@ pango_hb_font_create_hb_font (PangoFont *font)
}
static void
-pango_hb_font_get_transform (PangoFont *font,
- PangoMatrix *matrix)
+pango2_hb_font_get_transform (Pango2Font *font,
+ Pango2Matrix *matrix)
{
- PangoHbFace *face = PANGO_HB_FACE (font->face);
+ Pango2HbFace *face = PANGO2_HB_FACE (font->face);
if (face->transform)
{
*matrix = *face->transform;
- pango_matrix_scale (matrix, face->x_scale, face->y_scale);
+ pango2_matrix_scale (matrix, face->x_scale, face->y_scale);
}
else
- *matrix = (PangoMatrix) PANGO_MATRIX_INIT;
+ *matrix = (Pango2Matrix) PANGO2_MATRIX_INIT;
}
static void
-pango_hb_font_class_init (PangoHbFontClass *class)
+pango2_hb_font_class_init (Pango2HbFontClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- PangoFontClass *font_class = PANGO_FONT_CLASS (class);
+ Pango2FontClass *font_class = PANGO2_FONT_CLASS (class);
- object_class->finalize = pango_hb_font_finalize;
- object_class->get_property = pango_hb_font_get_property;
+ object_class->finalize = pango2_hb_font_finalize;
+ object_class->get_property = pango2_hb_font_get_property;
- font_class->describe = pango_hb_font_describe;
- font_class->get_glyph_extents = pango_hb_font_get_glyph_extents;
- font_class->get_metrics = pango_hb_font_get_metrics;
- font_class->create_hb_font = pango_hb_font_create_hb_font;
- font_class->get_transform = pango_hb_font_get_transform;
+ font_class->describe = pango2_hb_font_describe;
+ font_class->get_glyph_extents = pango2_hb_font_get_glyph_extents;
+ font_class->get_metrics = pango2_hb_font_get_metrics;
+ font_class->create_hb_font = pango2_hb_font_create_hb_font;
+ font_class->get_transform = pango2_hb_font_get_transform;
/**
- * PangoHbFont:variations: (attributes org.gtk.Property.get=pango_hb_font_get_variations)
+ * Pango2HbFont:variations: (attributes org.gtk.Property.get=pango2_hb_font_get_variations)
*
* The variations that are applied for this font.
*
@@ -926,9 +926,9 @@ pango_hb_font_class_init (PangoHbFontClass *class)
/* {{{ Public API */
/**
- * pango_hb_font_new:
- * @face: the `PangoHbFace` to use
- * @size: the desired size in points, scaled by `PANGO_SCALE`
+ * pango2_hb_font_new:
+ * @face: the `Pango2HbFace` to use
+ * @size: the desired size in points, scaled by `PANGO2_SCALE`
* @features: (nullable) (array length=n_features): OpenType font features to use for this font
* @n_features: length of @features
* @variations: (nullable) (array length=n_variations): font variations to apply
@@ -937,37 +937,37 @@ pango_hb_font_class_init (PangoHbFontClass *class)
* @dpi: the dpi used when rendering
* @ctm: (nullable): transformation matrix to use when rendering
*
- * Creates a new `PangoHbFont`.
+ * Creates a new `Pango2HbFont`.
*
- * Returns: a newly created `PangoHbFont`
+ * Returns: a newly created `Pango2HbFont`
*/
-PangoHbFont *
-pango_hb_font_new (PangoHbFace *face,
- int size,
- hb_feature_t *features,
- unsigned int n_features,
- hb_variation_t *variations,
- unsigned int n_variations,
- PangoGravity gravity,
- float dpi,
- const PangoMatrix *ctm)
+Pango2HbFont *
+pango2_hb_font_new (Pango2HbFace *face,
+ int size,
+ hb_feature_t *features,
+ unsigned int n_features,
+ hb_variation_t *variations,
+ unsigned int n_variations,
+ Pango2Gravity gravity,
+ float dpi,
+ const Pango2Matrix *ctm)
{
- PangoHbFont *self;
- PangoFont *font;
+ Pango2HbFont *self;
+ Pango2Font *font;
- g_return_val_if_fail (PANGO_IS_HB_FACE (face), NULL);
+ g_return_val_if_fail (PANGO2_IS_HB_FACE (face), NULL);
g_return_val_if_fail (size > 0, NULL);
g_return_val_if_fail (dpi > 0, NULL);
- self = g_object_new (PANGO_TYPE_HB_FONT, NULL);
+ self = g_object_new (PANGO2_TYPE_HB_FONT, NULL);
- font = PANGO_FONT (self);
+ font = PANGO2_FONT (self);
- pango_font_set_face (font, PANGO_FONT_FACE (face));
- pango_font_set_size (font, size);
- pango_font_set_dpi (font, dpi);
- pango_font_set_gravity (font, gravity);
- pango_font_set_ctm (font, ctm);
+ pango2_font_set_face (font, PANGO2_FONT_FACE (face));
+ pango2_font_set_size (font, size);
+ pango2_font_set_dpi (font, dpi);
+ pango2_font_set_gravity (font, gravity);
+ pango2_font_set_ctm (font, ctm);
self->features = g_memdup2 (features, sizeof (hb_feature_t) * n_features);
self->n_features = n_features;
@@ -978,22 +978,22 @@ pango_hb_font_new (PangoHbFace *face,
}
/**
- * pango_hb_font_new_for_description:
- * @face: the `PangoHbFace` to use
- * @description: a `PangoFontDescription`
+ * pango2_hb_font_new_for_description:
+ * @face: the `Pango2HbFace` to use
+ * @description: a `Pango2FontDescription`
* @dpi: the dpi used when rendering
* @ctm: (nullable): transformation matrix to use when rendering
*
- * Creates a new `PangoHbFont` with size, features, variations and
+ * Creates a new `Pango2HbFont` with size, features, variations and
* gravity taken from a font description.
*
- * Returns: a newly created `PangoHbFont`
+ * Returns: a newly created `Pango2HbFont`
*/
-PangoHbFont *
-pango_hb_font_new_for_description (PangoHbFace *face,
- const PangoFontDescription *description,
- float dpi,
- const PangoMatrix *ctm)
+Pango2HbFont *
+pango2_hb_font_new_for_description (Pango2HbFace *face,
+ const Pango2FontDescription *description,
+ float dpi,
+ const Pango2Matrix *ctm)
{
int size;
hb_feature_t features[10];
@@ -1001,27 +1001,27 @@ pango_hb_font_new_for_description (PangoHbFace *face,
hb_variation_t *variations;
unsigned int n_variations;
unsigned int length;
- PangoGravity gravity;
+ Pango2Gravity gravity;
const char *str;
- g_return_val_if_fail (PANGO_IS_HB_FACE (face), NULL);
+ g_return_val_if_fail (PANGO2_IS_HB_FACE (face), NULL);
g_return_val_if_fail (description != NULL, NULL);
g_return_val_if_fail (dpi > 0, NULL);
- if ((pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_SIZE) == 0)
- size = 10 * PANGO_SCALE;
- else if (pango_font_description_get_size_is_absolute (description))
- size = pango_font_description_get_size (description) * 72. / dpi;
+ if ((pango2_font_description_get_set_fields (description) & PANGO2_FONT_MASK_SIZE) == 0)
+ size = 10 * PANGO2_SCALE;
+ else if (pango2_font_description_get_size_is_absolute (description))
+ size = pango2_font_description_get_size (description) * 72. / dpi;
else
- size = pango_font_description_get_size (description);
+ size = pango2_font_description_get_size (description);
g_return_val_if_fail (size > 0, NULL);
font_description_get_features (description, features, G_N_ELEMENTS (features), &n_features);
- if ((pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_VARIATIONS) != 0)
+ if ((pango2_font_description_get_set_fields (description) & PANGO2_FONT_MASK_VARIATIONS) != 0)
{
- str = pango_font_description_get_variations (description);
+ str = pango2_font_description_get_variations (description);
length = count_variations (str);
variations = g_alloca (sizeof (hb_variation_t) * length);
parse_variations (str, variations, length, &n_variations);
@@ -1032,18 +1032,18 @@ pango_hb_font_new_for_description (PangoHbFace *face,
n_variations = 0;
}
- if ((pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_GRAVITY) != 0 &&
- pango_font_description_get_gravity (description) != PANGO_GRAVITY_SOUTH)
- gravity = pango_font_description_get_gravity (description);
+ if ((pango2_font_description_get_set_fields (description) & PANGO2_FONT_MASK_GRAVITY) != 0 &&
+ pango2_font_description_get_gravity (description) != PANGO2_GRAVITY_SOUTH)
+ gravity = pango2_font_description_get_gravity (description);
else
- gravity = PANGO_GRAVITY_AUTO;
+ gravity = PANGO2_GRAVITY_AUTO;
- return pango_hb_font_new (face, size, features, n_features, variations, n_variations, gravity, dpi, ctm);
+ return pango2_hb_font_new (face, size, features, n_features, variations, n_variations, gravity, dpi, ctm);
}
/**
- * pango_hb_font_get_features:
- * @self: a `PangoFont`
+ * pango2_hb_font_get_features:
+ * @self: a `Pango2Font`
* @n_features: (nullable) (out caller-allocates): return location for
* the length of the returned array
*
@@ -1058,10 +1058,10 @@ pango_hb_font_new_for_description (PangoHbFace *face,
* Returns: (nullable) (transfer none): the features
*/
const hb_feature_t *
-pango_hb_font_get_features (PangoHbFont *self,
- unsigned int *n_features)
+pango2_hb_font_get_features (Pango2HbFont *self,
+ unsigned int *n_features)
{
- g_return_val_if_fail (PANGO_IS_HB_FONT (self), NULL);
+ g_return_val_if_fail (PANGO2_IS_HB_FONT (self), NULL);
if (n_features)
*n_features = self->n_features;
@@ -1071,8 +1071,8 @@ pango_hb_font_get_features (PangoHbFont *self,
/**
- * pango_hb_font_get_variations:
- * @self: a `PangoHbFont`
+ * pango2_hb_font_get_variations:
+ * @self: a `Pango2HbFont`
* @n_variations: (nullable) (out caller-allocates): return location for
* the length of the returned array
*
@@ -1081,10 +1081,10 @@ pango_hb_font_get_features (PangoHbFont *self,
* Returns: (nullable) (transfer none): the variations
*/
const hb_variation_t *
-pango_hb_font_get_variations (PangoHbFont *self,
- unsigned int *n_variations)
+pango2_hb_font_get_variations (Pango2HbFont *self,
+ unsigned int *n_variations)
{
- g_return_val_if_fail (PANGO_IS_HB_FONT (self), NULL);
+ g_return_val_if_fail (PANGO2_IS_HB_FONT (self), NULL);
if (n_variations)
*n_variations = self->n_variations;