Merge branch 'small-caps' into 'master'

Handle new pango api

See merge request GNOME/gtk!4137
This commit is contained in:
Matthias Clasen 2021-11-08 19:39:55 +00:00
commit 20fd760a52
7 changed files with 196 additions and 163 deletions

View File

@ -48,7 +48,7 @@ if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
fi
pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.49.1 pango; then
if ! pkg-config --atleast-version=1.49.3 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango
meson compile -C _pango_build

View File

@ -94,13 +94,12 @@ show_page (GtkTextView *text_view,
gtk_text_buffer_insert (buffer, &iter, " can easily be realized with ", -1);
insert_link (buffer, &iter, "tags", 2);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert (buffer, &iter,
"Of course you can also embed Emoji 😋, "
"icons ", -1);
gtk_text_buffer_insert (buffer, &iter, "Of course you can also embed Emoji 😋, ", -1);
gtk_text_buffer_insert (buffer, &iter, "icons ", -1);
theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (text_view)));
icon = gtk_icon_theme_lookup_icon (theme,
"microphone-sensitivity-high-symbolic",
"eye-not-looking-symbolic",
NULL,
16,
1,

View File

@ -44,6 +44,16 @@ pango_variant_to_string (PangoVariant variant)
return "normal";
case PANGO_VARIANT_SMALL_CAPS:
return "small_caps";
case PANGO_VARIANT_ALL_SMALL_CAPS:
return "all_small_caps";
case PANGO_VARIANT_PETITE_CAPS:
return "petite_caps";
case PANGO_VARIANT_ALL_PETITE_CAPS:
return "all_petite_caps";
case PANGO_VARIANT_UNICASE:
return "unicase";
case PANGO_VARIANT_TITLE_CAPS:
return "title_caps";
default:
g_assert_not_reached ();
}

View File

@ -513,31 +513,6 @@ gtk_css_style_compute_font_features (GtkCssStyle *style)
break;
}
switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps))
{
case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS:
append_separated (&s, "smcp 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS:
append_separated (&s, "c2sc 1, smcp 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS:
append_separated (&s, "pcap 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS:
append_separated (&s, "c2pc 1, pcap 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_UNICASE:
append_separated (&s, "unic 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS:
append_separated (&s, "titl 1");
break;
case GTK_CSS_FONT_VARIANT_CAPS_NORMAL:
default:
break;
}
numeric = _gtk_css_font_variant_numeric_value_get (style->font_variant->font_variant_numeric);
if (numeric == GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL)
{
@ -675,6 +650,32 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
}
}
/* casing variants */
switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps))
{
case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS));
break;
case GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_ALL_SMALL_CAPS));
break;
case GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_PETITE_CAPS));
break;
case GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_ALL_PETITE_CAPS));
break;
case GTK_CSS_FONT_VARIANT_CAPS_UNICASE:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_UNICASE));
break;
case GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS:
attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_TITLE_CAPS));
break;
case GTK_CSS_FONT_VARIANT_CAPS_NORMAL:
default:
break;
}
/* OpenType features */
{
char *font_features = gtk_css_style_compute_font_features (style);

View File

@ -1192,6 +1192,21 @@ pango_font_description_to_css (PangoFontDescription *desc,
case PANGO_VARIANT_SMALL_CAPS:
g_string_append (s, "font-variant: small-caps; ");
break;
case PANGO_VARIANT_ALL_SMALL_CAPS:
g_string_append (s, "font-variant: all-small-caps; ");
break;
case PANGO_VARIANT_PETITE_CAPS:
g_string_append (s, "font-variant: petite-caps; ");
break;
case PANGO_VARIANT_ALL_PETITE_CAPS:
g_string_append (s, "font-variant: all-petite-caps; ");
break;
case PANGO_VARIANT_UNICASE:
g_string_append (s, "font-variant: unicase; ");
break;
case PANGO_VARIANT_TITLE_CAPS:
g_string_append (s, "font-variant: titling-caps; ");
break;
default:
break;
}

View File

@ -4409,6 +4409,8 @@ gtk_text_view_allocate_children (GtkTextView *text_view)
{
const AnchoredChild *child = iter->data;
GtkTextIter child_loc;
GtkRequisition child_req;
GtkAllocation allocation;
/* We need to force-validate the regions containing children. */
gtk_text_buffer_get_iter_at_child_anchor (get_buffer (text_view),
@ -4429,6 +4431,15 @@ gtk_text_view_allocate_children (GtkTextView *text_view)
}
gtk_text_layout_validate_yrange (priv->layout, &child_loc, 0, 1);
gtk_widget_get_preferred_size (child->widget, &child_req, NULL);
allocation.x = - child_req.width;
allocation.y = - child_req.height;
allocation.width = child_req.width;
allocation.height = child_req.height;
gtk_widget_size_allocate (child->widget, &allocation, -1);
}
}
@ -5910,9 +5921,6 @@ gtk_text_view_snapshot (GtkWidget *widget,
snapshot_text_view_child (widget, priv->bottom_child, snapshot);
snapshot_text_view_child (widget, priv->center_child, snapshot);
/* Propagate exposes to all unanchored children.
* Anchored children are handled in gtk_text_view_paint().
*/
for (iter = priv->anchored_children.head; iter; iter = iter->next)
{
const AnchoredChild *vc = iter->data;

View File

@ -11,7 +11,7 @@ project('gtk', 'c',
license: 'LGPL-2.1-or-later')
glib_req = '>= 2.66.0'
pango_req = '>= 1.49.1' # keep this in sync with .gitlab-ci/test-msys.sh
pango_req = '>= 1.49.3' # keep this in sync with .gitlab-ci/test-msys.sh
fribidi_req = '>= 0.19.7'
cairo_req = '>= 1.14.0'
gdk_pixbuf_req = '>= 2.30.0'