summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-11-02 14:21:20 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-11-02 14:21:20 +0000
commit191e2b1d55c2b93726a092b5eb4d7114af277197 (patch)
tree07703e6f8f7f5ec3ea1c47a6be0f333de2644f7b /pango
parent22865210cbef2f0d1c0d5f481e798390f1b4f059 (diff)
downloadpango-191e2b1d55c2b93726a092b5eb4d7114af277197.tar.gz
Patch from Darin Adler, with updates, to use g_ascii_* instead of
Fri Nov 2 08:50:16 2001 Owen Taylor <otaylor@redhat.com> * pango/{fonts.c,pango-color.c,pango-utils.c, pangoft2-fontmap.c,pangowin32-fontcache.c, pangowin32-fontmap.c, pangox-fontmap.c}: Patch from Darin Adler, with updates, to use g_ascii_* instead of locale-dependent variants (#55833). * pango/fonts.c: Use g_ascii_dtostr, g_ascii_strtod().
Diffstat (limited to 'pango')
-rw-r--r--pango/fonts.c25
-rw-r--r--pango/pango-color.c2
-rw-r--r--pango/pango-utils.c54
-rw-r--r--pango/pangoft2-fontmap.c8
-rw-r--r--pango/pangowin32-fontcache.c20
-rw-r--r--pango/pangowin32-fontmap.c6
-rw-r--r--pango/pangox-fontmap.c4
7 files changed, 60 insertions, 59 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 084f0250..941f6e5d 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -610,7 +610,7 @@ pango_font_description_equal (const PangoFontDescription *desc1,
desc1->stretch == desc2->stretch &&
desc1->size == desc2->size &&
(desc1->family_name == desc2->family_name ||
- (desc1->family_name && desc2->family_name && g_strcasecmp (desc1->family_name, desc2->family_name) == 0)));
+ (desc1->family_name && desc2->family_name && g_ascii_strcasecmp (desc1->family_name, desc2->family_name) == 0)));
}
/**
@@ -728,7 +728,7 @@ find_field (FieldMap *map, int n_elements, const char *str, int len, int *val)
for (i=0; i<n_elements; i++)
{
- if (map[i].str && g_strncasecmp (map[i].str, str, len) == 0)
+ if (map[i].str && g_ascii_strncasecmp (map[i].str, str, len) == 0)
{
if (val)
*val = map[i].value;
@@ -742,7 +742,7 @@ find_field (FieldMap *map, int n_elements, const char *str, int len, int *val)
static gboolean
find_field_any (const char *str, int len, PangoFontDescription *desc)
{
- return (g_strcasecmp (str, "Normal") == 0 ||
+ return (g_ascii_strcasecmp (str, "Normal") == 0 ||
find_field (style_map, G_N_ELEMENTS (style_map), str, len,
desc ? (int *)&desc->style : NULL) ||
find_field (variant_map, G_N_ELEMENTS (variant_map), str, len,
@@ -822,7 +822,7 @@ pango_font_description_from_string (const char *str)
if (wordlen != 0)
{
char *end;
- double size = g_strtod (p, &end);
+ double size = g_ascii_strtod (p, &end);
if (end - p == wordlen) /* word is a valid float */
{
desc->size = (int)(size * PANGO_SCALE + 0.5);
@@ -908,7 +908,6 @@ char *
pango_font_description_to_string (const PangoFontDescription *desc)
{
GString *result = g_string_new (NULL);
- char *str;
if (desc->family_name && desc->mask & PANGO_FONT_MASK_FAMILY)
{
@@ -932,17 +931,16 @@ pango_font_description_to_string (const PangoFontDescription *desc)
if (desc->mask & PANGO_FONT_MASK_SIZE)
{
+ char buf[G_ASCII_DTOSTR_BUF_SIZE];
+
if (result->len > 0 || result->str[result->len -1] != ' ')
g_string_append_c (result, ' ');
- /* FIXME: %g is not right here. We need to always use '.
- */
- g_string_append_printf (result, "%g", (double)desc->size / PANGO_SCALE);
+ g_ascii_dtostr (buf, sizeof (buf), (double)desc->size / PANGO_SCALE);
+ g_string_append (result, buf);
}
- str = result->str;
- g_string_free (result, FALSE);
- return str;
+ return g_string_free (result, FALSE);
}
/**
@@ -962,12 +960,13 @@ pango_font_description_to_filename (const PangoFontDescription *desc)
char *result = pango_font_description_to_string (desc);
char *p;
- g_strdown (result);
p = result;
while (*p)
{
- if (strchr ("-+_.", *p) == NULL && !isalnum (*p))
+ if (strchr ("-+_.", *p) == NULL && !g_ascii_isalnum (*p))
*p = '_';
+ else
+ *p = g_ascii_tolower (*p);
p++;
}
diff --git a/pango/pango-color.c b/pango/pango-color.c
index 5a90260e..b834140b 100644
--- a/pango/pango-color.c
+++ b/pango/pango-color.c
@@ -889,7 +889,7 @@ static ColorEntry xColors[] = {
static int
compare_xcolor_entries (const void *a, const void *b)
{
- return g_strcasecmp ((const char *) a, ((const ColorEntry *) b)->name);
+ return g_ascii_strcasecmp ((const char *) a, ((const ColorEntry *) b)->name);
}
static gboolean
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index e7ee0bab..6f6db1a0 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -709,21 +709,21 @@ pango_parse_style (const char *str,
{
case 'n':
case 'N':
- if (g_strcasecmp (str, "normal") == 0)
+ if (g_ascii_strcasecmp (str, "normal") == 0)
{
*style = PANGO_STYLE_NORMAL;
return TRUE;
}
break;
case 'i':
- if (g_strcasecmp (str, "italic") == 0)
+ if (g_ascii_strcasecmp (str, "italic") == 0)
{
*style = PANGO_STYLE_ITALIC;
return TRUE;
}
break;
case 'o':
- if (g_strcasecmp (str, "oblique") == 0)
+ if (g_ascii_strcasecmp (str, "oblique") == 0)
{
*style = PANGO_STYLE_OBLIQUE;
return TRUE;
@@ -760,7 +760,7 @@ pango_parse_variant (const char *str,
{
case 'n':
case 'N':
- if (g_strcasecmp (str, "normal") == 0)
+ if (g_ascii_strcasecmp (str, "normal") == 0)
{
*variant = PANGO_VARIANT_NORMAL;
return TRUE;
@@ -768,8 +768,8 @@ pango_parse_variant (const char *str,
break;
case 's':
case 'S':
- if (g_strcasecmp (str, "small_caps") == 0 ||
- g_strcasecmp (str, "smallcaps") == 0)
+ if (g_ascii_strcasecmp (str, "small_caps") == 0 ||
+ g_ascii_strcasecmp (str, "smallcaps") == 0)
{
*variant = PANGO_VARIANT_SMALL_CAPS;
return TRUE;
@@ -806,7 +806,7 @@ pango_parse_weight (const char *str,
{
case 'b':
case 'B':
- if (g_strcasecmp (str, "bold") == 0)
+ if (g_ascii_strcasecmp (str, "bold") == 0)
{
*weight = PANGO_WEIGHT_BOLD;
return TRUE;
@@ -814,7 +814,7 @@ pango_parse_weight (const char *str,
break;
case 'h':
case 'H':
- if (g_strcasecmp (str, "heavy") == 0)
+ if (g_ascii_strcasecmp (str, "heavy") == 0)
{
*weight = PANGO_WEIGHT_HEAVY;
return TRUE;
@@ -822,7 +822,7 @@ pango_parse_weight (const char *str,
break;
case 'l':
case 'L':
- if (g_strcasecmp (str, "light") == 0)
+ if (g_ascii_strcasecmp (str, "light") == 0)
{
*weight = PANGO_WEIGHT_LIGHT;
return TRUE;
@@ -830,7 +830,7 @@ pango_parse_weight (const char *str,
break;
case 'n':
case 'N':
- if (g_strcasecmp (str, "normal") == 0)
+ if (g_ascii_strcasecmp (str, "normal") == 0)
{
*weight = PANGO_WEIGHT_NORMAL;
return TRUE;
@@ -838,12 +838,12 @@ pango_parse_weight (const char *str,
break;
case 'u':
case 'U':
- if (g_strcasecmp (str, "ultralight") == 0)
+ if (g_ascii_strcasecmp (str, "ultralight") == 0)
{
*weight = PANGO_WEIGHT_ULTRALIGHT;
return TRUE;
}
- else if (g_strcasecmp (str, "ultrabold") == 0)
+ else if (g_ascii_strcasecmp (str, "ultrabold") == 0)
{
*weight = PANGO_WEIGHT_ULTRABOLD;
return TRUE;
@@ -904,7 +904,7 @@ pango_parse_stretch (const char *str,
{
case 'c':
case 'C':
- if (g_strcasecmp (str, "condensed") == 0)
+ if (g_ascii_strcasecmp (str, "condensed") == 0)
{
*stretch = PANGO_STRETCH_CONDENSED;
return TRUE;
@@ -912,19 +912,19 @@ pango_parse_stretch (const char *str,
break;
case 'e':
case 'E':
- if (g_strcasecmp (str, "extra_condensed") == 0 ||
- g_strcasecmp (str, "extracondensed") == 0)
+ if (g_ascii_strcasecmp (str, "extra_condensed") == 0 ||
+ g_ascii_strcasecmp (str, "extracondensed") == 0)
{
*stretch = PANGO_STRETCH_EXTRA_CONDENSED;
return TRUE;
}
- if (g_strcasecmp (str, "extra_expanded") == 0 ||
- g_strcasecmp (str, "extraexpanded") == 0)
+ if (g_ascii_strcasecmp (str, "extra_expanded") == 0 ||
+ g_ascii_strcasecmp (str, "extraexpanded") == 0)
{
*stretch = PANGO_STRETCH_EXTRA_EXPANDED;
return TRUE;
}
- if (g_strcasecmp (str, "expanded") == 0)
+ if (g_ascii_strcasecmp (str, "expanded") == 0)
{
*stretch = PANGO_STRETCH_EXPANDED;
return TRUE;
@@ -932,7 +932,7 @@ pango_parse_stretch (const char *str,
break;
case 'n':
case 'N':
- if (g_strcasecmp (str, "normal") == 0)
+ if (g_ascii_strcasecmp (str, "normal") == 0)
{
*stretch = PANGO_STRETCH_NORMAL;
return TRUE;
@@ -940,14 +940,14 @@ pango_parse_stretch (const char *str,
break;
case 's':
case 'S':
- if (g_strcasecmp (str, "semi_condensed") == 0 ||
- g_strcasecmp (str, "semicondensed") == 0)
+ if (g_ascii_strcasecmp (str, "semi_condensed") == 0 ||
+ g_ascii_strcasecmp (str, "semicondensed") == 0)
{
*stretch = PANGO_STRETCH_SEMI_CONDENSED;
return TRUE;
}
- if (g_strcasecmp (str, "semi_expanded") == 0 ||
- g_strcasecmp (str, "semiexpanded") == 0)
+ if (g_ascii_strcasecmp (str, "semi_expanded") == 0 ||
+ g_ascii_strcasecmp (str, "semiexpanded") == 0)
{
*stretch = PANGO_STRETCH_SEMI_EXPANDED;
return TRUE;
@@ -955,14 +955,14 @@ pango_parse_stretch (const char *str,
break;
case 'u':
case 'U':
- if (g_strcasecmp (str, "ultra_condensed") == 0 ||
- g_strcasecmp (str, "ultracondensed") == 0)
+ if (g_ascii_strcasecmp (str, "ultra_condensed") == 0 ||
+ g_ascii_strcasecmp (str, "ultracondensed") == 0)
{
*stretch = PANGO_STRETCH_ULTRA_CONDENSED;
return TRUE;
}
- if (g_strcasecmp (str, "ultra_expanded") == 0 ||
- g_strcasecmp (str, "ultraexpanded") == 0)
+ if (g_ascii_strcasecmp (str, "ultra_expanded") == 0 ||
+ g_ascii_strcasecmp (str, "ultraexpanded") == 0)
{
*stretch = PANGO_STRETCH_ULTRA_EXPANDED;
return TRUE;
diff --git a/pango/pangoft2-fontmap.c b/pango/pangoft2-fontmap.c
index 1419347e..6690da38 100644
--- a/pango/pangoft2-fontmap.c
+++ b/pango/pangoft2-fontmap.c
@@ -205,10 +205,10 @@ pango_ft2_is_font_file (const char *name)
len = strlen (name);
if (len > 4 &&
- (g_strncasecmp (&name[len-4], ".pfa", 4) == 0 ||
- g_strncasecmp (&name[len-4], ".pfb", 4) == 0 ||
- g_strncasecmp (&name[len-4], ".ttf", 4) == 0 ||
- g_strncasecmp (&name[len-4], ".ttc", 4) == 0))
+ (g_ascii_strncasecmp (&name[len-4], ".pfa", 4) == 0 ||
+ g_ascii_strncasecmp (&name[len-4], ".pfb", 4) == 0 ||
+ g_ascii_strncasecmp (&name[len-4], ".ttf", 4) == 0 ||
+ g_ascii_strncasecmp (&name[len-4], ".ttc", 4) == 0))
return TRUE;
return FALSE;
diff --git a/pango/pangowin32-fontcache.c b/pango/pangowin32-fontcache.c
index a99e84d7..8bdf15d3 100644
--- a/pango/pangowin32-fontcache.c
+++ b/pango/pangowin32-fontcache.c
@@ -210,33 +210,33 @@ pango_win32_font_cache_load (PangoWin32FontCache *cache,
/* If we fail, try some similar fonts often found on Windows. */
if (tries == 0)
{
- if (g_strcasecmp (lf.lfFaceName, "helvetica") == 0)
+ if (g_ascii_strcasecmp (lf.lfFaceName, "helvetica") == 0)
strcpy (lf.lfFaceName, "arial");
- else if (g_strcasecmp (lf.lfFaceName, "new century schoolbook") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "new century schoolbook") == 0)
strcpy (lf.lfFaceName, "century schoolbook");
- else if (g_strcasecmp (lf.lfFaceName, "courier") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "courier") == 0)
strcpy (lf.lfFaceName, "courier new");
- else if (g_strcasecmp (lf.lfFaceName, "lucida") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "lucida") == 0)
strcpy (lf.lfFaceName, "lucida sans unicode");
- else if (g_strcasecmp (lf.lfFaceName, "lucidatypewriter") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "lucidatypewriter") == 0)
strcpy (lf.lfFaceName, "lucida console");
- else if (g_strcasecmp (lf.lfFaceName, "times") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "times") == 0)
strcpy (lf.lfFaceName, "times new roman");
}
else if (tries == 1)
{
- if (g_strcasecmp (lf.lfFaceName, "courier") == 0)
+ if (g_ascii_strcasecmp (lf.lfFaceName, "courier") == 0)
{
strcpy (lf.lfFaceName, "");
lf.lfPitchAndFamily |= FF_MODERN;
}
- else if (g_strcasecmp (lf.lfFaceName, "times new roman") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "times new roman") == 0)
{
strcpy (lf.lfFaceName, "");
lf.lfPitchAndFamily |= FF_ROMAN;
}
- else if (g_strcasecmp (lf.lfFaceName, "helvetica") == 0
- || g_strcasecmp (lf.lfFaceName, "lucida") == 0)
+ else if (g_ascii_strcasecmp (lf.lfFaceName, "helvetica") == 0
+ || g_ascii_strcasecmp (lf.lfFaceName, "lucida") == 0)
{
strcpy (lf.lfFaceName, "");
lf.lfPitchAndFamily |= FF_SWISS;
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 451649c3..7dbefe24 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -725,7 +725,7 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
*/
lfp2 = g_new (LOGFONT, 1);
*lfp2 = *lfp;
- g_strdown (lfp2->lfFaceName);
+ lfp2->lfFaceName = g_ascii_strdown (lfp2->lfFaceName, -1);
size_info = g_hash_table_lookup (win32fontmap->size_infos, lfp);
if (!size_info)
{
@@ -740,7 +740,7 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
/* Convert the LOGFONT into a PangoFontDescription */
- family_name = g_strdup (lfp2->lfFaceName);
+ family_name = lfp2->lfFaceName;
if (!lfp2->lfItalic)
style = PANGO_STYLE_NORMAL;
@@ -803,7 +803,7 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
win32face->coverage = NULL;
win32face->logfont = *lfp;
win32face->unicode_table = NULL;
- g_strdown (win32face->logfont.lfFaceName);
+ win32face->logfont.lfFaceName = g_ascii_strdown (lfp->lfFaceName, -1);
font_family->font_entries = g_slist_append (font_family->font_entries, win32face);
win32fontmap->n_fonts++;
diff --git a/pango/pangox-fontmap.c b/pango/pangox-fontmap.c
index 213aa251..c2c4a116 100644
--- a/pango/pangox-fontmap.c
+++ b/pango/pangox-fontmap.c
@@ -981,6 +981,7 @@ pango_x_get_xlfd_field (const char *fontname,
char *buffer)
{
const char *t1, *t2;
+ char *p;
int countdown, len, num_dashes;
if (!fontname)
@@ -1010,7 +1011,8 @@ pango_x_get_xlfd_field (const char *fontname,
strncpy (buffer, t1, len);
buffer[len] = 0;
/* Convert to lower case. */
- g_strdown (buffer);
+ for (p = buffer; *p; p++)
+ *p = g_ascii_tolower (*p);
}
else
strcpy(buffer, "(nil)");