mirror of https://github.com/GNOME/gimp.git
app/text: nuke gimpfont-utils.[ch]
gimp_font_util_pango_font_description_to_string() isn't needed any longer as this was fixed long ago in pango itself (and we require a much higher version anyway). See Pango bug #166540 (at GNOME Bugzilla).
This commit is contained in:
parent
fa529db76b
commit
439e8b0bf1
|
@ -22,8 +22,6 @@ libapptext_a_sources = \
|
||||||
gimp-fonts.h \
|
gimp-fonts.h \
|
||||||
gimpfont.c \
|
gimpfont.c \
|
||||||
gimpfont.h \
|
gimpfont.h \
|
||||||
gimpfont-utils.c \
|
|
||||||
gimpfont-utils.h \
|
|
||||||
gimpfontlist.c \
|
gimpfontlist.c \
|
||||||
gimpfontlist.h \
|
gimpfontlist.h \
|
||||||
gimptext.c \
|
gimptext.c \
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
/* GIMP - The GNU Image Manipulation Program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* gimpfontlist.c
|
|
||||||
* Copyright (C) 2005 Manish Singh <yosh@gimp.org>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <pango/pango.h>
|
|
||||||
|
|
||||||
#include "gimpfont-utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Workaround pango bug #166540 */
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
getword (const char *str, const char *last, size_t *wordlen)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
p = getword (name, name + strlen (name), &wordlen);
|
|
||||||
|
|
||||||
if (wordlen)
|
|
||||||
{
|
|
||||||
gchar *end;
|
|
||||||
gdouble size;
|
|
||||||
|
|
||||||
size = g_ascii_strtod (p, &end);
|
|
||||||
|
|
||||||
if (end - p == wordlen)
|
|
||||||
{
|
|
||||||
gchar *new_name;
|
|
||||||
|
|
||||||
new_name = g_strconcat (name, ",", NULL);
|
|
||||||
g_free (name);
|
|
||||||
|
|
||||||
name = new_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/* GIMP - The GNU Image Manipulation Program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* gimpfont-utils.h
|
|
||||||
* Copyright (C) 2005 Manish Singh <yosh@gimp.org>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GIMP_FONT_UTILS_H__
|
|
||||||
#define __GIMP_FONT_UTILS_H__
|
|
||||||
|
|
||||||
|
|
||||||
/* 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. 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 (const PangoFontDescription *desc);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_FONT_UTILS_H__ */
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include "text-types.h"
|
#include "text-types.h"
|
||||||
|
|
||||||
#include "gimpfont.h"
|
#include "gimpfont.h"
|
||||||
#include "gimpfont-utils.h"
|
|
||||||
#include "gimpfontlist.h"
|
#include "gimpfontlist.h"
|
||||||
|
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
@ -47,9 +46,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef char * (* GimpFontDescToStringFunc) (const PangoFontDescription *desc);
|
|
||||||
|
|
||||||
|
|
||||||
static void gimp_font_list_add_font (GimpFontList *list,
|
static void gimp_font_list_add_font (GimpFontList *list,
|
||||||
PangoContext *context,
|
PangoContext *context,
|
||||||
PangoFontDescription *desc);
|
PangoFontDescription *desc);
|
||||||
|
@ -61,8 +57,6 @@ static void gimp_font_list_load_names (GimpFontList *list,
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpFontList, gimp_font_list, GIMP_TYPE_LIST)
|
G_DEFINE_TYPE (GimpFontList, gimp_font_list, GIMP_TYPE_LIST)
|
||||||
|
|
||||||
static GimpFontDescToStringFunc font_desc_to_string = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_font_list_class_init (GimpFontListClass *klass)
|
gimp_font_list_class_init (GimpFontListClass *klass)
|
||||||
|
@ -102,27 +96,6 @@ gimp_font_list_restore (GimpFontList *list)
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_FONT_LIST (list));
|
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_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
|
||||||
if (! fontmap)
|
if (! fontmap)
|
||||||
g_error ("You are using a Pango that has been built against a cairo "
|
g_error ("You are using a Pango that has been built against a cairo "
|
||||||
|
@ -153,7 +126,7 @@ gimp_font_list_add_font (GimpFontList *list,
|
||||||
if (! desc)
|
if (! desc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
name = font_desc_to_string (desc);
|
name = pango_font_description_to_string (desc);
|
||||||
|
|
||||||
if (g_utf8_validate (name, -1, NULL))
|
if (g_utf8_validate (name, -1, NULL))
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
#include "core/gimpimage-undo.h"
|
#include "core/gimpimage-undo.h"
|
||||||
#include "core/gimplayer-floating-sel.h"
|
#include "core/gimplayer-floating-sel.h"
|
||||||
|
|
||||||
#include "gimpfont-utils.h"
|
|
||||||
|
|
||||||
#include "gimptext.h"
|
#include "gimptext.h"
|
||||||
#include "gimptext-compat.h"
|
#include "gimptext-compat.h"
|
||||||
#include "gimptextlayer.h"
|
#include "gimptextlayer.h"
|
||||||
|
@ -78,7 +76,7 @@ text_render (GimpImage *image,
|
||||||
size = PANGO_PIXELS (pango_font_description_get_size (desc));
|
size = PANGO_PIXELS (pango_font_description_get_size (desc));
|
||||||
|
|
||||||
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
|
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
|
||||||
font = gimp_font_util_pango_font_description_to_string (desc);
|
font = pango_font_description_to_string (desc);
|
||||||
|
|
||||||
pango_font_description_free (desc);
|
pango_font_description_free (desc);
|
||||||
|
|
||||||
|
|
|
@ -4231,12 +4231,6 @@ GIMP_IS_FONT_CLASS
|
||||||
GIMP_FONT_GET_CLASS
|
GIMP_FONT_GET_CLASS
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
|
||||||
<FILE>gimpfont-utils</FILE>
|
|
||||||
<TITLE>GimpFont-utils</TITLE>
|
|
||||||
gimp_font_util_pango_font_description_to_string
|
|
||||||
</SECTION>
|
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gimpfontlist</FILE>
|
<FILE>gimpfontlist</FILE>
|
||||||
<TITLE>GimpFontList</TITLE>
|
<TITLE>GimpFontList</TITLE>
|
||||||
|
|
Loading…
Reference in New Issue