[gtk/matthiasc/for-main] pango_font_description_to_css: Handle numeric weight
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-main] pango_font_description_to_css: Handle numeric weight
- Date: Thu, 14 Jul 2022 19:50:16 +0000 (UTC)
commit f8945b6325c4b0b896aabd123c16096aa01649cf
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 14 09:46:05 2022 -0400
pango_font_description_to_css: Handle numeric weight
The PangoWeight enum agrees with the numeric values
we use here, so we can do this without a switch and
support numeric weight values at the same time.
gtk/gtkfontbutton.c | 39 ++-------------------------------------
1 file changed, 2 insertions(+), 37 deletions(-)
---
diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c
index 3cd42e161c..4b80b9fe22 100644
--- a/gtk/gtkfontbutton.c
+++ b/gtk/gtkfontbutton.c
@@ -1206,43 +1206,8 @@ pango_font_description_to_css (PangoFontDescription *desc,
}
}
if (set & PANGO_FONT_MASK_WEIGHT)
- {
- switch (pango_font_description_get_weight (desc))
- {
- case PANGO_WEIGHT_THIN:
- g_string_append (s, "font-weight: 100; ");
- break;
- case PANGO_WEIGHT_ULTRALIGHT:
- g_string_append (s, "font-weight: 200; ");
- break;
- case PANGO_WEIGHT_LIGHT:
- case PANGO_WEIGHT_SEMILIGHT:
- g_string_append (s, "font-weight: 300; ");
- break;
- case PANGO_WEIGHT_BOOK:
- case PANGO_WEIGHT_NORMAL:
- g_string_append (s, "font-weight: 400; ");
- break;
- case PANGO_WEIGHT_MEDIUM:
- g_string_append (s, "font-weight: 500; ");
- break;
- case PANGO_WEIGHT_SEMIBOLD:
- g_string_append (s, "font-weight: 600; ");
- break;
- case PANGO_WEIGHT_BOLD:
- g_string_append (s, "font-weight: 700; ");
- break;
- case PANGO_WEIGHT_ULTRABOLD:
- g_string_append (s, "font-weight: 800; ");
- break;
- case PANGO_WEIGHT_HEAVY:
- case PANGO_WEIGHT_ULTRAHEAVY:
- g_string_append (s, "font-weight: 900; ");
- break;
- default:
- break;
- }
- }
+ g_string_append_printf (s, "font-weight: %d; ", pango_font_description_get_weight (desc));
+
if (set & PANGO_FONT_MASK_STRETCH)
{
switch (pango_font_description_get_stretch (desc))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]