Code

Added missing Pango Weights.
authortavmjong-free <tavmjong@free.fr>
Thu, 15 Apr 2010 12:34:26 +0000 (14:34 +0200)
committertavmjong-free <tavmjong@free.fr>
Thu, 15 Apr 2010 12:34:26 +0000 (14:34 +0200)
src/libnrtype/FontInstance.cpp
src/libnrtype/Layout-TNG-Output.cpp

index 50dbec61d9410bcd87f74bde5f0691d1e01c8e43..5a9aad206b4457aae91144bb45884efc20bc3f19 100644 (file)
@@ -307,17 +307,25 @@ unsigned int font_instance::Attribute(const gchar *key, gchar *str, unsigned int
                free_res=false;
        } else if ( strcmp(key,"weight") == 0 ) {
                PangoWeight v=pango_font_description_get_weight(descr);
-               if ( v <= PANGO_WEIGHT_ULTRALIGHT ) {
+               if ( v <= PANGO_WEIGHT_THIN ) {
+                       res=(char*)"100";
+               } else if ( v <= PANGO_WEIGHT_ULTRALIGHT ) {
                        res=(char*)"200";
                } else if ( v <= PANGO_WEIGHT_LIGHT ) {
                        res=(char*)"300";
+               } else if ( v <= PANGO_WEIGHT_BOOK ) {
+                       res=(char*)"380";
                } else if ( v <= PANGO_WEIGHT_NORMAL ) {
                        res=(char*)"normal";
+               } else if ( v <= PANGO_WEIGHT_MEDIUM ) {
+                       res=(char*)"500";
+               } else if ( v <= PANGO_WEIGHT_SEMIBOLD ) {
+                       res=(char*)"600";
                } else if ( v <= PANGO_WEIGHT_BOLD ) {
                        res=(char*)"bold";
                } else if ( v <= PANGO_WEIGHT_ULTRABOLD ) {
-                   res=(char*)"800";
-               } else { // HEAVY
+                       res=(char*)"800";
+               } else { // HEAVY   NB: Pango defines ULTRAHEAVY = 1000 but not CSS2
                        res=(char*)"900";
                }
                free_res=false;
index d6b68ab40585b4549affc04766282f1a056a2f83..d25eb039d34b4872a73370c606563ecd8bcad222 100644 (file)
@@ -333,13 +333,17 @@ static char const *style_to_text(PangoStyle s)
 static char const *weight_to_text(PangoWeight w)
 {
     switch (w) {
+        case PANGO_WEIGHT_THIN      : return "thin";
         case PANGO_WEIGHT_ULTRALIGHT: return "ultralight";
         case PANGO_WEIGHT_LIGHT     : return "light";
-        case PANGO_WEIGHT_SEMIBOLD  : return "semibold";
+        case PANGO_WEIGHT_BOOK      : return "book";
         case PANGO_WEIGHT_NORMAL    : return "normalweight";
+        case PANGO_WEIGHT_MEDIUM    : return "medium";
+        case PANGO_WEIGHT_SEMIBOLD  : return "semibold";
         case PANGO_WEIGHT_BOLD      : return "bold";
         case PANGO_WEIGHT_ULTRABOLD : return "ultrabold";
         case PANGO_WEIGHT_HEAVY     : return "heavy";
+        case PANGO_WEIGHT_ULTRAHEAVY: return "ultraheavy";
     }
     return "???";
 }