summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-03-02 23:23:07 +0000
committerOwen Taylor <otaylor@src.gnome.org>2005-03-02 23:23:07 +0000
commit3c1328ced0d4388f27ad403be9369aeadb76cca1 (patch)
tree6b19ecd7ea64f828a64d2a4cbb2b0228c8787a9f
parent55f827e5976eb19dc3be543da4b9076b04750e4f (diff)
downloadpango-3c1328ced0d4388f27ad403be9369aeadb76cca1.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)
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-1-107
-rw-r--r--pango/fonts.c41
3 files changed, 48 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 04ccf3c7..bcc78740 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
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)
+
+2005-03-02 Owen Taylor <otaylor@redhat.com>
+
* pango/pango-attributes.c (pango_attr_iterator_get_attrs):
Fix various typos in the docs (#163244, Morten Welinder)
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 04ccf3c7..bcc78740 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,5 +1,12 @@
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)
+
+2005-03-02 Owen Taylor <otaylor@redhat.com>
+
* pango/pango-attributes.c (pango_attr_iterator_get_attrs):
Fix various typos in the docs (#163244, Morten Welinder)
diff --git a/pango/fonts.c b/pango/fonts.c
index 12752762..68fd2df3 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, ',');
}