Code

Added/Fixed Pango font weights. Included Jon's workaround for Pango
authortavmjong-free <tavmjong@free.fr>
Sun, 18 Apr 2010 07:24:32 +0000 (09:24 +0200)
committertavmjong-free <tavmjong@free.fr>
Sun, 18 Apr 2010 07:24:32 +0000 (09:24 +0200)
older than 1.24.

src/libnrtype/Layout-TNG-Input.cpp

index fb2769edc6f80e32377658529051f030cb8e3892..d16c6457dfbe3fa827da86fb9467940338fb6bf6 100644 (file)
 #include "sp-string.h"
 #include "FontFactory.h"
 
+#if !PANGO_VERSION_CHECK(1,24,0)
+#define PANGO_WEIGHT_THIN       static_cast<PangoWeight>(100)
+#define PANGO_WEIGHT_BOOK       static_cast<PangoWeight>(380)
+#define PANGO_WEIGHT_MEDIUM     static_cast<PangoWeight>(500)
+#define PANGO_WEIGHT_ULTRAHEAVY static_cast<PangoWeight>(1000)
+#endif
+
 namespace Inkscape {
 namespace Text {
 
@@ -237,18 +244,16 @@ static const Layout::EnumConversionItem enum_convert_spstyle_style_to_pango_styl
     {SP_CSS_FONT_STYLE_OBLIQUE, PANGO_STYLE_OBLIQUE}};
 
 static const Layout::EnumConversionItem enum_convert_spstyle_weight_to_pango_weight[] = {
+  // NB: The Pango web page calls 500 "the normal font" but both CSS2 and the Pango
+  // enumeration define 400 as normal.
     {SP_CSS_FONT_WEIGHT_NORMAL, PANGO_WEIGHT_NORMAL},
-    {SP_CSS_FONT_WEIGHT_100, PANGO_WEIGHT_ULTRALIGHT},
+    {SP_CSS_FONT_WEIGHT_BOLD,PANGO_WEIGHT_BOLD},
+    {SP_CSS_FONT_WEIGHT_100, PANGO_WEIGHT_THIN},
     {SP_CSS_FONT_WEIGHT_200, PANGO_WEIGHT_ULTRALIGHT},
     {SP_CSS_FONT_WEIGHT_300, PANGO_WEIGHT_LIGHT},
     {SP_CSS_FONT_WEIGHT_400, PANGO_WEIGHT_NORMAL},
-#if GTK_CHECK_VERSION(2,6,0)
-    {SP_CSS_FONT_WEIGHT_500, PANGO_WEIGHT_SEMIBOLD},
-#else 
-    {SP_CSS_FONT_WEIGHT_500, PANGO_WEIGHT_NORMAL},
-#endif
-    {SP_CSS_FONT_WEIGHT_600, PANGO_WEIGHT_BOLD},
-    {SP_CSS_FONT_WEIGHT_BOLD,PANGO_WEIGHT_BOLD},
+    {SP_CSS_FONT_WEIGHT_500, PANGO_WEIGHT_MEDIUM},
+    {SP_CSS_FONT_WEIGHT_600, PANGO_WEIGHT_SEMIBOLD},
     {SP_CSS_FONT_WEIGHT_700, PANGO_WEIGHT_BOLD},
     {SP_CSS_FONT_WEIGHT_800, PANGO_WEIGHT_ULTRABOLD},
     {SP_CSS_FONT_WEIGHT_900, PANGO_WEIGHT_HEAVY}};