summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d21f068)
raw | patch | inline | side by side (parent: d21f068)
author | miklosh <miklosh@users.sourceforge.net> | |
Sun, 22 Jul 2007 20:07:18 +0000 (20:07 +0000) | ||
committer | miklosh <miklosh@users.sourceforge.net> | |
Sun, 22 Jul 2007 20:07:18 +0000 (20:07 +0000) |
src/extension/internal/pdfinput/svg-builder.cpp | patch | blob | history |
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index b17a51ea84b9d5a34aa1e95128ab93598399dac6..fc013674be3c5a534688c0eba9e024c441ff968e 100644 (file)
}
}
+/**
+ * This array holds info about translating font weight names to more or less CSS equivalents
+ */
+static char *font_weight_translator[][2] = {
+ {"bold", "bold"},
+ {"light", "300"},
+ {"black", "900"},
+ {"heavy", "900"},
+ {"ultrabold", "800"},
+ {"extrabold", "800"},
+ {"demibold", "600"},
+ {"semibold", "600"},
+ {"medium", "500"},
+ {"book", "normal"},
+ {"regular", "normal"},
+ {"roman", "normal"},
+ {"normal", "normal"},
+ {"ultralight", "200"},
+ {"extralight", "200"},
+ {"thin", "100"}
+};
+
/**
* \brief Updates _font_style according to the font set in parameter state
*/
// In a PDF font names can look like this: IONIPB+MetaPlusBold-Italic
char *font_family = NULL;
char *font_style = NULL;
+ char *font_style_lowercase = NULL;
char *plus_sign = strstr(_font_specification, "+");
if (plus_sign) {
font_family = g_strdup(plus_sign + 1);
char *minus_sign = g_strrstr(font_family, "-");
if (minus_sign) {
font_style = minus_sign + 1;
+ font_style_lowercase = g_ascii_strdown(font_style, -1);
minus_sign[0] = 0;
}
} else {
sp_repr_css_set_property(_font_style, "font-family", font_family);
}
- g_free(font_family);
// Font style
if (font->isItalic()) {
sp_repr_css_set_property(_font_style, "font-style", "italic");
+ } else if (font_style) {
+ if ( strstr(font_style_lowercase, "italic") ||
+ strstr(font_style_lowercase, "slanted") ) {
+ sp_repr_css_set_property(_font_style, "font-style", "italic");
+ } else if (strstr(font_style_lowercase, "oblique")) {
+ sp_repr_css_set_property(_font_style, "font-style", "oblique");
+ }
}
// Font variant -- default 'normal' value
weight_num[0] = (gchar)( '1' + (font_weight - GfxFont::W100) );
sp_repr_css_set_property(_font_style, "font-weight", (gchar *)&weight_num);
}
+ } else if (font_style) {
+ // Apply the font weight translations
+ int num_translations = sizeof(font_weight_translator) / ( 2 * sizeof(char *) );
+ for ( int i = 0 ; i < num_translations ; i++ ) {
+ if (strstr(font_style_lowercase, font_weight_translator[i][0])) {
+ sp_repr_css_set_property(_font_style, "font-weight",
+ font_weight_translator[i][1]);
+ }
+ }
+ }
+ g_free(font_family);
+ if (font_style_lowercase) {
+ g_free(font_style_lowercase);
}
// Font stretch