diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-05-30 18:49:02 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-05-30 18:49:02 +0000 |
commit | b988bf518feb66916cbd137d62deca149b8cdcef (patch) | |
tree | 2a397a3b6c3ed0dc1928b17ff686aa32a4b25961 /pango/fonts.c | |
parent | f5692a3d420b3430deaf20ac6be3953966c4c479 (diff) | |
download | pango-b988bf518feb66916cbd137d62deca149b8cdcef.tar.gz |
Use g_strtod().
Tue May 30 14:30:24 2000 Owen Taylor <otaylor@redhat.com>
* pango/fonts.c (pango_font_description_from_string): Use g_strtod().
* pango/fonts.c (pango_font_description_to_string): Fix bug
where spaces where not properly inserted into font description
string.
* pango/fonts.c (pango_font_get_glyph_extents): Fix some
1000 <=> PANGO_SCALE bugs.
* pango/pangox-fontcache.c (pango_x_font_cache_load): Fix list
manipulation bug.
Diffstat (limited to 'pango/fonts.c')
-rw-r--r-- | pango/fonts.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index 4914c6f0..70650225 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <ctype.h> +#include <math.h> #include "pango.h" @@ -244,10 +245,10 @@ pango_font_description_from_string (const char *str) if (wordlen != 0) { char *end; - double size = strtod (p, &end); + double size = g_strtod (p, &end); if (end - p == wordlen) /* word is a valid float */ { - desc->size = (int)(size * 1000 + 0.5); + desc->size = (int)(size * PANGO_SCALE + 0.5); last = p; } } @@ -297,7 +298,7 @@ append_field (GString *str, FieldMap *map, int n_elements, int val) { if (map[i].str) { - if (str->len != 0) + if (str->len > 0 && str->str[str->len -1] != ' ') g_string_append_c (str, ' '); g_string_append (str, map[i].str); } @@ -305,7 +306,7 @@ append_field (GString *str, FieldMap *map, int n_elements, int val) } } - if (str->len != 0) + if (str->len > 0 || str->str[str->len -1] != ' ') g_string_append_c (str, ' '); g_string_sprintfa (str, "%d", val); } @@ -350,10 +351,12 @@ pango_font_description_to_string (const PangoFontDescription *desc) if (desc->size > 0) { - if (result->len == 0) + if (result->len > 0 || result->str[result->len -1] != ' ') g_string_append_c (result, ' '); - g_string_sprintfa (result, "%f", desc->size / 1000.); + /* FIXME: %g is not right here. We need to always use '. + */ + g_string_sprintfa (result, "%g", (double)desc->size / PANGO_SCALE); } str = result->str; @@ -443,7 +446,7 @@ pango_font_find_shaper (PangoFont *font, * coordinates extending to the right and down. The macros PANGO_ASCENT(), * PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING can be used to convert * from the extents rectangle to more traditional font metrics. The units - * of the rectangles are in 1000ths of a device unit. + * of the rectangles are in 1/PANGO_SCALE of a device unit. **/ void pango_font_get_glyph_extents (PangoFont *font, |