[gtksourceview/wip/chergert/glyph-alignment: 13/13] map: use new textview API to fix glyph alignment
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/glyph-alignment: 13/13] map: use new textview API to fix glyph alignment
- Date: Tue, 22 Jun 2021 06:39:52 +0000 (UTC)
commit becafce05af48452680e231d69a17c7bbdc7f33f
Author: Christian Hergert <chergert redhat com>
Date: Sat Jun 19 12:38:48 2021 -0700
map: use new textview API to fix glyph alignment
This helps reduce the amount of grid lines we see across the font from
pixel alignment in text rendering. Our font is a bit special, in that we
know how it needs to be rendered to give the effect we're looking for.
Depends on https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3690
gtksourceview/gtksourcemap.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/gtksourceview/gtksourcemap.c b/gtksourceview/gtksourcemap.c
index 3350a0c3..6af138cd 100644
--- a/gtksourceview/gtksourcemap.c
+++ b/gtksourceview/gtksourcemap.c
@@ -1097,6 +1097,32 @@ gtk_source_map_hide (GtkWidget *widget)
}
}
+static void
+gtk_source_map_css_changed (GtkWidget *widget,
+ GtkCssStyleChange *change)
+{
+ g_assert (GTK_IS_WIDGET (widget));
+
+ GTK_WIDGET_CLASS (gtk_source_map_parent_class)->css_changed (widget, change);
+
+#if GTK_CHECK_VERSION(4,3,1)
+ {
+ PangoContext *rtl_context;
+ PangoContext *ltr_context;
+
+ /* Ensure rounding so that BuilderBlocks aligns properly within
+ * rounding errors between glyphs.
+ */
+
+ rtl_context = gtk_text_view_get_rtl_context (GTK_TEXT_VIEW (widget));
+ ltr_context = gtk_text_view_get_ltr_context (GTK_TEXT_VIEW (widget));
+
+ pango_context_set_round_glyph_positions (rtl_context, TRUE);
+ pango_context_set_round_glyph_positions (ltr_context, TRUE);
+ }
+#endif
+}
+
static void
gtk_source_map_constructed (GObject *object)
{
@@ -1124,6 +1150,7 @@ gtk_source_map_class_init (GtkSourceMapClass *klass)
widget_class->show = gtk_source_map_show;
widget_class->state_flags_changed = gtk_source_map_state_flags_changed;
widget_class->realize = gtk_source_map_realize;
+ widget_class->css_changed = gtk_source_map_css_changed;
text_view_class->snapshot_layer = gtk_source_map_snapshot_layer;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]