summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-03-02 23:22:57 +0000
committerOwen Taylor <otaylor@src.gnome.org>2005-03-02 23:22:57 +0000
commit5c6bc9117934a13465a6db3d94a1b1803f26a930 (patch)
tree937a3be65c46fc9eb0eabff79330aff74d636fb1 /pango/fonts.c
parent570fb282bd17ff8c8b4a3514ffaf6e4751b7c161 (diff)
downloadpango-5c6bc9117934a13465a6db3d94a1b1803f26a930.tar.gz
For family names that add in numbers add a , to distinguish them from
2005-03-02 Owen Taylor <otaylor@redhat.com> * pango/fonts.c (pango_font_description_from_string_: For family names that add in numbers add a , to distinguish them from family+size (#166540, debugging/testing by Manish Singh)
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index b0b73f16..eefe07b9 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -859,6 +859,25 @@ getword (const char *str, const char *last, size_t *wordlen)
return result;
}
+static gboolean
+parse_size (const char *word,
+ size_t wordlen,
+ int *pango_size)
+{
+ char *end;
+ double size = g_ascii_strtod (word, &end);
+
+ if (end - word == wordlen) /* word is a valid float */
+ {
+ if (pango_size)
+ *pango_size = (int)(size * PANGO_SCALE + 0.5);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/**
* pango_font_description_from_string:
* @str: string representation of a font description.
@@ -912,13 +931,10 @@ pango_font_description_from_string (const char *str)
*/
if (wordlen != 0)
{
- char *end;
- double size = g_ascii_strtod (p, &end);
- if (end - p == wordlen) /* word is a valid float */
+ if (parse_size (p, wordlen, &desc->size))
{
- desc->size = (int)(size * PANGO_SCALE + 0.5);
desc->mask |= PANGO_FONT_MASK_SIZE;
- last = p;
+ last = p;
}
}
@@ -1006,9 +1022,20 @@ pango_font_description_to_string (const PangoFontDescription *desc)
size_t wordlen;
g_string_append (result, desc->family_name);
-
+
+ /* We need to add a trailing comma if the family name ends
+ * in a keyword like "Bold", or if the family name ends in
+ * a number and no keywords will be added.
+ */
p = getword (desc->family_name, desc->family_name + strlen(desc->family_name), &wordlen);
- if (wordlen != 0 && find_field_any (p, wordlen, NULL))
+ if (wordlen != 0 &&
+ (find_field_any (p, wordlen, NULL) ||
+ (parse_size (p, wordlen, NULL) &&
+ desc->weight == PANGO_WEIGHT_NORMAL &&
+ desc->style == PANGO_STYLE_NORMAL &&
+ desc->stretch == PANGO_STRETCH_NORMAL &&
+ desc->variant == PANGO_VARIANT_NORMAL &&
+ (desc->mask & PANGO_FONT_MASK_SIZE) == 0)))
g_string_append_c (result, ',');
}