[vte] fonts: Improve font bolding



commit 05fb6061fb962fee09085f5d7c9f9fd27202e2c6
Author: Christian Persch <chpe src gnome org>
Date:   Sat Oct 9 20:16:05 2021 +0200

    fonts: Improve font bolding
    
    Embolden the font by adding to its weight, not just overwriting the
    weight with PANGO_WEIGHT_BOLD.

 src/drawing-cairo.cc | 8 +++++++-
 src/vtedefines.hh    | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/drawing-cairo.cc b/src/drawing-cairo.cc
index a606fd46..0a1cdae1 100644
--- a/src/drawing-cairo.cc
+++ b/src/drawing-cairo.cc
@@ -152,7 +152,13 @@ DrawingContext::set_text_font(GtkWidget* widget,
 
        /* calculate bold font desc */
        bolddesc = pango_font_description_copy (fontdesc);
-       pango_font_description_set_weight (bolddesc, PANGO_WEIGHT_BOLD);
+        if (pango_font_description_get_set_fields(bolddesc) & PANGO_FONT_MASK_WEIGHT) {
+                auto const weight = pango_font_description_get_weight(bolddesc);
+                auto const bold_weight = std::min(1000, weight + VTE_FONT_WEIGHT_BOLDENING);
+                pango_font_description_set_weight(bolddesc, PangoWeight(bold_weight));
+        } else {
+                pango_font_description_set_weight (bolddesc, PANGO_WEIGHT_BOLD);
+        }
 
        /* calculate italic font desc */
        italicdesc = pango_font_description_copy (fontdesc);
diff --git a/src/vtedefines.hh b/src/vtedefines.hh
index fe8d6e97..7f2e478a 100644
--- a/src/vtedefines.hh
+++ b/src/vtedefines.hh
@@ -154,3 +154,5 @@
 
 #define VTE_MIN_GRID_WIDTH (2) /* space for one wide character */
 #define VTE_MIN_GRID_HEIGHT (1)
+
+#define VTE_FONT_WEIGHT_BOLDENING (PANGO_WEIGHT_BOLD - PANGO_WEIGHT_NORMAL)


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