From 0aa7c9aa764335098e0880410a1821b4c330fb7e Mon Sep 17 00:00:00 2001 From: tavmjong-free Date: Thu, 15 Apr 2010 14:34:26 +0200 Subject: [PATCH] Added missing Pango Weights. --- src/libnrtype/FontInstance.cpp | 14 +++++++++++--- src/libnrtype/Layout-TNG-Output.cpp | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 50dbec61d..5a9aad206 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -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; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index d6b68ab40..d25eb039d 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -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 "???"; } -- 2.30.2