mirror of https://github.com/GNOME/gimp.git
be smarter about finding trailing numbers that look like sizes, so we
2005-02-21 Manish Singh <yosh@gimp.org> * app/text/gimpfont-utils.[ch]: be smarter about finding trailing numbers that look like sizes, so we don't have spurious commas. * app/text/gimpfontlist.c: As an optimization, figure out if pango needs a workaround, and if not, just call it directly.
This commit is contained in:
parent
9cccf4168c
commit
9676e99884
|
@ -1,3 +1,11 @@
|
|||
2005-02-21 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/text/gimpfont-utils.[ch]: be smarter about finding trailing
|
||||
numbers that look like sizes, so we don't have spurious commas.
|
||||
|
||||
* app/text/gimpfontlist.c: As an optimization, figure out if
|
||||
pango needs a workaround, and if not, just call it directly.
|
||||
|
||||
2005-02-21 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-callbacks.c
|
||||
|
|
|
@ -30,26 +30,52 @@
|
|||
|
||||
/* Workaround pango bug #166540 */
|
||||
|
||||
gchar *
|
||||
gimp_font_util_pango_font_description_to_string (PangoFontDescription *desc)
|
||||
static const char *
|
||||
getword (const char *str, const char *last, size_t *wordlen)
|
||||
{
|
||||
gchar *name;
|
||||
gchar last_char;
|
||||
const char *result;
|
||||
|
||||
while (last > str && g_ascii_isspace (*(last - 1)))
|
||||
last--;
|
||||
|
||||
result = last;
|
||||
while (result > str && !g_ascii_isspace (*(result - 1)))
|
||||
result--;
|
||||
|
||||
*wordlen = last - result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gimp_font_util_pango_font_description_to_string (const PangoFontDescription *desc)
|
||||
{
|
||||
gchar *name;
|
||||
size_t wordlen;
|
||||
const gchar *p;
|
||||
|
||||
g_return_val_if_fail (desc != NULL, NULL);
|
||||
|
||||
name = pango_font_description_to_string (desc);
|
||||
|
||||
last_char = name[strlen (name) - 1];
|
||||
p = getword (name, name + strlen (name), &wordlen);
|
||||
|
||||
if (g_ascii_isdigit (last_char) || last_char == '.')
|
||||
if (wordlen)
|
||||
{
|
||||
gchar *new_name;
|
||||
gchar *end;
|
||||
gdouble size;
|
||||
|
||||
new_name = g_strconcat (name, ",", NULL);
|
||||
g_free (name);
|
||||
size = g_ascii_strtod (p, &end);
|
||||
|
||||
name = new_name;
|
||||
if (end - p == wordlen)
|
||||
{
|
||||
gchar *new_name;
|
||||
|
||||
new_name = g_strconcat (name, ",", NULL);
|
||||
g_free (name);
|
||||
|
||||
name = new_name;
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
|
|
|
@ -25,9 +25,12 @@
|
|||
|
||||
/* This is solely to workaround pango bug #166540, by tacking on a ',' to
|
||||
* font names that end in numbers, so pango_font_description_from_string
|
||||
* doesn't interpret it as a size
|
||||
* doesn't interpret it as a size. Note that this doesn't fully workaround
|
||||
* problems pango has with font name serialization, just only the bad size
|
||||
* interpretation. Family names that end with style names are still
|
||||
* processed wrongly.
|
||||
*/
|
||||
gchar * gimp_font_util_pango_font_description_to_string (PangoFontDescription *desc);
|
||||
gchar * gimp_font_util_pango_font_description_to_string (const PangoFontDescription *desc);
|
||||
|
||||
|
||||
#endif /* __GIMP_FONT_UTILS_H__ */
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
#endif
|
||||
|
||||
|
||||
typedef char * (* GimpFontDescToStringFunc) (const PangoFontDescription *desc);
|
||||
|
||||
|
||||
static void gimp_font_list_class_init (GimpFontListClass *klass);
|
||||
static void gimp_font_list_init (GimpFontList *list);
|
||||
|
||||
|
@ -63,6 +66,8 @@ static void gimp_font_list_load_names (GimpFontList *list,
|
|||
|
||||
static GimpListClass *parent_class = NULL;
|
||||
|
||||
static GimpFontDescToStringFunc font_desc_to_string = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_font_list_get_type (void)
|
||||
|
@ -126,11 +131,32 @@ gimp_font_list_new (gdouble xresolution,
|
|||
void
|
||||
gimp_font_list_restore (GimpFontList *list)
|
||||
{
|
||||
PangoFontMap *fontmap;
|
||||
PangoContext *context;
|
||||
PangoFontMap *fontmap;
|
||||
PangoContext *context;
|
||||
|
||||
g_return_if_fail (GIMP_IS_FONT_LIST (list));
|
||||
|
||||
if (font_desc_to_string == NULL)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
gchar *name;
|
||||
gchar last_char;
|
||||
|
||||
desc = pango_font_description_new ();
|
||||
pango_font_description_set_family (desc, "Wilber 12");
|
||||
|
||||
name = pango_font_description_to_string (desc);
|
||||
last_char = name[strlen (name) - 1];
|
||||
|
||||
g_free (name);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
if (last_char != ',')
|
||||
font_desc_to_string = &gimp_font_util_pango_font_description_to_string;
|
||||
else
|
||||
font_desc_to_string = &pango_font_description_to_string;
|
||||
}
|
||||
|
||||
fontmap = pango_ft2_font_map_new ();
|
||||
pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap),
|
||||
list->xresolution, list->yresolution);
|
||||
|
@ -159,7 +185,7 @@ gimp_font_list_add_font (GimpFontList *list,
|
|||
if (! desc)
|
||||
return;
|
||||
|
||||
name = gimp_font_util_pango_font_description_to_string (desc);
|
||||
name = font_desc_to_string (desc);
|
||||
|
||||
if (! g_utf8_validate (name, -1, NULL))
|
||||
{
|
||||
|
@ -261,7 +287,7 @@ gimp_font_list_load_names (GimpFontList *list,
|
|||
FcFontSetDestroy (fontset);
|
||||
}
|
||||
|
||||
#else /* ! USE_FONTCONFIG_DIRECTLY */
|
||||
#else /* ! USE_FONTCONFIG_DIRECTLY */
|
||||
|
||||
static void
|
||||
gimp_font_list_load_names (GimpFontList *list,
|
||||
|
@ -293,4 +319,4 @@ gimp_font_list_load_names (GimpFontList *list,
|
|||
g_free (families);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* USE_FONTCONFIG_DIRECTLY */
|
||||
|
|
Loading…
Reference in New Issue