Commit b658e763 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh

Font configuration stuff: You can rescan for fonts on the fly now. A

2003-09-01  Manish Singh  <yosh@gimp.org>

        Font configuration stuff: You can rescan for fonts on the fly now.
        A couple caveats: the text tool font dialog doesn't get updated, but
        that's supposed to be going away. The new font dock doesn't resort
        on update, but mitch is supposed to fix that. :)

        Some nice stuff for advanced font users: GIMP local font directories,
        and an optional site and user fonts.conf.

        I thought about supporting the auto-resan feature in fontconfig,
        but it might take too much time to do a scan so I haven't implemented
        it. Another thing I want to do is create fontconfig caches in the
        local dirs.

        * text/gimpfonts.[ch]: gimp_fonts_init/load/reset implementation.

        * text/Makefile.am: added gimpfonts.[ch]

        * app/core/gimp.c: use gimp_fonts_init/reset.

        * app/config/gimpcoreconfig.[ch]
        * app/config/gimprc-blurbs.h: added font-path config setting.

        * app/gui/preferences-dialog.c: Add a Font Folders section for the
        above. Also added a Rescan Font List button, which goes in the
        Environment section. Not sure if this is the right place...
        it also looks kinda ugly all by its lonesome.

        * app/gui/user-install-dialog.c: mention the fonts directory.

        * themes/Default/images/preferences/Makefile.am
        * themes/Default/images/preferences/folders-fonts.png: dummy icon for
        font folders pref, probably a folder with a little "T" in the corner
        would be good.
parent dcb6f225
2003-09-01 Manish Singh <yosh@gimp.org>
Font configuration stuff: You can rescan for fonts on the fly now.
A couple caveats: the text tool font dialog doesn't get updated, but
that's supposed to be going away. The new font dock doesn't resort
on update, but mitch is supposed to fix that. :)
Some nice stuff for advanced font users: GIMP local font directories,
and an optional site and user fonts.conf.
I thought about supporting the auto-resan feature in fontconfig,
but it might take too much time to do a scan so I haven't implemented
it. Another thing I want to do is create fontconfig caches in the
local dirs.
* text/gimpfonts.[ch]: gimp_fonts_init/load/reset implementation.
* text/Makefile.am: added gimpfonts.[ch]
* app/core/gimp.c: use gimp_fonts_init/reset.
* app/config/gimpcoreconfig.[ch]
* app/config/gimprc-blurbs.h: added font-path config setting.
* app/gui/preferences-dialog.c: Add a Font Folders section for the
above. Also added a Rescan Font List button, which goes in the
Environment section. Not sure if this is the right place...
it also looks kinda ugly all by its lonesome.
* app/gui/user-install-dialog.c: mention the fonts directory.
* themes/Default/images/preferences/Makefile.am
* themes/Default/images/preferences/folders-fonts.png: dummy icon for
font folders pref, probably a folder with a little "T" in the corner
would be good.
2003-09-01 Michael Natterer <mitch@gimp.org>
* app/core/gimpitem.[ch]: added new virtual function
......@@ -53,7 +89,7 @@
actually updates the splash, and one which does nothing, so we
don't need global variables in the status callback.
* app/appenv.h: removed vraiable declarations here. Some are still
* app/appenv.h: removed variable declarations here. Some are still
left, will get rid of this entire file soon...
* app/main.c: added them as local variables to main() and
......@@ -67,6 +67,7 @@ enum
PROP_PATTERN_PATH,
PROP_PALETTE_PATH,
PROP_GRADIENT_PATH,
PROP_FONT_PATH,
PROP_DEFAULT_BRUSH,
PROP_DEFAULT_PATTERN,
PROP_DEFAULT_PALETTE,
......@@ -177,6 +178,11 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
GIMP_PARAM_PATH_DIR_LIST,
gimp_config_build_data_path ("gradients"),
GIMP_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_FONT_PATH,
"font-path", FONT_PATH_BLURB,
GIMP_PARAM_PATH_DIR_LIST,
gimp_config_build_data_path ("fonts"),
0);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_BRUSH,
"default-brush", DEFAULT_BRUSH_BLURB,
DEFAULT_BRUSH,
......@@ -299,6 +305,7 @@ gimp_core_config_finalize (GObject *object)
g_free (core_config->pattern_path);
g_free (core_config->palette_path);
g_free (core_config->gradient_path);
g_free (core_config->font_path);
g_free (core_config->default_brush);
g_free (core_config->default_pattern);
g_free (core_config->default_palette);
......@@ -354,6 +361,10 @@ gimp_core_config_set_property (GObject *object,
g_free (core_config->gradient_path);
core_config->gradient_path = g_value_dup_string (value);
break;
case PROP_FONT_PATH:
g_free (core_config->font_path);
core_config->font_path = g_value_dup_string (value);
break;
case PROP_DEFAULT_BRUSH:
g_free (core_config->default_brush);
core_config->default_brush = g_value_dup_string (value);
......@@ -474,6 +485,9 @@ gimp_core_config_get_property (GObject *object,
case PROP_GRADIENT_PATH:
g_value_set_string (value, core_config->gradient_path);
break;
case PROP_FONT_PATH:
g_value_set_string (value, core_config->font_path);
break;
case PROP_DEFAULT_BRUSH:
g_value_set_string (value, core_config->default_brush);
break;
......
......@@ -48,6 +48,7 @@ struct _GimpCoreConfig
gchar *pattern_path;
gchar *palette_path;
gchar *gradient_path;
gchar *font_path;
gchar *default_brush;
gchar *default_pattern;
gchar *default_palette;
......
......@@ -132,6 +132,9 @@ N_("Tools such as fuzzy-select and bucket fill find regions based on a " \
#define GRADIENT_PATH_BLURB \
"Sets the gradient search path."
#define FONT_PATH_BLURB \
"Where to look for fonts."
#define HELP_BROWSER_BLURB \
N_("Sets the browser used by the help system.")
......
......@@ -37,6 +37,7 @@
#include "paint/paint.h"
#include "text/gimpfontlist.h"
#include "text/gimpfonts.h"
#include "xcf/xcf.h"
......@@ -521,6 +522,7 @@ gimp_real_exit (Gimp *gimp,
gimp_data_factory_data_save (gimp->pattern_factory);
gimp_data_factory_data_save (gimp->gradient_factory);
gimp_data_factory_data_save (gimp->palette_factory);
gimp_fonts_reset (gimp);
gimp_documents_save (gimp);
gimp_templates_save (gimp);
gimp_parasiterc_save (gimp);
......@@ -794,9 +796,7 @@ gimp_restore (Gimp *gimp,
/* initialize the list of gimp fonts */
(* status_callback) (NULL, _("Fonts"), 0.70);
gimp_container_freeze (gimp->fonts);
gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
gimp_container_thaw (gimp->fonts);
gimp_fonts_init (gimp);
/* initialize the document history */
(* status_callback) (NULL, _("Documents"), 0.80);
......
......@@ -35,6 +35,8 @@
#include "core/gimp.h"
#include "text/gimpfonts.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpdeviceinfo.h"
#include "widgets/gimpdevices.h"
......@@ -1856,6 +1858,22 @@ prefs_dialog_new (Gimp *gimp,
prefs_enum_option_menu_add (config, "thumbnail-size", 0, 0,
_("Size of Thumbnail Files:"),
GTK_TABLE (table), 1);
vbox2 = prefs_frame_new (_("Fonts"), GTK_CONTAINER (vbox), FALSE);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new_with_label (_("Rescan Font List"));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gimp_fonts_load),
gimp);
/*************/
......@@ -1931,6 +1949,10 @@ prefs_dialog_new (Gimp *gimp,
GIMP_HELP_PREFS_FOLDERS_GRADIENTS,
N_("Select Gradient Folders"),
"gradient-path" },
{ N_("Fonts"), N_("Font Folders"), "folders-fonts.png",
GIMP_HELP_PREFS_FOLDERS_GRADIENTS,
N_("Select Font Folders"),
"font-path" },
{ N_("Plug-Ins"), N_("Plug-In Folders"), "folders-plug-ins.png",
GIMP_HELP_PREFS_FOLDERS_PLUG_INS,
N_("Select Plug-In Folders"),
......
......@@ -198,9 +198,19 @@ tree_items[] =
"brushes."),
TREE_ITEM_MKDIR_ONLY, NULL
},
{
TRUE, "fonts",
N_("This folder is used to store fonts you only want\n"
"visible in the GIMP. The GIMP checks this folder in\n"
"addition to the system-wide GIMP fonts installation\n"
"when searching for fonts. Use this only if you really\n"
"want to have GIMP-only fonts, otherwise put things\n"
"in your global font directory."),
TREE_ITEM_MKDIR_ONLY, NULL
},
{
TRUE, "gradients",
N_("This folder is used to store user defined gradients\n"
N_("This folder is used to store user defined gradients.\n"
"The GIMP checks this folder in addition to the system-\n"
"wide GIMP gradients installation when searching for\n"
"gradients."),
......
......@@ -35,6 +35,8 @@
#include "core/gimp.h"
#include "text/gimpfonts.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpdeviceinfo.h"
#include "widgets/gimpdevices.h"
......@@ -1856,6 +1858,22 @@ prefs_dialog_new (Gimp *gimp,
prefs_enum_option_menu_add (config, "thumbnail-size", 0, 0,
_("Size of Thumbnail Files:"),
GTK_TABLE (table), 1);
vbox2 = prefs_frame_new (_("Fonts"), GTK_CONTAINER (vbox), FALSE);
hbox = gtk_hbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gtk_button_new_with_label (_("Rescan Font List"));
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gimp_fonts_load),
gimp);
/*************/
......@@ -1931,6 +1949,10 @@ prefs_dialog_new (Gimp *gimp,
GIMP_HELP_PREFS_FOLDERS_GRADIENTS,
N_("Select Gradient Folders"),
"gradient-path" },
{ N_("Fonts"), N_("Font Folders"), "folders-fonts.png",
GIMP_HELP_PREFS_FOLDERS_GRADIENTS,
N_("Select Font Folders"),
"font-path" },
{ N_("Plug-Ins"), N_("Plug-In Folders"), "folders-plug-ins.png",
GIMP_HELP_PREFS_FOLDERS_PLUG_INS,
N_("Select Plug-In Folders"),
......
......@@ -198,9 +198,19 @@ tree_items[] =
"brushes."),
TREE_ITEM_MKDIR_ONLY, NULL
},
{
TRUE, "fonts",
N_("This folder is used to store fonts you only want\n"
"visible in the GIMP. The GIMP checks this folder in\n"
"addition to the system-wide GIMP fonts installation\n"
"when searching for fonts. Use this only if you really\n"
"want to have GIMP-only fonts, otherwise put things\n"
"in your global font directory."),
TREE_ITEM_MKDIR_ONLY, NULL
},
{
TRUE, "gradients",
N_("This folder is used to store user defined gradients\n"
N_("This folder is used to store user defined gradients.\n"
"The GIMP checks this folder in addition to the system-\n"
"wide GIMP gradients installation when searching for\n"
"gradients."),
......
......@@ -21,6 +21,8 @@ libapptext_a_sources = \
gimpfont.h \
gimpfontlist.c \
gimpfontlist.h \
gimpfonts.c \
gimpfonts.h \
gimptext.c \
gimptext.h \
gimptext-bitmap.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others
*
* text.c
* Copyright (C) 2003 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include <pango/pangoft2.h>
/* PangoFT2 is assumed, so we should have this in our cflags */
#include <fontconfig/fontconfig.h>
#include "libgimpbase/gimpbase.h"
#include "core/core-types.h"
#include "config/gimpconfig-path.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "gimpfontlist.h"
#include "gimpfonts.h"
#define CONF_FNAME "fonts.conf"
static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
gchar *fonts_conf);
static void gimp_fonts_add_directories (FcConfig *config,
const gchar *path_str);
void
gimp_fonts_init (Gimp *gimp)
{
gimp_fonts_load (gimp);
g_signal_connect_swapped (gimp->config, "notify::font-path",
G_CALLBACK (gimp_fonts_load), gimp);
}
void
gimp_fonts_load (Gimp *gimp)
{
FcConfig *config;
gchar *fonts_conf;
gchar *path;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts));
gimp_set_busy (gimp);
gimp_container_clear (GIMP_CONTAINER (gimp->fonts));
config = FcInitLoadConfig ();
if (! config)
return;
fonts_conf = gimp_personal_rc_file (CONF_FNAME);
if (! gimp_fonts_load_fonts_conf (config, fonts_conf))
return;
fonts_conf = g_build_filename (gimp_sysconf_directory (), CONF_FNAME, NULL);
if (! gimp_fonts_load_fonts_conf (config, fonts_conf))
return;
path = gimp_config_path_expand (gimp->config->font_path, TRUE, NULL);
gimp_fonts_add_directories (config, path);
g_free (path);
if (! FcConfigBuildFonts (config))
{
FcConfigDestroy (config);
return;
}
FcConfigSetCurrent (config);
gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
gimp_unset_busy (gimp);
}
void
gimp_fonts_reset (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* We clear the default config here, so any subsequent fontconfig use will
* reinit the library with defaults. (Maybe we should call FcFini here too?)
*/
FcConfigSetCurrent (NULL);
}
static gboolean
gimp_fonts_load_fonts_conf (FcConfig *config,
gchar *fonts_conf)
{
gboolean ret = TRUE;
if (! FcConfigParseAndLoad (config, fonts_conf, FcFalse))
{
FcConfigDestroy (config);
ret = FALSE;
}
g_free (fonts_conf);
return ret;
}
static void
gimp_fonts_add_directories (FcConfig *config,
const gchar *path_str)
{
GList *path;
GList *list;
g_return_if_fail (config != NULL);
g_return_if_fail (path_str != NULL);
path = gimp_path_parse (path_str, 256, TRUE, NULL);
for (list = path; list; list = list->next)
FcConfigAppFontAddDir (config, (gchar *) list->data);
gimp_path_free (path);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_FONTS_H__
#define __GIMP_FONTS_H__
void gimp_fonts_init (Gimp *gimp);
void gimp_fonts_load (Gimp *gimp);
void gimp_fonts_reset (Gimp *gimp);
#endif /* __GIMP_FONTS_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others
*
* text.c
* Copyright (C) 2003 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include <pango/pangoft2.h>
/* PangoFT2 is assumed, so we should have this in our cflags */
#include <fontconfig/fontconfig.h>
#include "libgimpbase/gimpbase.h"
#include "core/core-types.h"
#include "config/gimpconfig-path.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "gimpfontlist.h"
#include "gimpfonts.h"
#define CONF_FNAME "fonts.conf"
static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
gchar *fonts_conf);
static void gimp_fonts_add_directories (FcConfig *config,
const gchar *path_str);
void
gimp_fonts_init (Gimp *gimp)
{
gimp_fonts_load (gimp);
g_signal_connect_swapped (gimp->config, "notify::font-path",
G_CALLBACK (gimp_fonts_load), gimp);
}
void
gimp_fonts_load (Gimp *gimp)
{
FcConfig *config;
gchar *fonts_conf;
gchar *path;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_FONT_LIST (gimp->fonts));
gimp_set_busy (gimp);
gimp_container_clear (GIMP_CONTAINER (gimp->fonts));
config = FcInitLoadConfig ();
if (! config)
return;
fonts_conf = gimp_personal_rc_file (CONF_FNAME);
if (! gimp_fonts_load_fonts_conf (config, fonts_conf))
return;
fonts_conf = g_build_filename (gimp_sysconf_directory (), CONF_FNAME, NULL);
if (! gimp_fonts_load_fonts_conf (config, fonts_conf))
return;
path = gimp_config_path_expand (gimp->config->font_path, TRUE, NULL);
gimp_fonts_add_directories (config, path);
g_free (path);
if (! FcConfigBuildFonts (config))
{
FcConfigDestroy (config);
return;
}
FcConfigSetCurrent (config);
gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
gimp_unset_busy (gimp);
}
void
gimp_fonts_reset (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* We clear the default config here, so any subsequent fontconfig use will
* reinit the library with defaults. (Maybe we should call FcFini here too?)
*/
FcConfigSetCurrent (NULL);
}
static gboolean
gimp_fonts_load_fonts_conf (FcConfig *config,
gchar *fonts_conf)
{
gboolean ret = TRUE;
if (! FcConfigParseAndLoad (config, fonts_conf, FcFalse))
{
FcConfigDestroy (config);
ret = FALSE;
}
g_free (fonts_conf);
return ret;
}
static void
gimp_fonts_add_directories (FcConfig *config,
const gchar *path_str)
{
GList *path;
GList *list;
g_return_if_fail (config != NULL);
g_return_if_fail (path_str != NULL);
path = gimp_path_parse (path_str, 256, TRUE, NULL);
for (list = path; list; list = list->next)
FcConfigAppFontAddDir (config, (gchar *) list->data);
gimp_path_free (path);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis and others
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_FONTS_H__
#define __GIMP_FONTS_H__
void gimp_fonts_init (Gimp *gimp);
void gimp_fonts_load (Gimp *gimp);
void gimp_fonts_reset (Gimp *gimp);
#endif /* __GIMP_FONTS_H__ */
......@@ -8,6 +8,7 @@ PREFS_IMAGES = \
environment.png \
folders.png \
folders-brushes.png \
folders-fonts.png \
folders-gradients.png \
folders-modules.png \
folders-environ.png \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment