diff --git a/Makefile b/Makefile index 25a81bf26..d0f5c9785 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # Various contributors (see AUTHORS.txt) # https://tuxpaint.org/ -# June 14, 2002 - April 9, 2023 +# June 14, 2002 - April 30, 2023 # The version number, for release: @@ -295,7 +295,6 @@ NOSOUNDFLAG:=$(if $(SDL_MIXER_LIB),,-DNOSOUND$(warning -lSDL2_Mixer failed, no s # SDL Pango is needed to render complex scripts like Thai and Arabic SDL2_PANGO_LIB:=$(call linktest,SDL2_Pango,-lSDL2_Pango,$(SDL_LIBS)) SDL2_PANGO_CFLAGS:=$(shell $(PKG_CONFIG) --cflags SDL2_Pango) -NOPANGOFLAG:=$(if $(SDL2_PANGO_LIB),,-DNO_SDLPANGO$(warning -lSDL2_Pango failed, no scripts for you!)) SDL_LIBS+=$(SDL_MIXER_LIB) $(SDL2_PANGO_LIB) @@ -355,7 +354,7 @@ DEFS:=-DVER_DATE=\"$(VER_DATE)\" -DVER_VERSION=\"$(VER_VERSION)\" \ -DIMDIR=\"$(patsubst $(DESTDIR)%,%,$(IM_PREFIX))/\" \ -DCONFDIR=\"$(patsubst $(DESTDIR)%,%,$(CONFDIR))/\" \ -DMAGIC_PREFIX=\"$(patsubst $(DESTDIR)%,%,$(MAGIC_PREFIX))/\" \ - $(NOSOUNDFLAG) $(NOSVGFLAG) $(OLDSVGFLAG) $(NOPANGOFLAG) \ + $(NOSOUNDFLAG) $(NOSVGFLAG) $(OLDSVGFLAG) \ $(MAEMOFLAG) DEBUG_FLAGS:= diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index c674bbffc..d989a79af 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -127,6 +127,13 @@ https://tuxpaint.org/ Ran it during 0.9.30 development. Bill Kendrick + * Now requiring "SDL2_Pango" library all the time (no longer + builds without it). Motivation: Without it, many scripts + (e.g. Japanese, Thai, Arabic) did not render properly. + Closes https://sourceforge.net/p/tuxpaint/bugs/268/ + (h/t Pere for confirming the situation.) + Bill Kendrick + * Localization Updates: --------------------- * Chinese (Simplified) translation diff --git a/src/dirwalk.c b/src/dirwalk.c index 72ee57bd3..18d3582e5 100644 --- a/src/dirwalk.c +++ b/src/dirwalk.c @@ -1,7 +1,7 @@ /* dirwalk.c - Copyright (c) 2009-2022 + Copyright (c) 2009-2023 https://tuxpaint.org/ This program is free software; you can redistribute it and/or modify @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last modified: December 11, 2022 + Last modified: April 30, 2023 */ #include @@ -166,11 +166,11 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, printf("%s:%d - success: tpf: 0x%x tpf->ttf_font: 0x%x\n", __FILE__, __LINE__, (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64 } -#ifndef NO_SDLPANGO else + { printf("%s:%d - success: tpf: 0x%x tpf->pango_context: 0x%x\n", __FILE__, __LINE__, (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->pango_context); -#endif + } #endif // These fonts crash Tux Paint via a library bug. diff --git a/src/fonts.c b/src/fonts.c index a9b60b6a2..32f02696c 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -1,7 +1,7 @@ /* fonts.c - Copyright (c) 2009-2022 + Copyright (c) 2009-2023 https://tuxpaint.org/ This program is free software; you can redistribute it and/or modify @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last modified: December 11, 2022 + Last modified: April 30, 2023 */ #include @@ -119,8 +119,6 @@ static const char *problemFontExtensions[] = { SDL_Thread *font_thread; #endif -#ifndef NO_SDLPANGO - #include "SDL2_Pango.h" #if !defined(SDL_PANGO_H) #error "---------------------------------------------------" @@ -130,8 +128,6 @@ SDL_Thread *font_thread; #error "---------------------------------------------------" #endif -#endif - #ifdef FORKED_FONTS int no_system_fonts; @@ -168,49 +164,6 @@ static void reliable_read(int fd, void *buf, size_t count); #endif -#ifdef NO_SDLPANGO -TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size) -{ - TuxPaint_Font *ret = NULL; - - if (!need_own_font) - { - return fallback; - } - else - { - char str[128]; - - snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, lang_prefix); - - ret = TuxPaint_Font_OpenFont("", str, size); - -#ifdef __APPLE__ - if (!ret) - { - snprintf(str, sizeof(str), "%sfonts/%s.ttf", DATA_PREFIX, lang_prefix); - ret = TuxPaint_Font_OpenFont("", str, size); - } - - if (!ret) - { - snprintf(str, sizeof(str), "/Library/Fonts/%s.ttf", lang_prefix); - ret = TuxPaint_Font_OpenFont("", str, size); - } - - if (!ret) - { - snprintf(str, sizeof(str), "%s/%s.ttf", apple_fontsPath(), lang_prefix); - ret = TuxPaint_Font_OpenFont("", str, size); - } -#endif - - return ret ? ret : fallback; - } -} -#endif // ifdef NO_SDLPANGO - - void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) { #ifdef DEBUG @@ -219,7 +172,6 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) if (!tpf) return; -#ifndef NO_SDLPANGO #ifdef DEBUG printf("%s:%d - TuxPaint_Font_CloseFont step 2 (%p, %d)\n", __FILE__, __LINE__, tpf->pango_context, tpf->typ); #endif @@ -231,7 +183,6 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) #endif tpf->pango_context = NULL; } -#endif #ifdef DEBUG printf("%s:%d - TuxPaint_Font_CloseFont step 3 (%p, %d)\n", __FILE__, __LINE__, tpf->ttf_font, tpf->typ); @@ -259,16 +210,12 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile TuxPaint_Font *tpf = NULL; char *familyname; int i; - -#ifndef NO_SDLPANGO char desc[1024]; -#endif #ifdef DEBUG printf("%s:%d - OpenFont(pango:\"%s\", ttf:\"%s\")\n", __FILE__, __LINE__, pangodesc, ttffilename); #endif -#ifndef NO_SDLPANGO if (pangodesc != NULL && pangodesc[0] != '\0') { tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font)); @@ -311,7 +258,6 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile return (tpf); } -#endif // #ifndef NO_SDLPANGO /* -- Did not, at this point, load the font using SDL_Pango -- */ @@ -356,7 +302,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile } familyname = TTF_FontFaceFamilyName(ttf_font); /* N.B.: I don't believe we're supposed to free() this... -bjk 2021.10.26 */ - (void)familyname; // avoid compiler complaints if NO_SDLPANGO is set, or ALWAYS_LOAD_FONT_WITH_PANGO is not set, and DEBUG is not set + (void)familyname; // avoid compiler complaints if ALWAYS_LOAD_FONT_WITH_PANGO is not set, and DEBUG is not set #ifdef DEBUG printf("%s:%d - Loaded %s (\"%s\")\n", __FILE__, __LINE__, ttffilename, @@ -367,7 +313,6 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile /* This is currently disabled, as it is under construction (and may be moot under SDL2) -bjk 2021.10.28 */ #ifdef ALWAYS_LOAD_FONT_WITH_PANGO -#ifndef NO_SDLPANGO /* -- Try loading the font with Pango, instead! */ tpf = TuxPaint_Font_OpenFont(familyname, "", size); if (tpf != NULL) @@ -383,7 +328,6 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile TTF_CloseFont(ttf_font); return (tpf); } -#endif // #ifndef NO_SDLPANGO #endif @@ -1412,58 +1356,34 @@ TuxPaint_Font *getfonthandle(int desire) #endif -/* FIXME: Doesn't make sense; fi->handle is NULL! -bjk 2007.07.17 - -#ifndef NO_SDLPANGO - - if (fi->handle->typ == FONT_TYPE_PANGO) + if (!name) { - snprintf(description, sizeof(description), "%s%s%s", fi->family, - (text_state ^ TTF_STYLE_ITALIC ? " italic" : ""), - (text_state ^ TTF_STYLE_BOLD ? " bold" : "")); - - pathname = (char *) ""; - -#ifdef DEBUG - printf("getfonthandle(%d) asking SDL_Pango for %s\n", desire, description); -#endif + name = fi->filename[text_state ^ TTF_STYLE_ITALIC]; + missing = text_state & TTF_STYLE_ITALIC; } -#endif -*/ - -/* FIXME: Doesn't make sense; fi->handle is NULL! -bjk 2007.07.17 - if (fi->handle->typ == FONT_TYPE_TTF) -*/ + if (!name) { - if (!name) - { - name = fi->filename[text_state ^ TTF_STYLE_ITALIC]; - missing = text_state & TTF_STYLE_ITALIC; - } - if (!name) - { - name = fi->filename[text_state ^ TTF_STYLE_BOLD]; - missing = text_state & TTF_STYLE_BOLD; - } - if (!name) - { - name = fi->filename[text_state ^ (TTF_STYLE_ITALIC | TTF_STYLE_BOLD)]; - missing = text_state & (TTF_STYLE_ITALIC | TTF_STYLE_BOLD); - } - if (!name) - { -#ifdef DEBUG - printf("%s:%d - name is still NULL\n", __FILE__, __LINE__); - fflush(stdout); -#endif - return (NULL); - } - - pathname = alloca(strlen(fi->directory) + 1 + strlen(name) + 1); - sprintf(pathname, "%s/%s", fi->directory, name); - - strcpy(description, ""); + name = fi->filename[text_state ^ TTF_STYLE_BOLD]; + missing = text_state & TTF_STYLE_BOLD; } + if (!name) + { + name = fi->filename[text_state ^ (TTF_STYLE_ITALIC | TTF_STYLE_BOLD)]; + missing = text_state & (TTF_STYLE_ITALIC | TTF_STYLE_BOLD); + } + if (!name) + { +#ifdef DEBUG + printf("%s:%d - name is still NULL\n", __FILE__, __LINE__); + fflush(stdout); +#endif + return (NULL); + } + + pathname = alloca(strlen(fi->directory) + 1 + strlen(name) + 1); + sprintf(pathname, "%s/%s", fi->directory, name); + + strcpy(description, ""); fi->handle = TuxPaint_Font_OpenFont(description, pathname, text_sizes[text_size]); // if the font doesn't load, we die -- it did load OK before though @@ -1496,10 +1416,8 @@ TuxPaint_Font *getfonthandle(int desire) TTF_SetFontStyle(fi->handle->ttf_font, missing); } -#ifndef NO_SDLPANGO if (fi->handle->typ == FONT_TYPE_PANGO) printf("%s:%d - It's a Pango context...\n", __FILE__, __LINE__); -#endif return fi->handle; } @@ -1590,9 +1508,7 @@ static int surfcmp(const void *s1, const void *s2) int charset_works(TuxPaint_Font * font, const char *s) { SDL_Color black = { 0, 0, 0, 0 }; -#ifndef NO_SDLPANGO SDLPango_Matrix pango_color; -#endif SDL_Surface **surfs = malloc(strlen(s) * sizeof surfs[0]); unsigned count = 0; int ret = 0; @@ -1612,7 +1528,6 @@ int charset_works(TuxPaint_Font * font, const char *s) while ((*s & 0xc0u) == 0x80u); // assume safe input c[offset++] = '\0'; -#ifndef NO_SDLPANGO if (font->typ == FONT_TYPE_PANGO) { sdl_color_to_pango_color(black, &pango_color); @@ -1620,7 +1535,6 @@ int charset_works(TuxPaint_Font * font, const char *s) SDLPango_SetText(font->pango_context, c, -1); tmp_surf = SDLPango_CreateSurfaceDraw(font->pango_context); } -#endif if (font->typ == FONT_TYPE_TTF) { @@ -1680,7 +1594,6 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf) return (""); } -#ifndef NO_SDLPANGO if (tpf->typ == FONT_TYPE_PANGO) { (void)(tpf); @@ -1688,7 +1601,6 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf) return (""); } -#endif if (tpf->typ == FONT_TYPE_TTF) return (TTF_FontFaceFamilyName(tpf->ttf_font)); @@ -1711,7 +1623,6 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) return (""); } -#ifndef NO_SDLPANGO if (tpf->typ == FONT_TYPE_PANGO) { (void)(tpf); @@ -1719,7 +1630,6 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) return (""); } -#endif if (tpf->typ == FONT_TYPE_TTF) return (TTF_FontFaceStyleName(tpf->ttf_font)); @@ -1732,8 +1642,6 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) } -#ifndef NO_SDLPANGO - void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color) { Uint8 pc[4][4]; @@ -1760,5 +1668,3 @@ void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color memcpy(pango_color, pc, 16); } - -#endif diff --git a/src/fonts.h b/src/fonts.h index c4fe25301..6bfe74281 100644 --- a/src/fonts.h +++ b/src/fonts.h @@ -19,8 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: January 6, 2023 - $Id$ + Last updated: April 30, 2023 */ #ifndef FONTS_H @@ -38,10 +37,7 @@ #include "SDL.h" #include "SDL_ttf.h" - -#ifndef NO_SDLPANGO #include "SDL2_Pango.h" -#endif #define PANGO_DEFAULT_FONT "DejaVu Sans" //#define PANGO_DEFAULT_FONT "OpenDyslexicAlta" @@ -52,28 +48,6 @@ #if !defined(FORKED_FONTS) && !defined(WIN32) #include "SDL_thread.h" #include "SDL_mutex.h" -#else -/* This shouldn't really be here :-) - * 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 -#define SDL_mutex int -#define SDL_CreateMutex() 0 // creates in released state -#define SDL_DestroyMutex(lock) -#ifndef SDL_mutexP -#define SDL_mutexP(lock) // take lock -#endif -#ifndef SDL_mutexV -#define SDL_mutexV(lock) // release lock -#endif -#endif - #endif extern SDL_Thread *font_thread; @@ -86,29 +60,18 @@ extern int font_socket_fd; extern int no_system_fonts; extern int all_locale_fonts; -/* FIXME: SDL_ttf is up to 2.0.8, so we can probably fully remove this; - -bjk 2007.06.05 */ -/* -TTF_Font *BUGFIX_TTF_OpenFont206(const char *const file, int ptsize); -#define TTF_OpenFont BUGFIX_TTF_OpenFont206 -*/ - /* Stuff that wraps either SDL_Pango or SDL_TTF for font rendering: */ enum { -#ifndef NO_SDLPANGO FONT_TYPE_PANGO, -#endif FONT_TYPE_TTF }; typedef struct TuxPaint_Font_s { -#ifndef NO_SDLPANGO SDLPango_Context *pango_context; -#endif int typ; TTF_Font *ttf_font; int height; @@ -194,12 +157,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf); const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf); const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf); - -#ifdef NO_SDLPANGO -TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size); -#else void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color); -#endif int load_user_fonts(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, void *vp, const char *restrict const locale); diff --git a/src/i18n.c b/src/i18n.c index 8f026d4bf..a62969ce1 100644 --- a/src/i18n.c +++ b/src/i18n.c @@ -4,7 +4,7 @@ For Tux Paint Language-related functions - Copyright (c) 2002-2022 by Bill Kendrick and others + Copyright (c) 2002-2023 by Bill Kendrick and others bill@newbreedsoftware.com https://tuxpaint.org/ @@ -23,9 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - $Id$ - - June 14, 2002 - December 11, 2022 + June 14, 2002 - April 30, 2023 */ #include @@ -256,11 +254,8 @@ static int lang_use_right_to_left[] = { -1 }; -/* FIXME: */ +/* FIXME: Remove! (We now require SDL_Pango all the time, so this is unnecessary -bjk 2023.04.30) */ static int lang_use_right_to_left_word[] = { -#ifdef NO_SDLPANGO - LANG_HE, -#endif -1 }; @@ -1334,15 +1329,3 @@ int setup_i18n(const char *restrict lang, const char *restrict locale, int *num_ locale = ""; return set_current_language(locale, num_wished_langs); } - -#ifdef NO_SDLPANGO -/** - * FIXME - */ -int smash_i18n(void) -{ - int tmp; - - return set_current_language("C", &tmp); -} -#endif diff --git a/src/i18n.h b/src/i18n.h index 032a67221..b9014f493 100644 --- a/src/i18n.h +++ b/src/i18n.h @@ -4,7 +4,7 @@ For Tux Paint Language-related functions - Copyright (c) 2002-2022 by Bill Kendrick and others + Copyright (c) 2002-2023 by Bill Kendrick and others bill@newbreedsoftware.com https://tuxpaint.org/ @@ -23,9 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - $Id$ - - June 14, 2002 - December 11, 2022 + June 14, 2002 - April 30, 2023 */ @@ -209,8 +207,4 @@ int get_current_language(void); int setup_i18n(const char *restrict lang, const char *restrict locale, int *ptr_num_wished_languages) MUST_CHECK; void mysetenv(const char *name, const char *value); -#ifdef NO_SDLPANGO - int smash_i18n(void) MUST_CHECK; -#endif - #endif diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 353a96854..194b870da 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - April 28, 2023 + June 14, 2002 - April 30, 2023 */ #include "platform.h" @@ -452,8 +452,6 @@ int iswprint(wchar_t wc) #endif -#ifndef NO_SDLPANGO - /* The following section renames global variables defined in SDL_Pango.h to avoid errors during linking. It is okay to rename these variables because they are constants. @@ -487,7 +485,7 @@ int iswprint(wchar_t wc) #include #include #endif -#endif /* !defined(NO_SDLPANGO) */ + #ifndef NOSOUND @@ -1710,10 +1708,7 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font, const char *restr { SDL_Surface *ret = NULL; int height; - -#ifndef NO_SDLPANGO SDLPango_Matrix pango_color; -#endif if (font == NULL) { @@ -1722,7 +1717,6 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font, const char *restr return NULL; } -#ifndef NO_SDLPANGO if (font->typ == FONT_TYPE_PANGO) { sdl_color_to_pango_color(color, &pango_color); @@ -1740,7 +1734,6 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font, const char *restr SDLPango_SetText_GivenAlignment(font->pango_context, str, -1, SDLPANGO_ALIGN_CENTER); ret = SDLPango_CreateSurfaceDraw(font->pango_context); } -#endif if (font->typ == FONT_TYPE_TTF) { @@ -1805,21 +1798,17 @@ static SDL_Surface *render_text_w(TuxPaint_Font * restrict font, const wchar_t * SDL_Surface *ret = NULL; int height; Uint16 *ustr; - -#ifndef NO_SDLPANGO int utfstr_max; char *utfstr; SDLPango_Matrix pango_color; -#endif -#ifndef NO_SDLPANGO if (font->typ == FONT_TYPE_PANGO) { sdl_color_to_pango_color(color, &pango_color); SDLPango_SetDefaultColor(font->pango_context, &pango_color); -/* Convert from 16-bit UNICODE to UTF-8 encoded for SDL_Pango: */ + /* Convert from 16-bit UNICODE to UTF-8 encoded for SDL_Pango: */ utfstr_max = (sizeof(char) * 4 * (wcslen(str) + 1)); utfstr = (char *)malloc(utfstr_max); @@ -1829,7 +1818,6 @@ static SDL_Surface *render_text_w(TuxPaint_Font * restrict font, const wchar_t * SDLPango_SetText(font->pango_context, utfstr, -1); ret = SDLPango_CreateSurfaceDraw(font->pango_context); } -#endif if (font->typ == FONT_TYPE_TTF) { @@ -2248,9 +2236,7 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Re static void handle_active(SDL_Event * event); /*static char *replace_tilde(const char* const path);*/ -#ifdef NO_SDLPANGO static void anti_carriage_return(int left, int right, int cur_top, int new_top, int cur_bot, int line_width); -#endif static void load_starter_id(char *saved_id, FILE * fil); static void load_starter(char *img_id); static void load_template(char *img_id); @@ -7893,12 +7879,6 @@ void show_version(int details) printf(" Bilinear scaling enabled (BILINEAR)\n"); #endif -#ifdef NO_SDLPANGO - printf(" Pango support disabled (NO_SDLPANGO)\n"); -#else - printf(" Pango support enabled (not NO_SDLPANGO)\n"); -#endif - #ifdef NOSVG printf(" SVG support disabled (NOSVG)\n"); #else @@ -9233,7 +9213,7 @@ static int load_user_fonts_stub(void *vp) } #endif -#ifndef NO_SDLPANGO + volatile long fontconfig_thread_done = 0; /** @@ -9311,7 +9291,7 @@ static int generate_fontconfig_cache( __attribute__((unused)) { return generate_fontconfig_cache_real(); } -#endif + #define hex2dec(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \ ((c) >= 'A' && (c) <= 'F') ? ((c) - 'A' + 10) : \ @@ -12688,21 +12668,7 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, SDL_Surface *text; TuxPaint_Font *myfont = medium_font; SDL_Rect dest; - -#ifdef NO_SDLPANGO - int len; - int x, y, j; - unsigned int i; - char substr[512]; - unsigned char *locale_str; - char *tstr; - unsigned char utf8_char[5]; - SDL_Rect src; - int utf8_str_len, last_text_height; - unsigned char utf8_str[512]; -#else SDLPango_Matrix pango_color; -#endif if (str == NULL || str[0] == '\0') @@ -12718,7 +12684,6 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, } -#ifndef NO_SDLPANGO /* Letting SDL_Pango do all this stuff! */ sdl_color_to_pango_color(color, &pango_color); @@ -12761,329 +12726,6 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, SDL_BlitSurface(text, NULL, screen, &dest); SDL_FreeSurface(text); } -#else - - /* Cursor starting position: */ - - x = left; - y = top; - - last_text_height = 0; - - debug(str); - debug(gettext(str)); - debug("..."); - - if (strcmp(str, "") != 0) - { - if (want_right_to_left == 0) - locale_str = (unsigned char *)strdup(gettext(str)); - else - locale_str = (unsigned char *)textdir(gettext(str)); - - - /* For each UTF8 character: */ - - utf8_str_len = 0; - utf8_str[0] = '\0'; - - for (i = 0; i <= strlen((char *)locale_str); i++) - { - if (locale_str[i] < 128) - { - utf8_str[utf8_str_len++] = locale_str[i]; - utf8_str[utf8_str_len] = '\0'; - - - /* Space? Blit the word! (Word-wrap if necessary) */ - - if (locale_str[i] == ' ' || locale_str[i] == '\0') - { - if (only_uppercase) - { - char *upper_utf8_str = uppercase((char *)utf8_str); - - text = render_text(myfont, (char *)upper_utf8_str, color); - free(upper_utf8_str); - } - else - text = render_text(myfont, (char *)utf8_str, color); - - if (!text) - continue; /* Didn't render anything... */ - - /* ----------- */ - if (text->w > right - left) - { - /* Move left and down (if not already at left!) */ - - if (x > left) - { - if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); - - x = left; - y = y + text->h; - } - - - /* Junk the blitted word; it's too long! */ - - last_text_height = text->h; - SDL_FreeSurface(text); - - - /* For each UTF8 character: */ - - for (j = 0; j < utf8_str_len; j++) - { - /* How many bytes does this character need? */ - - if (utf8_str[j] < 128) /* 0xxx xxxx - 1 byte */ - { - utf8_char[0] = utf8_str[j]; - utf8_char[1] = '\0'; - } - else if ((utf8_str[j] & 0xE0) == 0xC0) /* 110x xxxx - 2 bytes */ - { - utf8_char[0] = utf8_str[j]; - utf8_char[1] = utf8_str[j + 1]; - utf8_char[2] = '\0'; - j = j + 1; - } - else if ((utf8_str[j] & 0xF0) == 0xE0) /* 1110 xxxx - 3 bytes */ - { - utf8_char[0] = utf8_str[j]; - utf8_char[1] = utf8_str[j + 1]; - utf8_char[2] = utf8_str[j + 2]; - utf8_char[3] = '\0'; - j = j + 2; - } - else /* 1111 0xxx - 4 bytes */ - { - utf8_char[0] = utf8_str[j]; - utf8_char[1] = utf8_str[j + 1]; - utf8_char[2] = utf8_str[j + 2]; - utf8_char[3] = utf8_str[j + 3]; - utf8_char[4] = '\0'; - j = j + 3; - } - - - if (utf8_char[0] != '\0') - { - text = render_text(myfont, (char *)utf8_char, color); - if (text != NULL) - { - if (x + text->w > right) - { - if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); - - x = left; - y = y + text->h; - } - - dest.x = x; - - if (need_right_to_left && want_right_to_left) - dest.y = top; - else - dest.y = y; - - SDL_BlitSurface(text, NULL, screen, &dest); - - last_text_height = text->h; - - x = x + text->w; - - SDL_FreeSurface(text); - } - } - } - } - else - { - /* Not too wide for one line... */ - - if (x + text->w > right) - { - /* This word needs to move down? */ - - if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); - - x = left; - y = y + text->h; - } - - dest.x = x; - - if (need_right_to_left && want_right_to_left) - dest.y = top; - else - dest.y = y; - - SDL_BlitSurface(text, NULL, screen, &dest); - - last_text_height = text->h; - x = x + text->w; - - SDL_FreeSurface(text); - } - - - utf8_str_len = 0; - utf8_str[0] = '\0'; - } - } - else if ((locale_str[i] & 0xE0) == 0xC0) - { - utf8_str[utf8_str_len++] = locale_str[i]; - utf8_str[utf8_str_len++] = locale_str[i + 1]; - utf8_str[utf8_str_len] = '\0'; - i++; - } - else if ((locale_str[i] & 0xF0) == 0xE0) - { - utf8_str[utf8_str_len++] = locale_str[i]; - utf8_str[utf8_str_len++] = locale_str[i + 1]; - utf8_str[utf8_str_len++] = locale_str[i + 2]; - utf8_str[utf8_str_len] = '\0'; - i = i + 2; - } - else - { - utf8_str[utf8_str_len++] = locale_str[i]; - utf8_str[utf8_str_len++] = locale_str[i + 1]; - utf8_str[utf8_str_len++] = locale_str[i + 2]; - utf8_str[utf8_str_len++] = locale_str[i + 3]; - utf8_str[utf8_str_len] = '\0'; - i = i + 3; - } - } - - free(locale_str); - } - else if (strlen(str) != 0) - { - /* Truncate if too big! (sorry!) */ - - { - char *s1 = gettext(str); - - if (want_right_to_left) - { - char *freeme = s1; - - s1 = textdir(s1); - free(freeme); - } - tstr = uppercase(s1); - free(s1); - } - - if (strlen(tstr) > sizeof(substr) - 1) - tstr[sizeof(substr) - 1] = '\0'; - - - /* For each word... */ - - for (i = 0; i < strlen(tstr); i++) - { - /* Figure out the word... */ - - len = 0; - - for (j = i; tstr[j] != ' ' && tstr[j] != '\0'; j++) - { - substr[len++] = tstr[j]; - } - - substr[len++] = ' '; - substr[len] = '\0'; - - - /* Render the word for display... */ - - - if (only_uppercase) - { - char *uppercase_substr = uppercase(substr); - - text = render_text(myfont, uppercase_substr, color); - free(uppercase_substr); - } - else - text = render_text(myfont, substr, color); - - - /* If it won't fit on this line, move to the next! */ - - if (x + text->w > right) /* Correct? */ - { - if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); - - x = left; - y = y + text->h; - } - - - /* Draw the word: */ - - dest.x = x; - - if (need_right_to_left && want_right_to_left) - dest.y = top; - else - dest.y = y; - - SDL_BlitSurface(text, NULL, screen, &dest); - - - /* Move the cursor one word's worth: */ - - x = x + text->w; - - - /* Free the temp. surface: */ - - last_text_height = text->h; - SDL_FreeSurface(text); - - - /* Now on to the next word... */ - - i = j; - } - - free(tstr); - } - - - /* Right-justify the final line of text, in right-to-left mode: */ - - if (need_right_to_left && want_right_to_left && last_text_height > 0) - { - src.x = left; - src.y = top; - src.w = x - left; - src.h = last_text_height; - - dest.x = right - src.w; - dest.y = top; - - SDL_BlitSurface(screen, &src, screen, &dest); - - dest.x = left; - dest.y = top; - dest.w = (right - left - src.w); - dest.h = last_text_height; - - SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255)); - } -#endif } @@ -20737,42 +20379,6 @@ static void handle_active(SDL_Event * event) } -/** - * FIXME - */ -/* For right-to-left languages, when word-wrapping, we need to - make sure the text doesn't end up going from bottom-to-top, too! */ -#ifdef NO_SDLPANGO -static void anti_carriage_return(int left, int right, int cur_top, int new_top, int cur_bot, int line_width) -{ - SDL_Rect src, dest; - - - /* Move current set of text down one line (and right-justify it!): */ - - src.x = left; - src.y = cur_top; - src.w = line_width; - src.h = cur_bot - cur_top; - - dest.x = right - line_width; - dest.y = new_top; - - SDL_BlitSurface(screen, &src, screen, &dest); - - - /* Clear the top line for new text: */ - - dest.x = left; - dest.y = cur_top; - dest.w = right - left; - dest.h = new_top - cur_top; - - SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255)); -} -#endif - - /** * FIXME */ @@ -28971,10 +28577,7 @@ 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 render_scale = 1.0; @@ -28989,9 +28592,7 @@ static void setup(void) im_init(&im_data, get_current_language()); -#ifndef NO_SDLPANGO SDLPango_Init(); -#endif #ifndef WIN32 putenv((char *)"SDL_VIDEO_X11_WMCLASS=TuxPaint.TuxPaint"); @@ -29513,9 +29114,6 @@ static void setup(void) show_progress_bar(screen); - - -#ifndef NO_SDLPANGO /* Let Pango & fontcache do their work without locking up */ fontconfig_thread_done = 0; @@ -29551,7 +29149,6 @@ static void setup(void) run_font_scanner(screen, texture, renderer, lang_prefixes[get_current_language()]); #endif -#endif medium_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, DATA_PREFIX "fonts/default_font.ttf", @@ -29929,20 +29526,9 @@ static void setup(void) exit(1); } - -#ifdef NO_SDLPANGO - locale_font = load_locale_font(medium_font, 18); -#else locale_font = medium_font; -#endif -#if 0 - /* put elsewhere for THREADED_FONTS */ - /* Load user fonts, for the text tool */ - load_user_fonts(); -#endif - if (!dont_load_stamps) load_stamps(screen); @@ -30440,13 +30026,7 @@ int main(int argc, char *argv[]) #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 */ - DEBUG_PRINTF("Running font scanner\n"); - run_font_scanner(screen, texture, renderer, lang_prefixes[get_current_language()]); -#else DEBUG_PRINTF("NOT running font scanner\n"); -#endif #endif /* Warnings to satisfy SF.net Bug #3327493 -bjk 2011.06.24 */ @@ -30471,7 +30051,7 @@ int main(int argc, char *argv[]) DEBUG_PRINTF("Seconds in late start-up: %.3f\n", (double)(time2 - time1) / CLOCK_SPEED); -#if defined(DEBUG) && !defined(NO_SDLPANGO) +#ifdef DEBUG /* Confirm pango's character set */ if (1) {