forked from AuroraMiddleware/gtk
textview: Add line height plumbing
This adds a line-height property to GtkTexttag and a line_height field to GtkTextAttributes, and translates it to a pango attribute.
This commit is contained in:
parent
bbd2b255a3
commit
66b297e408
@ -387,6 +387,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
|
||||
if (tag->priv->pixels_inside_wrap_set)
|
||||
dest->pixels_inside_wrap = vals->pixels_inside_wrap;
|
||||
|
||||
if (tag->priv->line_height_set)
|
||||
dest->line_height = vals->line_height;
|
||||
|
||||
if (tag->priv->tabs_set)
|
||||
{
|
||||
if (dest->tabs)
|
||||
@ -457,6 +460,7 @@ _gtk_text_tag_affects_size (GtkTextTag *tag)
|
||||
priv->pixels_above_lines_set ||
|
||||
priv->pixels_below_lines_set ||
|
||||
priv->pixels_inside_wrap_set ||
|
||||
priv->line_height_set ||
|
||||
priv->tabs_set ||
|
||||
priv->underline_set ||
|
||||
priv->overline_set ||
|
||||
|
@ -147,6 +147,8 @@ struct _GtkTextAttributes
|
||||
int pixels_below_lines;
|
||||
int pixels_inside_wrap;
|
||||
|
||||
float line_height;
|
||||
|
||||
int letter_spacing;
|
||||
|
||||
guint invisible : 1;
|
||||
|
@ -1551,7 +1551,7 @@ add_generic_attrs (GtkTextLayout *layout,
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
|
||||
if (!size_only)
|
||||
{
|
||||
attr = gtk_text_attr_appearance_new (appearance);
|
||||
@ -1638,6 +1638,17 @@ add_text_attrs (GtkTextLayout *layout,
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
#if PANGO_VERSION_CHECK(1, 49, 0)
|
||||
if (style->line_height != 0.0)
|
||||
{
|
||||
attr = pango_attr_line_height_new (style->line_height);
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + byte_count;
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (style->font_features)
|
||||
{
|
||||
attr = pango_attr_font_features_new (style->font_features);
|
||||
@ -1673,7 +1684,6 @@ add_text_attrs (GtkTextLayout *layout,
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -107,6 +107,7 @@ enum {
|
||||
PROP_PIXELS_ABOVE_LINES,
|
||||
PROP_PIXELS_BELOW_LINES,
|
||||
PROP_PIXELS_INSIDE_WRAP,
|
||||
PROP_LINE_HEIGHT,
|
||||
PROP_EDITABLE,
|
||||
PROP_WRAP_MODE,
|
||||
PROP_JUSTIFICATION,
|
||||
@ -150,6 +151,7 @@ enum {
|
||||
PROP_PIXELS_ABOVE_LINES_SET,
|
||||
PROP_PIXELS_BELOW_LINES_SET,
|
||||
PROP_PIXELS_INSIDE_WRAP_SET,
|
||||
PROP_LINE_HEIGHT_SET,
|
||||
PROP_EDITABLE_SET,
|
||||
PROP_WRAP_MODE_SET,
|
||||
PROP_JUSTIFICATION_SET,
|
||||
@ -596,6 +598,21 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkTexTag:line-height:
|
||||
*
|
||||
* Factor to scale line height by.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LINE_HEIGHT,
|
||||
g_param_spec_float ("line-height",
|
||||
P_("Line height factor"),
|
||||
P_("The factor to apply to line height"),
|
||||
0.0, 10.0, 0.0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkTextTag:strikethrough:
|
||||
*
|
||||
@ -936,6 +953,10 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
P_("Pixels inside wrap set"),
|
||||
P_("Whether this tag affects the number of pixels between wrapped lines"));
|
||||
|
||||
ADD_SET_PROP ("line-height-set", PROP_LINE_HEIGHT_SET,
|
||||
P_("Line height set"),
|
||||
P_("Whether this tag affects the height of lines"));
|
||||
|
||||
ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET,
|
||||
P_("Strikethrough set"),
|
||||
P_("Whether this tag affects strikethrough"));
|
||||
@ -1573,6 +1594,13 @@ gtk_text_tag_set_property (GObject *object,
|
||||
size_changed = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_LINE_HEIGHT:
|
||||
priv->line_height_set = TRUE;
|
||||
priv->values->line_height = g_value_get_float (value);
|
||||
g_object_notify (object, "line-height-set");
|
||||
size_changed = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
priv->editable_set = TRUE;
|
||||
priv->values->editable = g_value_get_boolean (value);
|
||||
@ -2022,6 +2050,10 @@ gtk_text_tag_get_property (GObject *object,
|
||||
g_value_set_int (value, priv->values->pixels_inside_wrap);
|
||||
break;
|
||||
|
||||
case PROP_LINE_HEIGHT:
|
||||
g_value_set_float (value, priv->values->line_height);
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE:
|
||||
g_value_set_boolean (value, priv->values->editable);
|
||||
break;
|
||||
@ -2169,6 +2201,10 @@ gtk_text_tag_get_property (GObject *object,
|
||||
g_value_set_boolean (value, priv->pixels_inside_wrap_set);
|
||||
break;
|
||||
|
||||
case PROP_LINE_HEIGHT_SET:
|
||||
g_value_set_boolean (value, priv->line_height_set);
|
||||
break;
|
||||
|
||||
case PROP_EDITABLE_SET:
|
||||
g_value_set_boolean (value, priv->editable_set);
|
||||
break;
|
||||
|
@ -71,6 +71,7 @@ struct _GtkTextTagPrivate
|
||||
guint pixels_above_lines_set : 1;
|
||||
guint pixels_below_lines_set : 1;
|
||||
guint pixels_inside_wrap_set : 1;
|
||||
guint line_height_set : 1;
|
||||
guint tabs_set : 1;
|
||||
guint underline_set : 1;
|
||||
guint overline_set : 1;
|
||||
|
Loading…
Reference in New Issue
Block a user