[lasem] Implement the negative* spacing constants



commit d9bf7c93b0c302d4b552dbc8e6d6448897567982
Author: Garen Torikian <gjtorikian gmail com>
Date:   Wed Jun 3 22:11:01 2015 +0200

    Implement the negative* spacing constants
    
    In addition to the existing positive spacing rules defined, MathML
    also has the notion of negative spacing rules:
    https://developer.mozilla.org/en-US/docs/Web/MathML/Attribute/Values

 src/lsmmathmlattributes.c   |   22 ++++++++++++
 src/lsmmathmlenums.c        |    8 ++++
 src/lsmmathmlenums.h        |    7 ++++
 src/lsmmathmlmathelement.c  |   10 +++++-
 src/lsmmathmlstyle.h        |    8 ++++
 src/lsmmathmlstyleelement.c |   78 +++++++++++++++++++++++++++++++++++++++++++
 src/lsmmathmlstyleelement.h |    7 ++++
 src/lsmmathmltraits.h       |    8 ++++
 8 files changed, 147 insertions(+), 1 deletions(-)
---
diff --git a/src/lsmmathmlattributes.c b/src/lsmmathmlattributes.c
index f9b698b..d35661e 100644
--- a/src/lsmmathmlattributes.c
+++ b/src/lsmmathmlattributes.c
@@ -124,6 +124,28 @@ lsm_mathml_space_attribute_normalize (LsmMathmlSpaceAttribute *attribute,
        g_return_val_if_fail (space != NULL, 0.0);
 
        switch (space->name) {
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_VERY_THIN:
+                       attribute->value = style->negative_very_very_thin_math_space;
+                       break;
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_THIN:
+                       attribute->value = style->negative_very_thin_math_space;
+                       break;
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_THIN:
+                       attribute->value = style->negative_thin_math_space;
+                       break;
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_MEDIUM:
+                       attribute->value = style->negative_medium_math_space;
+                       break;
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_THICK:
+                       attribute->value = style->negative_thick_math_space;
+                       break;
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_THICK:
+                       attribute->value = style->negative_very_thick_math_space;
+                       break;
+               case LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_VERY_THICK:
+                       attribute->value = style->negative_very_very_thick_math_space;
+                       break;
+
                case LSM_MATHML_SPACE_NAME_VERY_VERY_THIN:
                        attribute->value = style->very_very_thin_math_space;
                        break;
diff --git a/src/lsmmathmlenums.c b/src/lsmmathmlenums.c
index 944e54d..3dc6861 100644
--- a/src/lsmmathmlenums.c
+++ b/src/lsmmathmlenums.c
@@ -68,6 +68,14 @@ lsm_mathml_display_from_string (const char *string)
 }
 
 static const char *lsm_mathml_space_name_strings[] = {
+       "negativeveryverythinmathspace",
+       "negativeverythinmathspace",
+       "negativethinmathspace",
+       "negativemediummathspace",
+       "negativethickmathspace",
+       "negativeverythickmathspace",
+       "negativeveryverythickmathspace",
+
        "veryverythinmathspace",
        "verythinmathspace",
        "thinmathspace",
diff --git a/src/lsmmathmlenums.h b/src/lsmmathmlenums.h
index 1beebdb..b4d9768 100644
--- a/src/lsmmathmlenums.h
+++ b/src/lsmmathmlenums.h
@@ -55,6 +55,13 @@ LsmMathmlDisplay     lsm_mathml_display_from_string          (const char *string);
 
 typedef enum {
        LSM_MATHML_SPACE_NAME_ERROR = -1,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_VERY_THIN,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_THIN,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_THIN,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_MEDIUM,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_THICK,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_THICK,
+       LSM_MATHML_SPACE_NAME_NEGATIVE_VERY_VERY_THICK,
        LSM_MATHML_SPACE_NAME_VERY_VERY_THIN,
        LSM_MATHML_SPACE_NAME_VERY_THIN,
        LSM_MATHML_SPACE_NAME_THIN,
diff --git a/src/lsmmathmlmathelement.c b/src/lsmmathmlmathelement.c
index b98d57f..7ca2545 100644
--- a/src/lsmmathmlmathelement.c
+++ b/src/lsmmathmlmathelement.c
@@ -1,5 +1,5 @@
 /* Lasem
- * 
+ *
  * Copyright © 2007-2008 Emmanuel Pacaud
  *
  * This library is free software; you can redistribute it and/or
@@ -130,6 +130,14 @@ lsm_mathml_math_element_init (LsmMathmlMathElement *self)
        style->script_size_multiplier = 0.71;
        style->script_min_size = 8.0;
 
+       style->negative_very_very_thin_math_space =     LSM_MATHML_SPACE_EM_NEGATIVE_VERY_VERY_THIN * 
style->math_size;
+       style->negative_very_thin_math_space =          LSM_MATHML_SPACE_EM_NEGATIVE_VERY_THIN * 
style->math_size;
+       style->negative_thin_math_space =               LSM_MATHML_SPACE_EM_NEGATIVE_THIN * style->math_size;
+       style->negative_medium_math_space =             LSM_MATHML_SPACE_EM_NEGATIVE_MEDIUM * 
style->math_size;
+       style->negative_thick_math_space =              LSM_MATHML_SPACE_EM_NEGATIVE_THICK * style->math_size;
+       style->negative_very_thick_math_space =                 LSM_MATHML_SPACE_EM_NEGATIVE_VERY_THICK * 
style->math_size;
+       style->negative_very_very_thick_math_space =    LSM_MATHML_SPACE_EM_NEGATIVE_VERY_VERY_THICK * 
style->math_size;
+
        style->very_very_thin_math_space =      LSM_MATHML_SPACE_EM_VERY_VERY_THIN * style->math_size;
        style->very_thin_math_space =           LSM_MATHML_SPACE_EM_VERY_THIN * style->math_size;
        style->thin_math_space =                LSM_MATHML_SPACE_EM_THIN * style->math_size;
diff --git a/src/lsmmathmlstyle.h b/src/lsmmathmlstyle.h
index 0acf93b..c2529b3 100644
--- a/src/lsmmathmlstyle.h
+++ b/src/lsmmathmlstyle.h
@@ -41,6 +41,14 @@ struct _LsmMathmlStyle {
        double script_size_multiplier;
        double script_min_size;
 
+       double negative_very_very_thin_math_space;
+       double negative_very_thin_math_space;
+       double negative_thin_math_space;
+       double negative_medium_math_space;
+       double negative_thick_math_space;
+       double negative_very_thick_math_space;
+       double negative_very_very_thick_math_space;
+
        double very_very_thin_math_space;
        double very_thin_math_space;
        double thin_math_space;
diff --git a/src/lsmmathmlstyleelement.c b/src/lsmmathmlstyleelement.c
index 2108af4..da63375 100644
--- a/src/lsmmathmlstyleelement.c
+++ b/src/lsmmathmlstyleelement.c
@@ -84,6 +84,42 @@ lsm_mathml_style_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
 
        /* mstyle */
 
+       length.value = style->negative_very_very_thin_math_space;
+       style->negative_very_very_thin_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_very_very_thin_math_space,
+                                                      style->negative_very_very_thin_math_space,
+                                                      &length, style);
+       length.value = style->negative_very_thin_math_space;
+       style->negative_very_thin_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_very_thin_math_space,
+                                                      style->negative_very_thin_math_space,
+                                                      &length, style);
+       length.value = style->negative_thin_math_space;
+       style->negative_thin_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_thin_math_space,
+                                                      style->negative_thin_math_space,
+                                                      &length, style);
+       length.value = style->negative_medium_math_space;
+       style->negative_medium_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_medium_math_space,
+                                                      style->negative_medium_math_space,
+                                                      &length, style);
+       length.value = style->negative_thick_math_space;
+       style->negative_thick_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_thick_math_space,
+                                                      style->negative_thick_math_space,
+                                                      &length, style);
+       length.value = style->negative_very_thick_math_space;
+       style->negative_very_thick_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_very_thick_math_space,
+                                                      style->negative_very_thick_math_space,
+                                                      &length, style);
+       length.value = style->negative_very_very_thick_math_space;
+       style->negative_very_very_thick_math_space =
+               lsm_mathml_length_attribute_normalize (&style_element->negative_very_very_thick_math_space,
+                                                      style->negative_very_very_thick_math_space,
+                                                      &length, style);
+
        length.value = style->very_very_thin_math_space;
        style->very_very_thin_math_space =
                lsm_mathml_length_attribute_normalize (&style_element->very_very_thin_math_space,
@@ -183,6 +219,48 @@ static const LsmAttributeInfos _attribute_infos[] = {
                .trait_class = &lsm_mathml_double_trait_class
        },
        {
+               .name = "negativeveryverythinmathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_very_very_thin_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
+               .name = "negativeverythinmathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_very_thin_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
+               .name = "negativethinmathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_thin_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
+               .name = "negativemediummathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_medium_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
+               .name = "negativethickmathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_thick_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
+               .name = "negativeverythickmathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_very_thick_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
+               .name = "negativeveryverythickmathspace",
+               .attribute_offset = offsetof (LsmMathmlStyleElement, negative_very_very_thick_math_space),
+               .trait_class = &lsm_mathml_length_trait_class,
+               .trait_default = &length_default
+       },
+       {
                .name = "veryverythinmathspace",
                .attribute_offset = offsetof (LsmMathmlStyleElement, very_very_thin_math_space),
                .trait_class = &lsm_mathml_length_trait_class,
diff --git a/src/lsmmathmlstyleelement.h b/src/lsmmathmlstyleelement.h
index 71d8ae0..34f218d 100644
--- a/src/lsmmathmlstyleelement.h
+++ b/src/lsmmathmlstyleelement.h
@@ -47,6 +47,13 @@ struct _LsmMathmlStyleElement {
        LsmMathmlScriptLevelAttribute script_level;
        LsmMathmlDoubleAttribute script_size_multiplier;
        LsmMathmlLengthAttribute script_min_size;
+       LsmMathmlLengthAttribute negative_very_very_thin_math_space;
+       LsmMathmlLengthAttribute negative_very_thin_math_space;
+       LsmMathmlLengthAttribute negative_thin_math_space;
+       LsmMathmlLengthAttribute negative_medium_math_space;
+       LsmMathmlLengthAttribute negative_thick_math_space;
+       LsmMathmlLengthAttribute negative_very_thick_math_space;
+       LsmMathmlLengthAttribute negative_very_very_thick_math_space;
        LsmMathmlLengthAttribute very_very_thin_math_space;
        LsmMathmlLengthAttribute very_thin_math_space;
        LsmMathmlLengthAttribute thin_math_space;
diff --git a/src/lsmmathmltraits.h b/src/lsmmathmltraits.h
index 65f23e2..4a89778 100644
--- a/src/lsmmathmltraits.h
+++ b/src/lsmmathmltraits.h
@@ -29,6 +29,14 @@
 
 G_BEGIN_DECLS
 
+#define LSM_MATHML_SPACE_EM_NEGATIVE_VERY_VERY_THIN    -0.055556
+#define LSM_MATHML_SPACE_EM_NEGATIVE_VERY_THIN         -0.111111
+#define LSM_MATHML_SPACE_EM_NEGATIVE_THIN              -0.166667
+#define LSM_MATHML_SPACE_EM_NEGATIVE_MEDIUM            -0.222222
+#define LSM_MATHML_SPACE_EM_NEGATIVE_THICK             -0.277778
+#define LSM_MATHML_SPACE_EM_NEGATIVE_VERY_THICK                -0.333333
+#define LSM_MATHML_SPACE_EM_NEGATIVE_VERY_VERY_THICK   -0.388889
+
 #define LSM_MATHML_SPACE_EM_VERY_VERY_THIN     0.055556
 #define LSM_MATHML_SPACE_EM_VERY_THIN          0.111111
 #define LSM_MATHML_SPACE_EM_THIN               0.166667


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