[librsvg] TextDecoration: Make this a struct of booleans, not a bitfield



commit 8da08fe5654735018489655845e49aada22e4330
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Dec 15 11:11:31 2017 -0600

    TextDecoration: Make this a struct of booleans, not a bitfield

 rsvg-styles.c | 10 ++++++----
 rsvg-styles.h | 13 +++++--------
 rsvg-text.c   |  4 ++--
 3 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/rsvg-styles.c b/rsvg-styles.c
index 5b2fb07..b8551a3 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -818,14 +818,16 @@ rsvg_parse_style_pair (RsvgState * state,
     } else if (g_str_equal (name, "text-decoration")) {
         if (g_str_equal (value, "inherit")) {
             state->has_font_decor = FALSE;
-            state->font_decor = TEXT_NORMAL;
+            state->font_decor.overline = FALSE;
+            state->font_decor.underline = FALSE;
+            state->font_decor.strike = FALSE;
         } else {
             if (strstr (value, "underline"))
-                state->font_decor |= TEXT_UNDERLINE;
+                state->font_decor.underline = TRUE;
             if (strstr (value, "overline"))
-                state->font_decor |= TEXT_OVERLINE;
+                state->font_decor.overline = TRUE;
             if (strstr (value, "strike") || strstr (value, "line-through"))     /* strike though or 
line-through */
-                state->font_decor |= TEXT_STRIKE;
+                state->font_decor.strike = TRUE;
             state->has_font_decor = TRUE;
         }
     } else if (g_str_equal (name, "direction")) {
diff --git a/rsvg-styles.h b/rsvg-styles.h
index 83738ed..7aa9f59 100644
--- a/rsvg-styles.h
+++ b/rsvg-styles.h
@@ -36,14 +36,11 @@
 
 G_BEGIN_DECLS 
 
-typedef int TextDecoration;
-
-enum {
-    TEXT_NORMAL = 0x00,
-    TEXT_OVERLINE = 0x01,
-    TEXT_UNDERLINE = 0x02,
-    TEXT_STRIKE = 0x04
-};
+typedef struct {
+    gboolean overline;
+    gboolean underline;
+    gboolean strike;
+} TextDecoration;
 
 typedef enum {
     TEXT_ANCHOR_START,
diff --git a/rsvg-text.c b/rsvg-text.c
index e1da916..43cab01 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -604,11 +604,11 @@ rsvg_text_create_layout (RsvgDrawingCtx *ctx, const char *text)
                             pango_attr_letter_spacing_new (rsvg_length_normalize (&letter_spacing, ctx) * 
PANGO_SCALE));
 
     if (state->has_font_decor) {
-        if (state->font_decor & TEXT_UNDERLINE) {
+        if (state->font_decor.underline) {
             pango_attr_list_insert (attr_list,
                                     pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
         }
-       if (state->font_decor & TEXT_STRIKE) {
+       if (state->font_decor.strike) {
             pango_attr_list_insert (attr_list,
                                     pango_attr_strikethrough_new (TRUE));
        }


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