From cdcc7af6b7153cc94b333c2a543a1c2fb4aa46a4 Mon Sep 17 00:00:00 2001
From: William Kendrick
Date: Tue, 4 Jan 2005 06:43:58 +0000
Subject: [PATCH] Added "--nosysfonts" option to supress loading of system-wide
fonts.
---
docs/CHANGES.txt | 1 +
docs/OPTIONS.txt | 12 +++++++--
docs/html/OPTIONS.html | 13 ++++++++--
src/tuxpaint.c | 56 +++++++++++++++++++++++++++++++-----------
4 files changed, 64 insertions(+), 18 deletions(-)
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index 8155696fe..9c802eb40 100644
--- a/docs/CHANGES.txt
+++ b/docs/CHANGES.txt
@@ -51,6 +51,7 @@ http://www.newbreedsoftware.com/tuxpaint/
* Text tool improvements:
-----------------------
* Attempts to pick up the system's fonts, too!
+ (Disable loading system fonts with "--nosysfonts" or "nosysfonts=yes".)
Albert Cahalan
* Italic, bold and sizes are now controlled with separate buttons
diff --git a/docs/OPTIONS.txt b/docs/OPTIONS.txt
index c88053658..e1a8a914a 100644
--- a/docs/OPTIONS.txt
+++ b/docs/OPTIONS.txt
@@ -3,13 +3,13 @@
Options Documentation
- Copyright 2004 by Bill Kendrick
+ Copyright 2005 by Bill Kendrick
New Breed Software
bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/
- December 26, 2004
+ January 3, 2005
---------------------------------------------------------------------------
@@ -171,6 +171,12 @@ Windows Users
This can help when Tux Paint is run on very slow computers, or
displayed on a remote X-Window display.
+ nosysfonts=yes
+
+ This option prevents Tux Paint from attempting to load fonts
+ (for use in the Text tool) from your operating system. It will
+ only load the ones that come with Tux Paint.
+
nostamps=yes
This option tells Tux Paint to not load any rubber stamp images,
@@ -392,6 +398,7 @@ Windows Users
--nooutlines
--nostamps
--nostampcontrols
+ --nosysfonts
--mirrorstamps
--keyboard
--savedir DIRECTORY
@@ -420,6 +427,7 @@ Windows Users
--outlines
--stamps
--stampcontrols
+ --sysfonts
--dontmirrorstamps
--mouse
--saveoverask
diff --git a/docs/html/OPTIONS.html b/docs/html/OPTIONS.html
index 0a6015cb8..6c5c1761b 100644
--- a/docs/html/OPTIONS.html
+++ b/docs/html/OPTIONS.html
@@ -16,13 +16,13 @@ version
Options Documentation
-Copyright 2004 by Bill Kendrick
+
Copyright 2005 by Bill Kendrick
New Breed Software
bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/
-December 26, 2004
+January 3, 2005
@@ -228,6 +228,13 @@ New Breed Software
or displayed on a remote X-Window display.
+ nosysfonts=yes
+
+ This option prevents Tux Paint from attempting to load fonts
+ (for use in the Text tool) from your operating system.
+ It will only load the ones that come with Tux Paint.
+
+
nostamps=yes
This option tells Tux Paint to not load any rubber stamp
@@ -627,6 +634,7 @@ New Breed Software
--nooutlines
--nostamps
--nostampcontrols
+ --nosysfonts
--mirrorstamps
--keyboard
--savedir DIRECTORY
@@ -658,6 +666,7 @@ New Breed Software
--outlines
--stamps
--stampcontrols
+ --sysfonts
--dontmirrorstamps
--mouse
--saveoverask
diff --git a/src/tuxpaint.c b/src/tuxpaint.c
index 5e584999c..bbfbe82fb 100644
--- a/src/tuxpaint.c
+++ b/src/tuxpaint.c
@@ -1389,6 +1389,7 @@ static int use_sound, fullscreen, disable_quit, simple_shapes,
wheely, no_fancy_cursors, keymouse, mouse_x, mouse_y,
mousekey_up, mousekey_down, mousekey_left, mousekey_right,
dont_do_xor, use_print_config, dont_load_stamps, noshortcuts,
+ no_system_fonts,
mirrorstamps, disable_stamp_controls, disable_save, ok_to_use_lockfile;
static int starter_mirrored, starter_flipped;
static int recording, playing;
@@ -1676,6 +1677,7 @@ static void groupfonts_range(style_info **base, int count)
int boldcounts[4] = {0,0,0,0};
int boldmap[4] = {-1,-1,-1,-1};
int i;
+
if(count<1 || count>4)
{
printf("::::::: %d %s\n",count, base[0]->family);
@@ -1684,8 +1686,9 @@ while(i--)
{
printf(" %s\n", base[i]->style);
}
-sleep(5);
+//sleep(5);
}
+
i = count;
while(i--)
boldcounts[base[i]->boldness]++;
@@ -5901,6 +5904,7 @@ static void show_usage(FILE * f, char * prg)
" %s [--mouse | --keyboard] [--dontgrab | --grab]\n"
" %s [--noshortcuts | --shortcuts] [--wheelmouse | --nowheelmouse]\n"
" %s [--outlines | --nooutlines] [--stamps | --nostamps]\n"
+ " %s [--nosysfonts | --sysfonts]\n"
" %s [--nostampcontrols | --stampcontrols]\n"
" %s [--mirrorstamps | --dontmirrorstamps]\n"
" %s [--saveoverask | --saveover | --saveovernew]\n"
@@ -5923,7 +5927,7 @@ static void show_usage(FILE * f, char * prg)
#ifdef WIN32
blank,
#endif
- blank);
+ blank, blank);
free(blank);
}
@@ -6010,6 +6014,7 @@ static void setup(int argc, char * argv[])
disable_save = 0;
disable_print = 0;
dont_load_stamps = 0;
+ no_system_fonts = 0;
print_delay = 0;
printcommand = "pngtopnm | pnmtops | lpr";
use_print_config = 0;
@@ -6261,6 +6266,14 @@ static void setup(int argc, char * argv[])
{
dont_load_stamps = 0;
}
+ else if (strcmp(argv[i], "--nosysfonts") == 0)
+ {
+ no_system_fonts = 1;
+ }
+ else if (strcmp(argv[i], "--sysfonts") == 0)
+ {
+ no_system_fonts = 0;
+ }
else if (strcmp(argv[i], "--noprint") == 0 || strcmp(argv[i], "-p") == 0)
{
disable_print = 1;
@@ -6965,19 +6978,22 @@ static void setup(int argc, char * argv[])
loadfonts(DATA_PREFIX "fonts", 1);
+ if (!no_system_fonts)
+ {
#ifdef WIN32
- // add Windows font dir here
+ // add Windows font dir here
#else
- loadfonts("/usr/share/feh/fonts", 0);
- loadfonts("/usr/share/fonts", 0);
- loadfonts("/usr/X11R6/lib/X11/fonts", 0);
- loadfonts("/usr/share/texmf/fonts", 0);
- loadfonts("/usr/share/grace/fonts/type1", 0);
- loadfonts("/usr/share/hatman/fonts", 0);
- loadfonts("/usr/share/icewm/themes/jim-mac", 0);
- loadfonts("/usr/share/vlc/skins2/fonts", 0);
- loadfonts("/usr/share/xplanet/fonts", 0);
+ loadfonts("/usr/share/feh/fonts", 0);
+ loadfonts("/usr/share/fonts", 0);
+ loadfonts("/usr/X11R6/lib/X11/fonts", 0);
+ loadfonts("/usr/share/texmf/fonts", 0);
+ loadfonts("/usr/share/grace/fonts/type1", 0);
+ loadfonts("/usr/share/hatman/fonts", 0);
+ loadfonts("/usr/share/icewm/themes/jim-mac", 0);
+ loadfonts("/usr/share/vlc/skins2/fonts", 0);
+ loadfonts("/usr/share/xplanet/fonts", 0);
#endif
+ }
homedirdir = get_fname("fonts");
loadfonts(homedirdir, 0);
@@ -14064,12 +14080,15 @@ static void loadfonts(const char * const dir, int fatal)
// Compressed files (with .gz or .bz2) might also work.
if (strstr(d_names[i], ".ttf") || strstr(d_names[i], ".pfa") || strstr(d_names[i], ".pfb"))
{
-//printf("Loading font: %s/%s\n", dir, d_names[i]);
+printf("Loading font: %s/%s\n", dir, d_names[i]);
TTF_Font *font = TTF_OpenFont(fname, text_sizes[text_size]);
if(font)
{
const char *family = TTF_FontFaceFamilyName(font);
- if(!( strstr(family, "Webdings") || strstr(family, "Dingbats") || strstr(family, "Cursor") || strstr(family, "Standard Symbols") ))
+ if(!(strstr(family, "Webdings") ||
+ strstr(family, "Dingbats") ||
+ strstr(family, "Cursor") ||
+ strstr(family, "Standard Symbols")))
{
user_font_styles[num_font_styles] = malloc(sizeof *user_font_styles[num_font_styles]);
user_font_styles[num_font_styles]->directory = strdup(dir);
@@ -14571,6 +14590,15 @@ static void parse_options(FILE * fi)
{
dont_load_stamps = 0;
}
+ else if (strcmp(str, "nosysfonts=yes") == 0)
+ {
+ no_system_fonts = 1;
+ }
+ else if (strcmp(str, "nosysfonts=no") == 0 ||
+ strcmp(str, "sysfonts=yes") == 0)
+ {
+ no_system_fonts = 0;
+ }
else if (strcmp(str, "nosound=yes") == 0)
{
use_sound = 0;