[gtk/small-text-fixes: 4/4] gtk: Pass font options along




commit 6c89dbf0b7f928d69cead00113e7a8661384f558
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Sep 3 07:21:15 2021 -0400

    gtk: Pass font options along
    
    Pass the widget's font options along when we
    are creating text nodes.

 gtk/gskpango.c           |  5 +++++
 gtk/gskpango.h           |  2 ++
 gtk/gtksnapshot.c        | 22 ++++++++++++----------
 gtk/gtksnapshotprivate.h | 13 +++++++------
 4 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gskpango.c b/gtk/gskpango.c
index e96c84a2fc..93aba75f60 100644
--- a/gtk/gskpango.c
+++ b/gtk/gskpango.c
@@ -100,6 +100,7 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer  *renderer,
   get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
 
   gtk_snapshot_append_text (crenderer->snapshot,
+                            crenderer->options,
                             glyph_item->item->analysis.font,
                             glyph_item->glyphs,
                             &color,
@@ -467,14 +468,18 @@ gtk_snapshot_append_layout (GtkSnapshot   *snapshot,
                             const GdkRGBA *color)
 {
   GskPangoRenderer *crenderer;
+  PangoContext *context;
 
   g_return_if_fail (snapshot != NULL);
   g_return_if_fail (PANGO_IS_LAYOUT (layout));
 
   crenderer = gsk_pango_renderer_acquire ();
 
+  context = pango_layout_get_context (layout);
+
   crenderer->snapshot = snapshot;
   crenderer->fg_color = color;
+  crenderer->options = pango_cairo_context_get_font_options (context);
 
   pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
 
diff --git a/gtk/gskpango.h b/gtk/gskpango.h
index 672128d1c1..05fa2254a0 100644
--- a/gtk/gskpango.h
+++ b/gtk/gskpango.h
@@ -63,6 +63,8 @@ struct _GskPangoRenderer
   /* Error underline color for this widget */
   GdkRGBA               *error_color;
 
+  const cairo_font_options_t  *options;
+
   GskPangoRendererState  state;
 
   guint                  is_cached_renderer : 1;
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 5ebb37f14f..b3935f5ff7 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -2121,22 +2121,24 @@ gtk_snapshot_render_layout (GtkSnapshot     *snapshot,
 }
 
 void
-gtk_snapshot_append_text (GtkSnapshot           *snapshot,
-                          PangoFont             *font,
-                          PangoGlyphString      *glyphs,
-                          const GdkRGBA         *color,
-                          float                  x,
-                          float                  y)
+gtk_snapshot_append_text (GtkSnapshot                *snapshot,
+                          const cairo_font_options_t *options,
+                          PangoFont                  *font,
+                          PangoGlyphString           *glyphs,
+                          const GdkRGBA              *color,
+                          float                       x,
+                          float                       y)
 {
   GskRenderNode *node;
   float dx, dy;
 
   gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
 
-  node = gsk_text_node_new (font,
-                            glyphs,
-                            color,
-                            &GRAPHENE_POINT_INIT (x + dx, y + dy));
+  node = gsk_text_node_new_full (options,
+                                 font,
+                                 glyphs,
+                                 color,
+                                 &GRAPHENE_POINT_INIT (x + dx, y + dy));
   if (node == NULL)
     return;
 
diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h
index 99714c5a99..ca32df1a52 100644
--- a/gtk/gtksnapshotprivate.h
+++ b/gtk/gtksnapshotprivate.h
@@ -24,12 +24,13 @@
 
 G_BEGIN_DECLS
 
-void                    gtk_snapshot_append_text                (GtkSnapshot            *snapshot,
-                                                                 PangoFont              *font,
-                                                                 PangoGlyphString       *glyphs,
-                                                                 const GdkRGBA          *color,
-                                                                 float                   x,
-                                                                 float                   y);
+void                    gtk_snapshot_append_text                (GtkSnapshot                *snapshot,
+                                                                 const cairo_font_options_t *options,
+                                                                 PangoFont                  *font,
+                                                                 PangoGlyphString           *glyphs,
+                                                                 const GdkRGBA              *color,
+                                                                 float                       x,
+                                                                 float                       y);
 
 void                    gtk_snapshot_push_collect               (GtkSnapshot            *snapshot);
 GskRenderNode *         gtk_snapshot_pop_collect                (GtkSnapshot            *snapshot);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]