[pango/pango2: 77/168] layout: Rename line-spacing to line-height
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 77/168] layout: Rename line-spacing to line-height
- Date: Wed, 8 Jun 2022 10:22:17 +0000 (UTC)
commit 18e9a2691982e77a106c12e70326fed209946ce8
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jan 23 22:54:21 2022 -0500
layout: Rename line-spacing to line-height
This matches better with the CSS terminology,
and reduces the clash with the spacing property
that is about to come back.
Update all callers.
pango/pango-layout.c | 63 +++++++++++++++++++++++++++------------------------
pango/pango-layout.h | 6 ++---
pango/serializer.c | 12 +++++-----
tests/testserialize.c | 4 ++--
utils/viewer-render.c | 2 +-
5 files changed, 46 insertions(+), 41 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index ced0e9c1..05247339 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -67,7 +67,7 @@ struct _PangoLayout
int length;
PangoAttrList *attrs;
PangoFontDescription *font_desc;
- float line_spacing;
+ float line_height;
int width;
int height;
PangoTabArray *tabs;
@@ -94,7 +94,7 @@ enum
PROP_TEXT,
PROP_ATTRIBUTES,
PROP_FONT_DESCRIPTION,
- PROP_LINE_SPACING,
+ PROP_LINE_HEIGHT,
PROP_WIDTH,
PROP_HEIGHT,
PROP_TABS,
@@ -122,7 +122,7 @@ pango_layout_init (PangoLayout *layout)
layout->wrap = PANGO_WRAP_WORD;
layout->alignment = PANGO_ALIGN_NATURAL;
layout->ellipsize = PANGO_ELLIPSIZE_NONE;
- layout->line_spacing = 0.0;
+ layout->line_height = 0.0;
layout->auto_dir = TRUE;
layout->text = g_strdup ("");
layout->length = 0;
@@ -170,8 +170,8 @@ pango_layout_set_property (GObject *object,
pango_layout_set_font_description (layout, g_value_get_boxed (value));
break;
- case PROP_LINE_SPACING:
- pango_layout_set_line_spacing (layout, g_value_get_float (value));
+ case PROP_LINE_HEIGHT:
+ pango_layout_set_line_height (layout, g_value_get_float (value));
break;
case PROP_WIDTH:
@@ -242,8 +242,8 @@ pango_layout_get_property (GObject *object,
g_value_set_boxed (value, layout->font_desc);
break;
- case PROP_LINE_SPACING:
- g_value_set_float (value, layout->line_spacing);
+ case PROP_LINE_HEIGHT:
+ g_value_set_float (value, layout->line_height);
break;
case PROP_WIDTH:
@@ -340,13 +340,18 @@ pango_layout_class_init (PangoLayoutClass *class)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
- * PangoLayout:line-spacing: (attributes org.gtk.Property.get=pango_layout_get_line_spacing
org.gtk.Property.set=pango_layout_set_line_spacing)
+ * PangoLayout:line-height: (attributes org.gtk.Property.get=pango_layout_get_line_height
org.gtk.Property.set=pango_layout_set_line_height)
*
- * The line spacing factor of the `PangoLayout`.
+ * The line height factor of the `PangoLayout`.
+ *
+ * If non-zero, the line height is multiplied by this factor to determine
+ * the logical extents of the text.
+ *
+ * The default value is 0.
*/
- props[PROP_LINE_SPACING] = g_param_spec_float ("line-spacing", "line-spacing", "line-spacing",
- 0., G_MAXFLOAT, 0.,
- G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ props[PROP_LINE_HEIGHT] = g_param_spec_float ("line-height", "line-height", "line-height",
+ 0., G_MAXFLOAT, 0.,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* PangoLayout:width: (attributes org.gtk.Property.get=pango_layout_get_width
org.gtk.Property.set=pango_layout_set_width)
@@ -549,11 +554,11 @@ get_effective_attributes (PangoLayout *layout)
pango_attr_font_desc_new (layout->font_desc));
}
- if (layout->line_spacing != 0.0)
+ if (layout->line_height != 0.0)
{
attrs = ensure_attrs (layout, attrs);
pango_attr_list_insert_before (attrs,
- pango_attr_line_height_new (layout->line_spacing));
+ pango_attr_line_height_new (layout->line_height));
}
if (layout->single_paragraph)
@@ -797,7 +802,7 @@ pango_layout_copy (PangoLayout *layout)
copy->attrs = pango_attr_list_copy (layout->attrs);
if (layout->font_desc)
copy->font_desc = pango_font_description_copy (layout->font_desc);
- copy->line_spacing = layout->line_spacing;
+ copy->line_height = layout->line_height;
copy->width = layout->width;
copy->height = layout->height;
if (layout->tabs)
@@ -1014,15 +1019,15 @@ pango_layout_get_font_description (PangoLayout *layout)
}
/**
- * pango_layout_set_line_spacing:
+ * pango_layout_set_line_height:
* @layout: a `PangoLayout`
- * @line_spacing: the new line spacing factor
+ * @line_height: the new line height factor
*
- * Sets a factor for line spacing.
+ * Sets a factor for line height.
*
* Typical values are: 0, 1, 1.5, 2. The default values is 0.
*
- * If @line_spacing is non-zero, lines are placed so that
+ * If @line_height is non-zero, lines are placed so that
*
* baseline2 = baseline1 + factor * height2
*
@@ -1032,34 +1037,34 @@ pango_layout_get_font_description (PangoLayout *layout)
* This method is a shorthand for adding a line-height attribute.
*/
void
-pango_layout_set_line_spacing (PangoLayout *layout,
- float line_spacing)
+pango_layout_set_line_height (PangoLayout *layout,
+ float line_height)
{
g_return_if_fail (PANGO_IS_LAYOUT (layout));
- if (layout->line_spacing == line_spacing)
+ if (layout->line_height == line_height)
return;
- layout->line_spacing = line_spacing;
+ layout->line_height = line_height;
- g_object_notify_by_pspec (G_OBJECT (layout), props[PROP_LINE_SPACING]);
+ g_object_notify_by_pspec (G_OBJECT (layout), props[PROP_LINE_HEIGHT]);
layout_changed (layout);
}
/**
- * pango_layout_get_line_spacing:
+ * pango_layout_get_line_height:
* @layout: a `PangoLayout`
*
- * Gets the line spacing factor of @layout.
+ * Gets the line height factor of the layout.
*
- * See [method@Pango.Layout.set_line_spacing].
+ * See [method@Pango.Layout.set_line_height].
*/
float
-pango_layout_get_line_spacing (PangoLayout *layout)
+pango_layout_get_line_height (PangoLayout *layout)
{
g_return_val_if_fail (PANGO_IS_LAYOUT (layout), 0.0);
- return layout->line_spacing;
+ return layout->line_height;
}
/**
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index 0c3e7c02..1a30b68c 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -62,12 +62,12 @@ const PangoFontDescription *
(PangoLayout *layout);
PANGO_AVAILABLE_IN_ALL
-void pango_layout_set_line_spacing
+void pango_layout_set_line_height
(PangoLayout *layout,
- float line_spacing);
+ float line_height);
PANGO_AVAILABLE_IN_ALL
-float pango_layout_get_line_spacing
+float pango_layout_get_line_height
(PangoLayout *layout);
PANGO_AVAILABLE_IN_ALL
diff --git a/pango/serializer.c b/pango/serializer.c
index 6f2efec8..ba387d5d 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -825,8 +825,8 @@ layout_to_json (GtkJsonPrinter *printer,
if (pango_layout_get_indent (layout) != 0)
gtk_json_printer_add_integer (printer, "indent", pango_layout_get_indent (layout));
- if (pango_layout_get_line_spacing (layout) != 0.)
- gtk_json_printer_add_number (printer, "line-spacing", pango_layout_get_line_spacing (layout));
+ if (pango_layout_get_line_height (layout) != 0.)
+ gtk_json_printer_add_number (printer, "line-height", pango_layout_get_line_height (layout));
if (flags & PANGO_LAYOUT_SERIALIZE_OUTPUT)
{
@@ -1400,7 +1400,7 @@ enum {
LAYOUT_WIDTH,
LAYOUT_HEIGHT,
LAYOUT_INDENT,
- LAYOUT_LINE_SPACING,
+ LAYOUT_LINE_HEIGHT,
LAYOUT_LINES
};
@@ -1418,7 +1418,7 @@ static const char *layout_members[] = {
"width",
"height",
"indent",
- "line-spacing",
+ "line-height",
"lines",
NULL
};
@@ -1473,8 +1473,8 @@ json_parser_fill_layout (GtkJsonParser *parser,
pango_layout_set_auto_dir (layout, gtk_json_parser_get_boolean (parser));
break;
- case LAYOUT_LINE_SPACING:
- pango_layout_set_line_spacing (layout, gtk_json_parser_get_number (parser));
+ case LAYOUT_LINE_HEIGHT:
+ pango_layout_set_line_height (layout, gtk_json_parser_get_number (parser));
break;
case LAYOUT_TABS:
diff --git a/tests/testserialize.c b/tests/testserialize.c
index 0219d91a..d20f5a89 100644
--- a/tests/testserialize.c
+++ b/tests/testserialize.c
@@ -267,7 +267,7 @@ test_serialize_layout_valid (void)
" },\n"
" \"alignment\" : \"center\",\n"
" \"width\" : 350000,\n"
- " \"line-spacing\" : 1.5\n"
+ " \"line-height\" : 1.5\n"
"}\n";
PangoContext *context;
@@ -292,7 +292,7 @@ test_serialize_layout_valid (void)
g_free (s);
g_assert_cmpint (pango_layout_get_alignment (layout), ==, PANGO_ALIGN_CENTER);
g_assert_cmpint (pango_layout_get_width (layout), ==, 350000);
- g_assert_cmpfloat_with_epsilon (pango_layout_get_line_spacing (layout), 1.5, 0.0001);
+ g_assert_cmpfloat_with_epsilon (pango_layout_get_line_height (layout), 1.5, 0.0001);
out_bytes = pango_layout_serialize (layout, PANGO_LAYOUT_SERIALIZE_DEFAULT);
diff --git a/utils/viewer-render.c b/utils/viewer-render.c
index e0b37d7e..c162f28a 100644
--- a/utils/viewer-render.c
+++ b/utils/viewer-render.c
@@ -162,7 +162,7 @@ make_layout(PangoContext *context,
}
if (opt_line_spacing >= 0.0)
- pango_layout_set_line_spacing (layout, (float)opt_line_spacing);
+ pango_layout_set_line_height (layout, (float)opt_line_spacing);
align = opt_align;
if (align != PANGO_ALIGN_CENTER &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]