* Exposing load_user_fonts() and some other font.c functions,

even when FORKED_FONTS is not set.
* No longer undef'ing SDL_thread stuff when FORKED_FONTS is
  used if we're ALSO not using SDL_Pango, since that now
  uses a thread to let fontconfig generate its cache, and
  still let Tux Paint be responsive to the OS and user.
  (SF.net bug #2944951)
* Spawning a thread and rendering a dummy string with SDL_Pango,
  to allow fontconfig to generate its cache.
  (SF.net bug #2944951)
* Setting up 'busy' mouse cursor (watch-shaped) earlier
  (so it can happen while fontconfig cache thread runs).
* Not spawning forked font scanner (FORKED_FONTS) as early, so
  fontconfig can generate its cache first.
  (I wasn't sure if calling an SDL_thread after a fork()
  occured was safe or not; admittedly, I discovered that
  SDL_thread spawning wasn't working due to the re-#defines
  of those functions when FORKED_FONTS was set; see above.)

All of this only tested on Ubuntu 9.04.  Forced disabling of FORKED_FONTS
by editing fonts.h, and Tux Paint still worked (it just took longer at
the splash screen while the fonts were loaded).  Needs testing on various
Windows, Mac OS X and BeOS.
This commit is contained in:
William Kendrick 2010-04-27 22:04:43 +00:00
parent 0c63f14092
commit be2b5537b3
5 changed files with 196 additions and 66 deletions

View file

@ -244,7 +244,8 @@ MOUSE_CFLAGS:=-Isrc/$(MOUSEDIR) -D$(CURSOR_SHAPES)_CURSOR_SHAPES
# "make" with no arguments builds the program and man page from sources:
#
.PHONY: all
all: tuxpaint translations magic-plugins tp-magic-config thumb-starters
all: tuxpaint translations magic-plugins tp-magic-config
# thumb-starters
@echo
@echo "--------------------------------------------------------------"
@echo
@ -416,9 +417,10 @@ install: install-bin install-data install-man install-doc \
install-magic-plugin-dev \
install-icon install-gettext install-im install-importscript \
install-default-config install-example-stamps \
install-example-starters install-thumb-starters\
install-example-starters \
install-bash-completion \
$(ARCH_INSTALL)
#install-thumb-starters
@echo
@echo "--------------------------------------------------------------"
@echo

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$
2009.April.24 (0.9.22)
2009.April.27 (0.9.22)
* New Tools:
----------
* Label - A tool to add text to a drawing, which can be modified or
@ -21,7 +21,7 @@ $Id$
----------------
* Blinds - Close window blinds over your picture.
Perspective - Change the image's perspective.
Mosaic Hexagon, Mosaic irregular, Mosaic square - Glass mosaic effects.
Moasic Hexagon, Mosaic irregular, Mosaic square - Glass mosaic effects.
Zoom - Zoom the image in or out.
By Pere Pujal i Carabantes <pere@fornol.no-ip.org>
@ -45,6 +45,19 @@ $Id$
* Other Improvements:
-------------------
* Creating thumbnails for the starters we provide.
Pere Pujal i Carabantes <pere@fornol.no-ip.org>
* On systems where Pango is used for UI text rendering, Tux Paint now
spawns a temporary thread during start-up (at the splash screen) to
allow "fontconfig" to generate its font cache in the background,
while showing the "please wait" animation, and responding to the US.
(Fontconfig takes a long time to generate its cache the first time
you run a Pango- and hence fontconfig-enabled application
(Tux Paint, Gimp, Inkscape, etc.), or after adding lots of new fonts
to your system).
SF.net Bug #2944951
* Thumbnailing (of UI elements, stamps, saved images, etc.) is now
gamma-corrected. See:
http://www.4p8.com/eric.brasseur/gamma.html
@ -106,8 +119,6 @@ $Id$
* Creation of thumbnails for personal starters and templates.
* Creating thumbnails for the starters we provide.
* New Starters:
-------------
* Elephant
@ -147,7 +158,7 @@ $Id$
* New Locales:
------------
* Luxembourgish translation
René Brandenburger <rene@brandenburger.lu>
Ren<EFBFBD> Brandenburger <rene@brandenburger.lu>
* Malayalam translation
TBD
@ -156,7 +167,7 @@ $Id$
Farinaz Hedayat <farinaz.hedayat@gmail.com>
* Venetian language
Fabio Lazarin, El Galepìn <mistro@elgalepin.com>
Fabio Lazarin, El Galep<EFBFBD>n <mistro@elgalepin.com>
* Localization Updates:
---------------------
@ -375,7 +386,7 @@ $Id$
* New localizations:
------------------
* Shuswap (Secwepemctín) translation
* Shuswap (Secwepemct<EFBFBD>n) translation
Neskie Manuel <neskiem@gmail.com>
* Songhay translation
@ -444,7 +455,7 @@ $Id$
Simona Riva <simona.riva@tiscali.it>
* Kurdish translation
Amed Çeko Jiyan <amedcj@gmail.com>
Amed <EFBFBD>eko Jiyan <amedcj@gmail.com>
* Portuguese translation
Sergio Marques <smarquespt@gmail.com>
@ -525,7 +536,7 @@ $Id$
-----------------
* Asturian
Xandru Armesto <alarmes@wanadoo.es>
Mikel González <mikelisimu@yahoo.es>
Mikel Gonz<EFBFBD>lez <mikelisimu@yahoo.es>
* Localization Updates:
---------------------
@ -533,7 +544,7 @@ $Id$
Samuel Murray (Groenkloof) <samuel@translate.org.za>
* German translation
Burkhard Lück <lueck@hube-lueck.de>
Burkhard L<EFBFBD>ck <lueck@hube-lueck.de>
* Greek translation:
Yannis Papatzikos <papatzikos@yahoo.gr>
@ -546,7 +557,7 @@ $Id$
Alesis Novik <alesisnov@gmail.com>
* Slovakian translation
Peter Tuhársky <tuharsky@misbb.sk>
Peter Tuh<EFBFBD>rsky <tuharsky@misbb.sk>
* Spanish translation
Gabriel Gazzan <ggabriel@internet.com.uy>
@ -721,7 +732,7 @@ $Id$
Edmund GRIMLEY EVANS <edmundo@rano.org>
* Faroese translation
Lis Gøthe í Jákupsstovu <morshus@gmail.com>
Lis G<EFBFBD>the <20> J<>kupsstovu <morshus@gmail.com>
* Finnish translation
Jorma Karvonen <karvjorm@users.sf.net>
@ -1022,7 +1033,7 @@ $Id$
Jacques Chion <Jacques.Chion@wanadoo.fr>
* German translation
Burkhard Lück <lueck@hube-lueck.de>
Burkhard L<EFBFBD>ck <lueck@hube-lueck.de>
* Gujarati translation
Kartik Mistry <kartik.mistry@gmail.com>
@ -1042,7 +1053,7 @@ $Id$
* Norwegian Nynorsk translation
Karl Ove Hufthammer <huftis@users.sourceforge.net>
* Norwegian Bokmål translation
* Norwegian Bokm<EFBFBD>l translation
Karl Ove Hufthammer <huftis@users.sourceforge.net>
* Polish translation
@ -1368,7 +1379,7 @@ $Id$
Freek de Kruijf <f.de.kruijf@hetnet.nl>
* Faroese
Lis Gøthe í Jákupsstovu <morshus@gmail.com>
Lis G<EFBFBD>the <20> J<>kupsstovu <morshus@gmail.com>
* Gujarati
Kartik Mistry <kartik.mistry@gmail.com>
@ -1524,7 +1535,7 @@ $Id$
Khalid Al Holan <alholan@gmail.com>
* Faroese
Lis Gøthe í Jákupsstovu <morshus@gmail.com>
Lis G<EFBFBD>the <20> J<>kupsstovu <morshus@gmail.com>
* Gujarati -- includes "gu.ttf" font
Kartik Mistry <kartik.mistry@gmail.com>
@ -1578,7 +1589,7 @@ $Id$
Leandro Regueiro <leandro.regueiro@gmail.com>
* German
Burkhard Lück <lueck@hube-lueck.de>
Burkhard L<EFBFBD>ck <lueck@hube-lueck.de>
* Greek
Sokratis Sofianopoulos <sokratis.sofianopoulos@gmail.com>
@ -1612,7 +1623,7 @@ $Id$
* Spanish
Pablo Pita <pablo.pita@kdemail.net>
Gabriel Gazzán <ggabriel@internet.com.uy>
Gabriel Gazz<EFBFBD>n <ggabriel@internet.com.uy>
* Thai
Ouychai Chaita <ae.freeman@gmail.com>
@ -2097,7 +2108,7 @@ $Id$
* Mentioned Tux Paint Config. tool in FAQ.
* French documentation created.
Jérôme Chantreau <plovemax@hotmail.com>
J<EFBFBD>r<EFBFBD>me Chantreau <plovemax@hotmail.com>
* New translations:
-----------------
@ -2133,7 +2144,7 @@ $Id$
* Mexican Spanish
Ignacio Tike <ignaciotike@spymac.com>
Daniel Illingworth <webmaster@intermagen.net>
Luis C. Suárez M. <luiscsuarez@gmail.com>
Luis C. Su<EFBFBD>rez M. <luiscsuarez@gmail.com>
* Swahili
Martin Benjamin <martin.benjamin@yale.edu>
@ -2171,7 +2182,7 @@ $Id$
* German
Patrick <nc-spechtpa3 [At] netcologne DOT de>
Burkhard Lück <lueck@hube-lueck.de>
Burkhard L<EFBFBD>ck <lueck@hube-lueck.de>
* Greek
The Greek Linux i18n Team <i18ngr@lists.hellug.gr>
@ -2206,11 +2217,11 @@ $Id$
Eugene Zelenko <greendeath@mail.ru>
* Spanish and Spanish documentation.
Gabriel Gazzán <ggabriel@internet.com.uy>
Gabriel Gazz<EFBFBD>n <ggabriel@internet.com.uy>
* Swedish
Magnus Dahl <magnus.dahl@bredband.net>
Tomas Skäre <tomas@nocrew.org>
Tomas Sk<EFBFBD>re <tomas@nocrew.org>
* Vietnamese
Clytie Siddall <clytie@riverland.net.au>
@ -2352,7 +2363,7 @@ $Id$
Pere Pujal Carabantes <ppujal@airtel.net>
* Updated Danish translation.
Mogens Jæger <mogensjaeger@get2net.dk>
Mogens J<EFBFBD>ger <mogensjaeger@get2net.dk>
* Updated Dutch translation.
Geert Stams <geertstams@wanadoo.nl>
@ -2367,7 +2378,7 @@ $Id$
Roland Illig <roland.illig@gmx.de>
* Updated Hungarian translation.
Török Gábor <gabo@linuxportal.hu>
T<EFBFBD>r<EFBFBD>k G<>bor <gabo@linuxportal.hu>
* Updated Icelandic translation.
Pjetur G. Hjaltason <pjetur@pjetur.net>
@ -2403,7 +2414,7 @@ $Id$
Andrej Kacian <andrej@kacian.sk>
* Updated Spanish translation.
Gabriel Gazzán <ggabriel@internet.com.uy>
Gabriel Gazz<EFBFBD>n <ggabriel@internet.com.uy>
* Updated Tamil translation.
Muguntharaj <mugunth@thamizha.com>
@ -2809,7 +2820,7 @@ $Id$
TOYAMA Shin-ichi <shin1@wmail.plala.or.jp>
* Added support for some useful HTML escape sequences in stamp descriptions
(e.g., "&acute;" for "á" ("a" with "'" over it))
(e.g., "&acute;" for "<EFBFBD>" ("a" with "'" over it))
Append ".esc" to the locale code (e.g., "fr.esc=...") in the ".txt"
description files.
@ -3011,7 +3022,7 @@ $Id$
Karl Ove Hufthammer <karl@huftis.org>
* Translated to Hungarian.
Török Gábor <gabo@linuxmania.hu>
T<EFBFBD>r<EFBFBD>k G<>bor <gabo@linuxmania.hu>
* Partly translated to Korean. PO file in an unusable charset, though...
Mark K. Kim <mkkim214@gmail.com>

View file

@ -428,6 +428,7 @@ static void reliable_read(int fd, void *buf, size_t count)
while (count);
}
#endif
static void groupfonts_range(style_info ** base, int count)
{
@ -931,7 +932,7 @@ static void loadfonts(SDL_Surface * screen, const char *const dir)
}
static int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict const locale)
/* static */ int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict const locale)
{
char *homedirdir;
@ -991,7 +992,7 @@ static int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict
}
#ifdef FORKED_FONTS
void run_font_scanner(SDL_Surface * screen, const char *restrict const locale)
{

View file

@ -56,6 +56,9 @@
* Move into 'fonts.c' and the code in 'tuxpaint.c'
* that uses this lot should be put into 'fonts.c' as well.
*/
#ifdef NO_SDLPANGO
/* Only kill SDL_thread stuff when we're not using Pango, because we need it to let fontconfig make its cache (takes a long time the first time) -bjk 2010.04.27 */
#define SDL_CreateThread(fn,vp) (void*)(long)(fn(vp))
#define SDL_WaitThread(tid,rcp) do{(void)tid;(void)rcp;}while(0)
#define SDL_Thread int
@ -66,6 +69,8 @@
#define SDL_mutexV(lock) // release lock
#endif
#endif
extern SDL_Thread *font_thread;
extern volatile long font_thread_done;
@ -188,4 +193,6 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size);
void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix *pango_color);
#endif
int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict const locale);
#endif

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - March 22, 2010
June 14, 2002 - April 27, 2010
*/
@ -95,6 +95,7 @@
#define COLORSEL_CLOBBER_WIPE 8 /* draw the (greyed out) colors, but don't disable */
#define COLORSEL_FORCE_REDRAW 16 /* enable, and force redraw (to make color picker work) */
/* FIXME: Why are we checking this BEFORE the #include "SDL.h"!? Does this even work? -bjk 2010.04.24 */
/* Setting the amask value based on endianness*/
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define TPAINT_AMASK 0xff000000
@ -318,6 +319,7 @@ extern WrapperData macosx;
#include <sys/stat.h>
#include "SDL.h"
#include "SDL_thread.h"
#if !defined(_SDL_H)
#error "---------------------------------------------------"
#error "If you installed SDL from a package, be sure to get"
@ -6749,6 +6751,65 @@ static int load_user_fonts_stub(void *vp)
}
#endif
#ifndef NO_SDLPANGO
volatile long fontconfig_thread_done = 0;
int generate_fontconfig_cache_spinner(SDL_Surface * screen)
{
SDL_Event event;
while (fontconfig_thread_done == 0) {
show_progress_bar(screen);
SDL_Flip(screen);
SDL_Delay(20);
while (SDL_PollEvent(&event) > 0) {
if (event.type == SDL_QUIT ||
(event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
printf("Aborting!\n"); fflush(stdout);
return(1);
}
}
}
return(0);
}
static int generate_fontconfig_cache_real(void)
{
TuxPaint_Font * tmp_font;
SDL_Surface * tmp_surf;
SDL_Color black = { 0, 0, 0, 0 };
printf("-- Hello from generate_fontconfig_cache() (thread # %d)\n", SDL_ThreadID()); fflush(stdout);
tmp_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, NULL, 12);
if (tmp_font != NULL)
{
printf("-- Generated a font.\n"); fflush(stdout);
tmp_surf = render_text(tmp_font, "Test", black);
if (tmp_surf != NULL) {
printf("-- Generated a surface\n"); fflush(stdout);
SDL_FreeSurface(tmp_surf);
} else {
printf("-- Failed to make a surface!\n"); fflush(stdout);
}
TuxPaint_Font_CloseFont(tmp_font);
} else {
printf("-- Failed to generate a font!\n"); fflush(stdout);
}
fontconfig_thread_done = 1;
printf("-- generate_fontconfig_cache() is done\n"); fflush(stdout);
return(0);
}
static int generate_fontconfig_cache(void *vp)
{
return generate_fontconfig_cache_real();
}
#endif
#define hex2dec(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \
((c) >= 'A' && (c) <= 'F') ? ((c) - 'A' + 10) : \
@ -20612,6 +20673,7 @@ static void do_lock_file(void)
free(lock_fname);
}
/////////////////////////////////////////////////////////////////////////////
static void setup(void)
{
@ -20636,7 +20698,9 @@ static void setup(void)
Uint32(*getpixel_tmp_btn_down) (SDL_Surface *, int, int);
Uint32(*getpixel_img_paintwell) (SDL_Surface *, int, int);
int big_title;
#ifndef NO_SDLPANGO
SDL_Thread * fontconfig_thread;
#endif
@ -20911,6 +20975,74 @@ static void setup(void)
SDL_Flip(screen);
#if defined(WIN32) && defined(LARGE_CURSOR_FULLSCREEN_BUG)
if (fullscreen && no_fancy_cursors == 0)
{
fprintf(stderr, "Warning: An SDL bug causes the fancy cursors to leave\n"
"trails in fullscreen mode. Disabling fancy cursors.\n"
"(You can do this yourself with 'nofancycursors' option,\n"
"to avoid this warning in the future.)\n");
no_fancy_cursors = 1;
}
#endif
/* Create cursors: */
scale = 1;
#ifdef SMALL_CURSOR_SHAPES
scale = 2;
#endif
#ifdef __APPLE__
cursor_arrow = SDL_GetCursor(); /* use standard system cursor */
#endif
/* this one first, because we need it yesterday */
cursor_watch = get_cursor(watch_bits, watch_mask_bits,
watch_width, watch_height,
14 / scale, 14 / scale);
do_setcursor(cursor_watch);
show_progress_bar(screen);
#ifndef NO_SDLPANGO
/* Let Pango & fontcache do their work without locking up */
fontconfig_thread_done = 0;
printf("Spawning Pango thread\n"); fflush(stdout);
fontconfig_thread = SDL_CreateThread(generate_fontconfig_cache, NULL);
if (fontconfig_thread == NULL) {
fprintf(stderr, "Failed to create Pango setup thread: %s\n", SDL_GetError());
} else {
printf("Thread spawned\n"); fflush(stdout);
if (generate_fontconfig_cache_spinner(screen)) /* returns 1 if aborted */
{
printf("Aborted!\n"); fflush(stdout);
SDL_KillThread(fontconfig_thread);
SDL_Quit();
exit(0);
/* FIXME: Let's be more graceful about exiting (e.g., clean up lockfile!) -bjk 2010.04.27 */
}
printf("Done generating cache\n"); fflush(stdout);
}
#ifdef FORKED_FONTS
/* NOW we can fork our own font scanner stuff, and let it run in the bgkd -bjk 2010.04.27 */
printf("Now running font scanner\n"); fflush(stdout);
run_font_scanner(screen, lang_prefixes[get_current_language()]);
#endif
#endif
medium_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT,
DATA_PREFIX "fonts/default_font.ttf",
18 - (only_uppercase * 3));
@ -20950,38 +21082,6 @@ static void setup(void)
SDL_Flip(screen);
#if defined(WIN32) && defined(LARGE_CURSOR_FULLSCREEN_BUG)
if (fullscreen && no_fancy_cursors == 0)
{
fprintf(stderr, "Warning: An SDL bug causes the fancy cursors to leave\n"
"trails in fullscreen mode. Disabling fancy cursors.\n"
"(You can do this yourself with 'nofancycursors' option,\n"
"to avoid this warning in the future.)\n");
no_fancy_cursors = 1;
}
#endif
/* Create cursors: */
scale = 1;
#ifdef SMALL_CURSOR_SHAPES
scale = 2;
#endif
#ifdef __APPLE__
cursor_arrow = SDL_GetCursor(); /* use standard system cursor */
#endif
/* this one first, because we need it yesterday */
cursor_watch = get_cursor(watch_bits, watch_mask_bits,
watch_width, watch_height,
14 / scale, 14 / scale);
do_setcursor(cursor_watch);
show_progress_bar(screen);
#ifdef FORKED_FONTS
reliable_write(font_socket_fd, &no_system_fonts, sizeof no_system_fonts);
#else
@ -21631,10 +21731,19 @@ int main(int argc, char *argv[])
chdir_to_binary(argv[0]);
setup_config(argv);
CLOCK_ASM(time2);
#ifdef FORKED_FONTS
// must start ASAP, but depends on locale which in turn needs the config
#ifdef NO_SDLPANGO
/* Only fork it now if we're not planning on creating a thread to handle fontconfig stuff -bjk 2010.04.27 */
printf("Running font scanner\n"); fflush(stdout);
run_font_scanner(screen, lang_prefixes[get_current_language()]);
#else
printf("NOT running font scanner\n"); fflush(stdout);
#endif
#endif
/* Set up! */