]> git.lyx.org Git - features.git/blobdiff - src/mathed/MathSupport.cpp
Cleanup of spacing in mathed
[features.git] / src / mathed / MathSupport.cpp
index 9801151129454530d7dd48141f7cf2e5ba0411d9..7769176e7aad403c6733d86c51bda8f1a4283a38 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "support/debug.h"
 #include "support/docstream.h"
+#include "support/lyxlib.h"
 
 #include <map>
 #include <algorithm>
@@ -506,6 +507,46 @@ int mathed_font_em(FontInfo const & font)
        return theFontMetrics(font).em();
 }
 
+/* The math units. Quoting TeX by Topic, p.205:
+ *
+ * Spacing around mathematical objects is measured in mu units. A mu
+ * is 1/18th part of \fontdimen6 of the font in family 2 in the
+ * current style, the ‘quad’ value of the symbol font.
+ *
+ * A \thickmuskip (default value in plain TeX: 5mu plus 5mu) is
+ * inserted around (binary) relations, except where these are preceded
+ * or followed by other relations or punctuation, and except if they
+ * follow an open, or precede a close symbol.
+ *
+ * A \medmuskip (default value in plain TeX: 4mu plus 2mu minus 4mu)
+ * is put around binary operators.
+ *
+ * A \thinmuskip (default value in plain TeX: 3mu) follows after
+ * punctuation, and is put around inner objects, except where these
+ * are followed by a close or preceded by an open symbol, and except
+ * if the other object is a large operator or a binary relation.
+ */
+
+int mathed_thinmuskip(FontInfo font)
+{
+       font.setFamily(SYMBOL_FAMILY);
+       return support::iround(3.0 / 18 * theFontMetrics(font).em());
+}
+
+
+int mathed_medmuskip(FontInfo font)
+{
+       font.setFamily(SYMBOL_FAMILY);
+       return support::iround(4.0 / 18 * theFontMetrics(font).em());
+}
+
+
+int mathed_thickmuskip(FontInfo font)
+{
+       font.setFamily(SYMBOL_FAMILY);
+       return support::iround(5.0 / 18 * theFontMetrics(font).em());
+}
+
 
 int mathed_char_width(FontInfo const & font, char_type c)
 {