mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
GtkTextView: Add fallback and letter-spacing support
Add support for the Pango attributes controlling font fallback and letter spacing to GtkTextTag. https://bugzilla.gnome.org/show_bug.cgi?id=740954
This commit is contained in:
parent
d0b7ccc2c5
commit
d184088cae
@ -378,6 +378,12 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
if (tag->priv->language_set)
|
||||
dest->language = vals->language;
|
||||
|
||||
if (tag->priv->fallback_set)
|
||||
dest->no_fallback = vals->no_fallback;
|
||||
|
||||
if (tag->priv->letter_spacing_set)
|
||||
dest->letter_spacing = vals->letter_spacing;
|
||||
|
||||
++n;
|
||||
}
|
||||
|
||||
@ -404,7 +410,8 @@ _gtk_text_tag_affects_size (GtkTextTag *tag)
|
||||
priv->tabs_set ||
|
||||
priv->underline_set ||
|
||||
priv->wrap_mode_set ||
|
||||
priv->invisible_set;
|
||||
priv->invisible_set ||
|
||||
priv->letter_spacing_set;
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -417,5 +424,6 @@ _gtk_text_tag_affects_nonsize_appearance (GtkTextTag *tag)
|
||||
priv->fg_color_set ||
|
||||
priv->strikethrough_set ||
|
||||
priv->bg_full_height_set ||
|
||||
priv->pg_bg_color_set;
|
||||
priv->pg_bg_color_set ||
|
||||
priv->fallback_set;
|
||||
}
|
||||
|
@ -210,11 +210,15 @@ struct _GtkTextAttributes
|
||||
/* can edit this text */
|
||||
guint editable : 1;
|
||||
|
||||
guint no_fallback: 1;
|
||||
|
||||
/*< private >*/
|
||||
/* Paragraph background */
|
||||
GdkRGBA *pg_bg_rgba;
|
||||
|
||||
guint padding[3];
|
||||
gint letter_spacing;
|
||||
|
||||
guint padding[2];
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -1578,6 +1578,24 @@ add_text_attrs (GtkTextLayout *layout,
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + byte_count;
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
if (style->no_fallback)
|
||||
{
|
||||
attr = pango_attr_fallback_new (!style->no_fallback);
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + byte_count;
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
|
||||
if (style->letter_spacing != 0)
|
||||
{
|
||||
attr = pango_attr_letter_spacing_new (style->letter_spacing);
|
||||
attr->start_index = start;
|
||||
attr->end_index = start + byte_count;
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,8 @@ enum {
|
||||
PROP_PARAGRAPH_BACKGROUND,
|
||||
PROP_PARAGRAPH_BACKGROUND_GDK,
|
||||
PROP_PARAGRAPH_BACKGROUND_RGBA,
|
||||
PROP_FALLBACK,
|
||||
PROP_LETTER_SPACING,
|
||||
|
||||
/* Behavior args */
|
||||
PROP_ACCUMULATIVE_MARGIN,
|
||||
@ -160,6 +162,8 @@ enum {
|
||||
PROP_TABS_SET,
|
||||
PROP_INVISIBLE_SET,
|
||||
PROP_PARAGRAPH_BACKGROUND_SET,
|
||||
PROP_FALLBACK_SET,
|
||||
PROP_LETTER_SPACING_SET,
|
||||
|
||||
LAST_ARG
|
||||
};
|
||||
@ -599,6 +603,38 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
GDK_TYPE_RGBA,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkTextTag:fallback:
|
||||
*
|
||||
* Whether font fallback is enabled.
|
||||
*
|
||||
* When set to %TRUE, other fonts will be substituted
|
||||
* where the current font is missing glyphs.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_FALLBACK,
|
||||
g_param_spec_boolean ("fallback",
|
||||
P_("Fallback"),
|
||||
P_("Whether font fallback is enabled."),
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkTextTag:letter-spacing:
|
||||
*
|
||||
* Extra spacing between graphemes, in Pango units.
|
||||
*
|
||||
* Since: 3.16
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LETTER_SPACING,
|
||||
g_param_spec_int ("letter-spacing",
|
||||
P_("Letter Spacing"),
|
||||
P_("Extra spacing between graphemes"),
|
||||
0, G_MAXINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
/**
|
||||
* GtkTextTag:accumulative-margin:
|
||||
*
|
||||
@ -726,6 +762,14 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
|
||||
P_("Paragraph background set"),
|
||||
P_("Whether this tag affects the paragraph background color"));
|
||||
|
||||
ADD_SET_PROP ("fallback-set", PROP_FALLBACK_SET,
|
||||
P_("Fallback set"),
|
||||
P_("Whether this tag affects font fallback"));
|
||||
|
||||
ADD_SET_PROP ("letter-spacing-set", PROP_LETTER_SPACING_SET,
|
||||
P_("Letter spacing set"),
|
||||
P_("Whether this tag affects letter spacing"));
|
||||
|
||||
/**
|
||||
* GtkTextTag::event:
|
||||
* @tag: the #GtkTextTag on which the signal is emitted
|
||||
@ -1450,6 +1494,18 @@ gtk_text_tag_set_property (GObject *object,
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_FALLBACK:
|
||||
priv->fallback_set = TRUE;
|
||||
priv->values->no_fallback = !g_value_get_boolean (value);
|
||||
g_object_notify (object, "fallback-set");
|
||||
break;
|
||||
|
||||
case PROP_LETTER_SPACING:
|
||||
priv->letter_spacing_set = TRUE;
|
||||
priv->values->letter_spacing = g_value_get_int (value);
|
||||
g_object_notify (object, "letter-spacing-set");
|
||||
break;
|
||||
|
||||
case PROP_ACCUMULATIVE_MARGIN:
|
||||
priv->accumulative_margin = g_value_get_boolean (value);
|
||||
g_object_notify (object, "accumulative-margin");
|
||||
@ -1763,6 +1819,14 @@ gtk_text_tag_get_property (GObject *object,
|
||||
g_value_set_boxed (value, priv->values->pg_bg_rgba);
|
||||
break;
|
||||
|
||||
case PROP_FALLBACK:
|
||||
g_value_set_boolean (value, !priv->values->no_fallback);
|
||||
break;
|
||||
|
||||
case PROP_LETTER_SPACING:
|
||||
g_value_set_int (value, priv->values->letter_spacing);
|
||||
break;
|
||||
|
||||
case PROP_ACCUMULATIVE_MARGIN:
|
||||
g_value_set_boolean (value, priv->accumulative_margin);
|
||||
break;
|
||||
@ -1861,6 +1925,14 @@ gtk_text_tag_get_property (GObject *object,
|
||||
g_value_set_boolean (value, priv->pg_bg_color_set);
|
||||
break;
|
||||
|
||||
case PROP_FALLBACK_SET:
|
||||
g_value_set_boolean (value, priv->fallback_set);
|
||||
break;
|
||||
|
||||
case PROP_LETTER_SPACING_SET:
|
||||
g_value_set_boolean (value, priv->letter_spacing_set);
|
||||
break;
|
||||
|
||||
case PROP_BACKGROUND:
|
||||
case PROP_FOREGROUND:
|
||||
case PROP_PARAGRAPH_BACKGROUND:
|
||||
|
@ -75,6 +75,8 @@ struct _GtkTextTagPrivate
|
||||
guint editable_set : 1;
|
||||
guint language_set : 1;
|
||||
guint pg_bg_color_set : 1;
|
||||
guint fallback_set : 1;
|
||||
guint letter_spacing_set : 1;
|
||||
|
||||
/* Whether these margins accumulate or override */
|
||||
guint accumulative_margin : 1;
|
||||
|
Loading…
Reference in New Issue
Block a user