From 3d15a468cd5d245b337771b8e4db9fef05674124 Mon Sep 17 00:00:00 2001 From: Albert Cahalan Date: Sun, 22 Nov 2009 23:17:35 +0000 Subject: [PATCH] lots of functions made static (some had to be moved) --- src/fonts.c | 1221 ++++++++++++++++++++-------------------- src/fonts.h | 28 +- src/im.c | 254 +++++---- src/im.h | 3 - src/parse.gperf | 2 +- src/parse.h | 2 +- src/pixels.c | 16 +- src/pixels.h | 11 - src/playsound.c | 2 +- src/postscript_print.c | 7 +- src/tuxpaint.c | 254 +++++---- 11 files changed, 884 insertions(+), 916 deletions(-) diff --git a/src/fonts.c b/src/fonts.c index 45158015e..d87bc3744 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -125,28 +125,27 @@ int no_system_fonts; int no_system_fonts = 1; #endif int all_locale_fonts; -volatile long font_thread_done = 0, font_thread_aborted = 0; -volatile long waiting_for_fonts = 0; -int font_scanner_pid; +volatile long font_thread_done; +static volatile long font_thread_aborted; +volatile long waiting_for_fonts; +static int font_scanner_pid; int font_socket_fd; TuxPaint_Font *medium_font, *small_font, *large_font, *locale_font; family_info **user_font_families; -int num_font_families = 0; -int num_font_families_max = 0; +int num_font_families; +static int num_font_families_max; style_info **user_font_styles; -int num_font_styles = 0; -int num_font_styles_max = 0; +int num_font_styles; +int num_font_styles_max; -int text_state = 0; +int text_state; unsigned text_size = 4; // initial text size int button_label_y_nudge; -static void loadfonts_locale_filter(SDL_Surface * screen, const char *const dir, const char *restrict locale); - /* Unfortunately, there is a bug in SDL_ttf-2.0.6, the current version that causes a segmentation fault if an attempt is made to call @@ -178,16 +177,9 @@ TTF_Font *BUGFIX_TTF_OpenFont206(const char *const file, int ptsize) /* #define TTF_OpenFont BUGFIX_TTF_OpenFont206 */ -TuxPaint_Font *try_alternate_font(int size) -{ #ifndef NO_SDLPANGO - - /* Do we need to do anything when we use SDL_Pango? - -bjk 2007.07.12 */ - - (void)size; // silence 'unused parameter' warning - -#else +static TuxPaint_Font *try_alternate_font(int size) +{ char str[128]; char prefix[64]; char *p; @@ -200,55 +192,48 @@ TuxPaint_Font *try_alternate_font(int size) return TuxPaint_Font_OpenFont("", str, size); } -#endif - return NULL; } +#endif +#ifdef NO_SDLPANGO TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size) { + if (!need_own_font) + return fallback; + TuxPaint_Font *ret = NULL; if (need_own_font) { -#ifndef NO_SDLPANGO - - /* FIXME: Do we even need to do anything when using SDL_Pango? -bjk 2007.07.12 */ - - (void)size; // silence 'unused parameter' warning - - return(fallback); - -#else char str[128]; - snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", - DATA_PREFIX, lang_prefix); + snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, lang_prefix); ret = TuxPaint_Font_OpenFont("", str, size); #ifdef __APPLE__ - if (ret == NULL) + if (!ret) { snprintf(str, sizeof(str), "%sfonts/%s.ttf", DATA_PREFIX, lang_prefix); ret = TuxPaint_Font_OpenFont("", str, size); } - if (ret == NULL) + if (!ret) { snprintf(str, sizeof(str), "/Library/Fonts/%s.ttf", lang_prefix); ret = TuxPaint_Font_OpenFont("", str, size); } - if (ret == NULL) + if (!ret) { snprintf(str, sizeof(str), "%s/%s.ttf", macosx.fontsPath, lang_prefix); ret = TuxPaint_Font_OpenFont("", str, size); } #endif - if (ret == NULL) + if (!ret) { ret = try_alternate_font(size); - if (ret == NULL) + if (!ret) { fprintf( stderr, @@ -263,11 +248,10 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size) button_label_y_nudge = smash_i18n(); } } - -#endif } return ret ? ret : fallback; } +#endif void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) { @@ -332,13 +316,12 @@ TuxPaint_Font * TuxPaint_Font_OpenFont(const char * pangodesc, const char * ttff if (ttffilename != NULL && ttffilename[0] != '\0') { - int i; #ifdef DEBUG printf("Opening TTF\n"); fflush(stdout); #endif #ifdef __APPLE__ - i = 0; + int i = 0; while (problemFonts[i] != NULL) { if (!strcmp(ttffilename, problemFonts[i++])) @@ -407,7 +390,7 @@ void reliable_write(int fd, const void *buf, size_t count) } -void reliable_read(int fd, void *buf, size_t count) +static void reliable_read(int fd, void *buf, size_t count) { struct pollfd p; do @@ -439,6 +422,581 @@ void reliable_read(int fd, void *buf, size_t count) } +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; + int boldmax; + int boldmin; + int bolduse; + int spot; + family_info *fi; + +#if 0 +// THREADED_FONTS + if (count < 1 || count > 4) + { + printf("\n::::::: %d styles in %s:\n", count, base[0]->family); + i = count; + while (i--) + { + printf(" %s\n", base[i]->style); + } + } +#endif + + i = count; + while (i--) + boldcounts[base[i]->boldness]++; + + boldmax = base[0]->boldness; + boldmin = base[0]->boldness; + bolduse = 0; + + i = 4; + while (i--) + { + if (!boldcounts[i]) + continue; + if (i > boldmax) + boldmax = i; + if (i < boldmin) + boldmin = i; + bolduse++; + } + if (likely(bolduse <= 2)) + { + // in case they are same, we want non-bold, + // so that setting goes second + boldmap[boldmax] = 1; + boldmap[boldmin] = 0; + } + else if (count == 3) + { + int boldmid; + int zmin = 0, zmid = 0, zmax = 0; + + boldmap[boldmax] = 1; + boldmap[boldmin] = 0; + boldmid = boldcounts[boldmin + 1] ? boldmin + 1 : boldmin + 2; + + i = 3; + while (i--) + { + if (base[i]->boldness == boldmin) + zmin = base[i]->italic; + if (base[i]->boldness == boldmid) + zmid = base[i]->italic; + if (base[i]->boldness == boldmax) + zmax = base[i]->italic; + } + if (zmin != zmid) + boldmap[boldmid] = 0; + else if (zmid != zmax) + boldmap[boldmid] = 1; + else if (boldmin == 0 && boldmid == 1) + { + boldmap[0] = -1; + boldmap[1] = 0; + } + } + else + { + int claimed_bold = boldcounts[3]; + int claimed_norm = boldcounts[1]; + + // 3 or 4 boldness levels, 4 or more styles! + // This is going to be random hacks and hopes. + + // bold is bold + boldmap[3] = 1; + + // norm is norm + boldmap[1] = 0; + + // classify demi-bold or medium + if (claimed_bold < 2) + { + boldmap[2] = 1; + claimed_bold += boldcounts[2]; + } + else if (claimed_norm < 2) + { + boldmap[2] = 0; + claimed_norm += boldcounts[2]; + } + + // classify lightface + if (claimed_norm < 2) + { + boldmap[0] = 0; + //claimed_norm += boldcounts[0]; + } + } + + if (num_font_families == num_font_families_max) + { + num_font_families_max = num_font_families_max * 5 / 4 + 30; + user_font_families = + realloc(user_font_families, + num_font_families_max * sizeof *user_font_families); + } + + fi = calloc(1, sizeof *fi); + user_font_families[num_font_families++] = fi; + fi->directory = strdup(base[0]->directory); + fi->family = strdup(base[0]->family); + fi->score = base[0]->truetype + base[0]->score; + i = count; + while (i--) + { + int b = boldmap[base[i]->boldness]; + if (b == -1) + { +#if 0 +// THREADED_FONTS + printf("too many boldness levels, discarding: %s, %s\n", + base[i]->family, base[i]->style); +#endif + continue; + } + spot = b ? TTF_STYLE_BOLD : 0; + spot += base[i]->italic ? TTF_STYLE_ITALIC : 0; + if (fi->filename[spot]) + { +#if 0 +// THREADED_FONTS + printf("duplicates, discarding: %s, %s\n", base[i]->family, + base[i]->style); + printf("b %d, spot %d\n", b, spot); + printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1], + fi->filename[2], fi->filename[3]); +#endif + continue; + } + fi->filename[spot] = strdup(base[i]->filename); + fi->score += 2; + } + if (!fi->filename[0] && !fi->filename[1]) + { + fi->filename[0] = fi->filename[2]; + fi->filename[2] = NULL; + fi->filename[1] = fi->filename[3]; + fi->filename[3] = NULL; + } + if (!fi->filename[0] && !fi->filename[2]) + { + fi->filename[0] = fi->filename[1]; + fi->filename[1] = NULL; + fi->filename[2] = fi->filename[3]; + fi->filename[3] = NULL; + } + if (!fi->filename[0]) + { + fi->filename[0] = strdup(fi->filename[TTF_STYLE_BOLD]); + } +} + + +// void qsort(void *base, size_t nmemb, size_t size, +// int(*compar)(const void *, const void *)); + + +// For qsort() and other use, to see if font files are groupable +static int compar_fontgroup(const void *v1, const void *v2) +{ + const style_info *s1 = *(style_info **) v1; + const style_info *s2 = *(style_info **) v2; + int rc; + + rc = strcmp(s1->directory, s2->directory); + if (rc) + return rc; + + rc = s1->truetype - s2->truetype; + if (rc) + return rc; + + return strcmp(s1->family, s2->family); +} + + +// For qsort() and other use, to see if font files are duplicates +static int compar_fontkiller(const void *v1, const void *v2) +{ + const family_info *f1 = *(family_info **) v1; + const family_info *f2 = *(family_info **) v2; + int rc; + + rc = strcmp(f1->family, f2->family); + if (rc) + return rc; + + return f1->score - f2->score; +} + + +// For qsort() and other use, to order the worst ones last +static int compar_fontscore(const void *v1, const void *v2) +{ + const family_info *f1 = *(family_info **) v1; + const family_info *f2 = *(family_info **) v2; + + return f2->score - f1->score; +} + + +// Font style names are a mess that we must try to make +// sense of. For example... +// +// Cooper: Light, Medium, Light Bold, Black +// HoeflerText: (nil), Black +static void parse_font_style(style_info * si) +{ + int have_light = 0; + int have_demi = 0; + int have_bold = 0; + int have_medium = 0; + int have_black = 0; + int have_heavy = 0; + + int stumped = 0; + char *sp = si->style; + + si->italic = 0; + + + while (*sp) + { + if (*sp == ' ') + { + sp++; + continue; + } + if (!strncasecmp(sp, "Bold", strlen("Bold"))) + { + sp += strlen("Bold"); + have_bold = 1; + continue; + } + if (!strncasecmp(sp, "Regular", strlen("Regular"))) + { + sp += strlen("Regular"); + continue; + } + if (!strncasecmp(sp, "Italic", strlen("Italic"))) + { + sp += strlen("Italic"); + si->italic = 1; + continue; + } + if (!strncasecmp(sp, "Oblique", strlen("Oblique"))) + { + sp += strlen("Oblique"); + si->italic = 1; + continue; + } + // move " Condensed" from style to family + if (!strncasecmp(sp, "Condensed", strlen("Condensed"))) + { + size_t len = strlen(si->family); + char *name = malloc(len + strlen(" Condensed") + 1); + sp += strlen("Condensed"); + memcpy(name, si->family, len); + strcpy(name + len, " Condensed"); + free(si->family); + si->family = name; + continue; + } + if (!strncasecmp(sp, "Light", strlen("Light"))) + { + sp += strlen("Light"); + have_light = 1; + continue; + } + if (!strncasecmp(sp, "Medium", strlen("Medium"))) + { + sp += strlen("Medium"); + have_medium = 1; + continue; + } + if (!strncasecmp(sp, "Demi", strlen("Demi"))) + { + sp += strlen("Demi"); + have_demi = 1; + continue; + } + if (!strncasecmp(sp, "Heavy", strlen("Heavy"))) + { + sp += strlen("Heavy"); + have_heavy = 1; + continue; + } + if (!strncasecmp(sp, "Normal", strlen("Normal"))) + { + sp += strlen("Normal"); + continue; + } + if (!strncasecmp(sp, "Black", strlen("Black"))) + { + sp += strlen("Black"); + have_black = 1; + continue; + } + if (!strncasecmp(sp, "Roman", strlen("Roman"))) + { + sp += strlen("Roman"); + continue; + } + if (!strncasecmp(sp, "Book", strlen("Book"))) + { + sp += strlen("Book"); + continue; + } + if (!strncasecmp(sp, "Chancery", strlen("Chancery"))) + { + sp += strlen("Chancery"); + si->italic = 1; + continue; + } + if (!strncasecmp(sp, "Thin", strlen("Thin"))) + { + sp += strlen("Thin"); + have_light = 1; + continue; + } + if (!strncmp(sp, "LR", strlen("LR"))) + { + sp += strlen("LR"); + continue; + } + + if (!stumped) + { + stumped = 1; +#if 0 +// THREADED_FONTS + printf("Font style parser stumped by \"%s\".\n", si->style); +#endif + } + sp++; // bad: an unknown character + } + + + if (have_demi || have_medium) + si->boldness = 2; + else if (have_bold || have_black || have_heavy) // TODO: split these + si->boldness = 3; + else if (have_light) + si->boldness = 0; + else + si->boldness = 1; + + // we'll count both TrueType and OpenType + si->truetype = !!strcasestr(si->filename, ".ttf") + || !!strcasestr(si->filename, ".otf"); +} + + +static void dupe_markdown_range(family_info ** base, int count) +{ + int bestscore = -999; + int bestslot = 0; + int i = count; + while (i--) + { + int score = base[i]->score; + if (score <= bestscore) + continue; + bestscore = score; + bestslot = i; + } + i = count; + while (i--) + { + if (i == bestslot) + continue; + base[i]->score = -999; + } +} + + +static void groupfonts(void) +{ + char **cpp; + int i = num_font_styles; + int low = 0; + + while (i--) + parse_font_style(user_font_styles[i]); + + qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0], + compar_fontgroup); + //printf("groupfonts() qsort(user_font_styles...)\n"); + //fflush(stdout); + + for (;;) + { + int high = low; + if (low >= num_font_styles) + break; + for (;;) + { + if (++high >= num_font_styles) + break; + if (compar_fontgroup(user_font_styles + low, user_font_styles + high)) + break; + } + groupfonts_range(user_font_styles + low, high - low); + low = high; + } + + i = num_font_styles; + while (i--) + { + free(user_font_styles[i]->filename); + free(user_font_styles[i]->directory); + free(user_font_styles[i]->family); + free(user_font_styles[i]->style); + free(user_font_styles[i]); + } + free(user_font_styles); + user_font_styles = NULL; // just to catch bugs + + qsort(user_font_families, num_font_families, sizeof user_font_families[0], + compar_fontkiller); + //printf(stderr, "groupfonts() qsort(user_font_families 1...)\n"); + //fflush(stdout); + low = 0; + for (;;) + { + int high = low; + if (low >= num_font_families) + break; + for (;;) + { + if (++high >= num_font_families) + break; + if (strcmp + (user_font_families[low]->family, user_font_families[high]->family)) + break; + } + dupe_markdown_range(user_font_families + low, high - low); + low = high; + } + qsort(user_font_families, num_font_families, sizeof user_font_families[0], + compar_fontscore); + //printf("groupfonts() qsort(user_font_families 2...)\n"); + //fflush(stdout); + if (user_font_families[0]->score < 0) + printf("sorted the wrong way, or all fonts were unusable\n"); +#if 0 +// THREADED_FONTS + printf("Trim starting with %d families\n", num_font_families); +#endif + while (num_font_families > 1 + && user_font_families[num_font_families - 1]->score < 0) + { + i = --num_font_families; + free(user_font_families[i]->directory); + free(user_font_families[i]->family); + cpp = user_font_families[i]->filename; + if (cpp[0]) + free(cpp[0]); + if (cpp[1]) + free(cpp[1]); + if (cpp[2]) + free(cpp[2]); + if (cpp[3]) + free(cpp[3]); + free(user_font_families[i]); + user_font_families[i] = NULL; + } +#if 0 +// THREADED_FONTS + printf("Trim ending with %d families\n", num_font_families); +#endif +} + + +static void loadfonts_locale_filter(SDL_Surface * screen, const char *const dir, const char *restrict locale) +{ + char buf[TP_FTW_PATHSIZE]; + unsigned dirlen = strlen(dir); + + memcpy(buf, dir, dirlen); + tp_ftw(screen, buf, dirlen, 1, loadfont_callback, locale); +} + +static void loadfonts(SDL_Surface * screen, const char *const dir) +{ + loadfonts_locale_filter(screen, dir, NULL); +} + + +static int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict locale) +{ + char *homedirdir; + + (void) vp; // junk passed by threading library + + loadfonts_locale_filter(screen, DATA_PREFIX "fonts", locale); + + if (!no_system_fonts) + { +#ifdef WIN32 + homedirdir = GetSystemFontDir(); + loadfonts(screen, homedirdir); + free(homedirdir); +#elif defined(__BEOS__) + loadfonts(screen, "/boot/home/config/font/ttffonts"); + loadfonts(screen, "/usr/share/fonts"); + loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); +#elif defined(__APPLE__) + loadfonts(screen, "/System/Library/Fonts"); + loadfonts(screen, "/Library/Fonts"); + loadfonts(screen, macosx.fontsPath); + loadfonts(screen, "/usr/share/fonts"); + loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); +#elif defined(__sun__) + loadfonts(screen, "/usr/openwin/lib/X11/fonts"); + loadfonts(screen, "/usr/share/fonts"); + loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); +#else + loadfonts(screen, "/usr/share/feh/fonts"); + loadfonts(screen, "/usr/share/fonts"); + loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); + loadfonts(screen, "/usr/share/texmf/fonts"); + loadfonts(screen, "/usr/share/grace/fonts/type1"); + loadfonts(screen, "/usr/share/hatman/fonts"); + loadfonts(screen, "/usr/share/icewm/themes/jim-mac"); + loadfonts(screen, "/usr/share/vlc/skins2/fonts"); + loadfonts(screen, "/usr/share/xplanet/fonts"); +#endif + } + + homedirdir = get_fname("fonts", DIR_DATA); + loadfonts(screen, homedirdir); + free(homedirdir); + +#ifdef WIN32 + homedirdir = get_fname("data/fonts", DIR_DATA); + loadfonts(screen, homedirdir); + free(homedirdir); +#endif + + groupfonts(); + + font_thread_done = 1; + waiting_for_fonts = 0; + // FIXME: need a memory barrier here + return 0; // useless, wanted by threading library +} + + + + void run_font_scanner(SDL_Surface * screen, const char *restrict locale) { int sv[2]; @@ -682,564 +1240,6 @@ void receive_some_font_info(SDL_Surface * screen) #endif -int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict locale) -{ - char *homedirdir; - - (void) vp; // junk passed by threading library - - loadfonts_locale_filter(screen, DATA_PREFIX "fonts", locale); - - if (!no_system_fonts) - { -#ifdef WIN32 - homedirdir = GetSystemFontDir(); - loadfonts(screen, homedirdir); - free(homedirdir); -#elif defined(__BEOS__) - loadfonts(screen, "/boot/home/config/font/ttffonts"); - loadfonts(screen, "/usr/share/fonts"); - loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); -#elif defined(__APPLE__) - loadfonts(screen, "/System/Library/Fonts"); - loadfonts(screen, "/Library/Fonts"); - loadfonts(screen, macosx.fontsPath); - loadfonts(screen, "/usr/share/fonts"); - loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); -#elif defined(__sun__) - loadfonts(screen, "/usr/openwin/lib/X11/fonts"); - loadfonts(screen, "/usr/share/fonts"); - loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); -#else - loadfonts(screen, "/usr/share/feh/fonts"); - loadfonts(screen, "/usr/share/fonts"); - loadfonts(screen, "/usr/X11R6/lib/X11/fonts"); - loadfonts(screen, "/usr/share/texmf/fonts"); - loadfonts(screen, "/usr/share/grace/fonts/type1"); - loadfonts(screen, "/usr/share/hatman/fonts"); - loadfonts(screen, "/usr/share/icewm/themes/jim-mac"); - loadfonts(screen, "/usr/share/vlc/skins2/fonts"); - loadfonts(screen, "/usr/share/xplanet/fonts"); -#endif - } - - homedirdir = get_fname("fonts", DIR_DATA); - loadfonts(screen, homedirdir); - free(homedirdir); - -#ifdef WIN32 - homedirdir = get_fname("data/fonts", DIR_DATA); - loadfonts(screen, homedirdir); - free(homedirdir); -#endif - - groupfonts(); - - font_thread_done = 1; - waiting_for_fonts = 0; - // FIXME: need a memory barrier here - return 0; // useless, wanted by threading library -} - - -// void qsort(void *base, size_t nmemb, size_t size, -// int(*compar)(const void *, const void *)); - - -// For qsort() and other use, to see if font files are groupable -int compar_fontgroup(const void *v1, const void *v2) -{ - const style_info *s1 = *(style_info **) v1; - const style_info *s2 = *(style_info **) v2; - int rc; - - rc = strcmp(s1->directory, s2->directory); - if (rc) - return rc; - - rc = s1->truetype - s2->truetype; - if (rc) - return rc; - - return strcmp(s1->family, s2->family); -} - - -// For qsort() and other use, to see if font files are duplicates -int compar_fontkiller(const void *v1, const void *v2) -{ - const family_info *f1 = *(family_info **) v1; - const family_info *f2 = *(family_info **) v2; - int rc; - - rc = strcmp(f1->family, f2->family); - if (rc) - return rc; - - return f1->score - f2->score; -} - - -// For qsort() and other use, to order the worst ones last -int compar_fontscore(const void *v1, const void *v2) -{ - const family_info *f1 = *(family_info **) v1; - const family_info *f2 = *(family_info **) v2; - - return f2->score - f1->score; -} - - -// Font style names are a mess that we must try to make -// sense of. For example... -// -// Cooper: Light, Medium, Light Bold, Black -// HoeflerText: (nil), Black -void parse_font_style(style_info * si) -{ - int have_light = 0; - int have_demi = 0; - int have_bold = 0; - int have_medium = 0; - int have_black = 0; - int have_heavy = 0; - - int stumped = 0; - char *sp = si->style; - - si->italic = 0; - - - while (*sp) - { - if (*sp == ' ') - { - sp++; - continue; - } - if (!strncasecmp(sp, "Bold", strlen("Bold"))) - { - sp += strlen("Bold"); - have_bold = 1; - continue; - } - if (!strncasecmp(sp, "Regular", strlen("Regular"))) - { - sp += strlen("Regular"); - continue; - } - if (!strncasecmp(sp, "Italic", strlen("Italic"))) - { - sp += strlen("Italic"); - si->italic = 1; - continue; - } - if (!strncasecmp(sp, "Oblique", strlen("Oblique"))) - { - sp += strlen("Oblique"); - si->italic = 1; - continue; - } - // move " Condensed" from style to family - if (!strncasecmp(sp, "Condensed", strlen("Condensed"))) - { - size_t len = strlen(si->family); - char *name = malloc(len + strlen(" Condensed") + 1); - sp += strlen("Condensed"); - memcpy(name, si->family, len); - strcpy(name + len, " Condensed"); - free(si->family); - si->family = name; - continue; - } - if (!strncasecmp(sp, "Light", strlen("Light"))) - { - sp += strlen("Light"); - have_light = 1; - continue; - } - if (!strncasecmp(sp, "Medium", strlen("Medium"))) - { - sp += strlen("Medium"); - have_medium = 1; - continue; - } - if (!strncasecmp(sp, "Demi", strlen("Demi"))) - { - sp += strlen("Demi"); - have_demi = 1; - continue; - } - if (!strncasecmp(sp, "Heavy", strlen("Heavy"))) - { - sp += strlen("Heavy"); - have_heavy = 1; - continue; - } - if (!strncasecmp(sp, "Normal", strlen("Normal"))) - { - sp += strlen("Normal"); - continue; - } - if (!strncasecmp(sp, "Black", strlen("Black"))) - { - sp += strlen("Black"); - have_black = 1; - continue; - } - if (!strncasecmp(sp, "Roman", strlen("Roman"))) - { - sp += strlen("Roman"); - continue; - } - if (!strncasecmp(sp, "Book", strlen("Book"))) - { - sp += strlen("Book"); - continue; - } - if (!strncasecmp(sp, "Chancery", strlen("Chancery"))) - { - sp += strlen("Chancery"); - si->italic = 1; - continue; - } - if (!strncasecmp(sp, "Thin", strlen("Thin"))) - { - sp += strlen("Thin"); - have_light = 1; - continue; - } - if (!strncmp(sp, "LR", strlen("LR"))) - { - sp += strlen("LR"); - continue; - } - - if (!stumped) - { - stumped = 1; -#if 0 -// THREADED_FONTS - printf("Font style parser stumped by \"%s\".\n", si->style); -#endif - } - sp++; // bad: an unknown character - } - - - if (have_demi || have_medium) - si->boldness = 2; - else if (have_bold || have_black || have_heavy) // TODO: split these - si->boldness = 3; - else if (have_light) - si->boldness = 0; - else - si->boldness = 1; - - // we'll count both TrueType and OpenType - si->truetype = !!strcasestr(si->filename, ".ttf") - || !!strcasestr(si->filename, ".otf"); -} - - - - -void groupfonts_range(style_info ** base, int count) -{ - int boldcounts[4] = { 0, 0, 0, 0 }; - int boldmap[4] = { -1, -1, -1, -1 }; - int i; - int boldmax; - int boldmin; - int bolduse; - int spot; - family_info *fi; - -#if 0 -// THREADED_FONTS - if (count < 1 || count > 4) - { - printf("\n::::::: %d styles in %s:\n", count, base[0]->family); - i = count; - while (i--) - { - printf(" %s\n", base[i]->style); - } - } -#endif - - i = count; - while (i--) - boldcounts[base[i]->boldness]++; - - boldmax = base[0]->boldness; - boldmin = base[0]->boldness; - bolduse = 0; - - i = 4; - while (i--) - { - if (!boldcounts[i]) - continue; - if (i > boldmax) - boldmax = i; - if (i < boldmin) - boldmin = i; - bolduse++; - } - if (likely(bolduse <= 2)) - { - // in case they are same, we want non-bold, - // so that setting goes second - boldmap[boldmax] = 1; - boldmap[boldmin] = 0; - } - else if (count == 3) - { - int boldmid; - int zmin = 0, zmid = 0, zmax = 0; - - boldmap[boldmax] = 1; - boldmap[boldmin] = 0; - boldmid = boldcounts[boldmin + 1] ? boldmin + 1 : boldmin + 2; - - i = 3; - while (i--) - { - if (base[i]->boldness == boldmin) - zmin = base[i]->italic; - if (base[i]->boldness == boldmid) - zmid = base[i]->italic; - if (base[i]->boldness == boldmax) - zmax = base[i]->italic; - } - if (zmin != zmid) - boldmap[boldmid] = 0; - else if (zmid != zmax) - boldmap[boldmid] = 1; - else if (boldmin == 0 && boldmid == 1) - { - boldmap[0] = -1; - boldmap[1] = 0; - } - } - else - { - int claimed_bold = boldcounts[3]; - int claimed_norm = boldcounts[1]; - - // 3 or 4 boldness levels, 4 or more styles! - // This is going to be random hacks and hopes. - - // bold is bold - boldmap[3] = 1; - - // norm is norm - boldmap[1] = 0; - - // classify demi-bold or medium - if (claimed_bold < 2) - { - boldmap[2] = 1; - claimed_bold += boldcounts[2]; - } - else if (claimed_norm < 2) - { - boldmap[2] = 0; - claimed_norm += boldcounts[2]; - } - - // classify lightface - if (claimed_norm < 2) - { - boldmap[0] = 0; - //claimed_norm += boldcounts[0]; - } - } - - if (num_font_families == num_font_families_max) - { - num_font_families_max = num_font_families_max * 5 / 4 + 30; - user_font_families = - realloc(user_font_families, - num_font_families_max * sizeof *user_font_families); - } - - fi = calloc(1, sizeof *fi); - user_font_families[num_font_families++] = fi; - fi->directory = strdup(base[0]->directory); - fi->family = strdup(base[0]->family); - fi->score = base[0]->truetype + base[0]->score; - i = count; - while (i--) - { - int b = boldmap[base[i]->boldness]; - if (b == -1) - { -#if 0 -// THREADED_FONTS - printf("too many boldness levels, discarding: %s, %s\n", - base[i]->family, base[i]->style); -#endif - continue; - } - spot = b ? TTF_STYLE_BOLD : 0; - spot += base[i]->italic ? TTF_STYLE_ITALIC : 0; - if (fi->filename[spot]) - { -#if 0 -// THREADED_FONTS - printf("duplicates, discarding: %s, %s\n", base[i]->family, - base[i]->style); - printf("b %d, spot %d\n", b, spot); - printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1], - fi->filename[2], fi->filename[3]); -#endif - continue; - } - fi->filename[spot] = strdup(base[i]->filename); - fi->score += 2; - } - if (!fi->filename[0] && !fi->filename[1]) - { - fi->filename[0] = fi->filename[2]; - fi->filename[2] = NULL; - fi->filename[1] = fi->filename[3]; - fi->filename[3] = NULL; - } - if (!fi->filename[0] && !fi->filename[2]) - { - fi->filename[0] = fi->filename[1]; - fi->filename[1] = NULL; - fi->filename[2] = fi->filename[3]; - fi->filename[3] = NULL; - } - if (!fi->filename[0]) - { - fi->filename[0] = strdup(fi->filename[TTF_STYLE_BOLD]); - } -} - - -void dupe_markdown_range(family_info ** base, int count) -{ - int bestscore = -999; - int bestslot = 0; - int i = count; - while (i--) - { - int score = base[i]->score; - if (score <= bestscore) - continue; - bestscore = score; - bestslot = i; - } - i = count; - while (i--) - { - if (i == bestslot) - continue; - base[i]->score = -999; - } -} - - -void groupfonts(void) -{ - char **cpp; - int i = num_font_styles; - int low = 0; - - while (i--) - parse_font_style(user_font_styles[i]); - - qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0], - compar_fontgroup); - //printf("groupfonts() qsort(user_font_styles...)\n"); - //fflush(stdout); - - for (;;) - { - int high = low; - if (low >= num_font_styles) - break; - for (;;) - { - if (++high >= num_font_styles) - break; - if (compar_fontgroup(user_font_styles + low, user_font_styles + high)) - break; - } - groupfonts_range(user_font_styles + low, high - low); - low = high; - } - - i = num_font_styles; - while (i--) - { - free(user_font_styles[i]->filename); - free(user_font_styles[i]->directory); - free(user_font_styles[i]->family); - free(user_font_styles[i]->style); - free(user_font_styles[i]); - } - free(user_font_styles); - user_font_styles = NULL; // just to catch bugs - - qsort(user_font_families, num_font_families, sizeof user_font_families[0], - compar_fontkiller); - //printf(stderr, "groupfonts() qsort(user_font_families 1...)\n"); - //fflush(stdout); - low = 0; - for (;;) - { - int high = low; - if (low >= num_font_families) - break; - for (;;) - { - if (++high >= num_font_families) - break; - if (strcmp - (user_font_families[low]->family, user_font_families[high]->family)) - break; - } - dupe_markdown_range(user_font_families + low, high - low); - low = high; - } - qsort(user_font_families, num_font_families, sizeof user_font_families[0], - compar_fontscore); - //printf("groupfonts() qsort(user_font_families 2...)\n"); - //fflush(stdout); - if (user_font_families[0]->score < 0) - printf("sorted the wrong way, or all fonts were unusable\n"); -#if 0 -// THREADED_FONTS - printf("Trim starting with %d families\n", num_font_families); -#endif - while (num_font_families > 1 - && user_font_families[num_font_families - 1]->score < 0) - { - i = --num_font_families; - free(user_font_families[i]->directory); - free(user_font_families[i]->family); - cpp = user_font_families[i]->filename; - if (cpp[0]) - free(cpp[0]); - if (cpp[1]) - free(cpp[1]); - if (cpp[2]) - free(cpp[2]); - if (cpp[3]) - free(cpp[3]); - free(user_font_families[i]); - user_font_families[i] = NULL; - } -#if 0 -// THREADED_FONTS - printf("Trim ending with %d families\n", num_font_families); -#endif -} TuxPaint_Font *getfonthandle(int desire) @@ -1389,26 +1389,11 @@ TuxPaint_Font *getfonthandle(int desire) } -void loadfonts(SDL_Surface * screen, const char *const dir) -{ - loadfonts_locale_filter(screen, dir, NULL); -} - -void loadfonts_locale_filter(SDL_Surface * screen, const char *const dir, const char *restrict locale) -{ - char buf[TP_FTW_PATHSIZE]; - unsigned dirlen = strlen(dir); - - memcpy(buf, dir, dirlen); - tp_ftw(screen, buf, dirlen, 1, loadfont_callback, locale); -} - - // backdoor into qsort operations, so we don't have to do work again -int was_bad_font; +static int was_bad_font; // see if two font surfaces are the same -int do_surfcmp(const SDL_Surface * const *const v1, +static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * const *const v2) { const SDL_Surface *const s1 = *v1; @@ -1461,7 +1446,7 @@ int do_surfcmp(const SDL_Surface * const *const v1, } // see if two font surfaces are the same -int surfcmp(const void *s1, const void *s2) +static int surfcmp(const void *s1, const void *s2) { int diff = do_surfcmp(s1, s2); if (!diff) diff --git a/src/fonts.h b/src/fonts.h index 9a0e6e94e..5b059a201 100644 --- a/src/fonts.h +++ b/src/fonts.h @@ -68,14 +68,12 @@ extern SDL_Thread *font_thread; -extern volatile long font_thread_done, font_thread_aborted; +extern volatile long font_thread_done; extern volatile long waiting_for_fonts; -extern int font_scanner_pid; extern int font_socket_fd; extern int no_system_fonts; extern int all_locale_fonts; -extern int was_bad_font; /* FIXME: SDL_ttf is up to 2.0.8, so we can probably fully remove this; -bjk 2007.06.05 */ @@ -106,13 +104,8 @@ typedef struct TuxPaint_Font_s { int TuxPaint_Font_FontHeight(TuxPaint_Font * tpf); -TuxPaint_Font *try_alternate_font(int size); -TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size); -int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict locale); - #ifdef FORKED_FONTS void reliable_write(int fd, const void *buf, size_t count); -void reliable_read(int fd, void *buf, size_t count); void run_font_scanner(SDL_Surface * screen, const char *restrict locale); void receive_some_font_info(SDL_Surface * screen); #endif @@ -171,7 +164,6 @@ extern TuxPaint_Font *medium_font, *small_font, *large_font, *locale_font; extern family_info **user_font_families; extern int num_font_families; -extern int num_font_families_max; extern style_info **user_font_styles; extern int num_font_styles; @@ -179,19 +171,8 @@ extern int num_font_styles_max; extern int button_label_y_nudge; -int compar_fontgroup(const void *v1, const void *v2); -int compar_fontkiller(const void *v1, const void *v2); -int compar_fontscore(const void *v1, const void *v2); -void parse_font_style(style_info * si); -void groupfonts_range(style_info ** base, int count); -void dupe_markdown_range(family_info ** base, int count); -void groupfonts(void); TuxPaint_Font *getfonthandle(int desire); -void loadfonts(SDL_Surface * screen, const char *const dir); -int do_surfcmp(const SDL_Surface * const *const v1, - const SDL_Surface * const *const v2); -int surfcmp(const void *s1, const void *s2); int charset_works(TuxPaint_Font * font, const char *s); TuxPaint_Font * TuxPaint_Font_OpenFont(const char * pangodesc, const char * ttffilename, int size); @@ -199,9 +180,10 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf); const char * TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf); 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); +#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 #endif diff --git a/src/im.c b/src/im.c index 477f93842..7c772a120 100644 --- a/src/im.c +++ b/src/im.c @@ -654,6 +654,139 @@ static const wchar_t* charmap_search(CHARMAP* cm, wchar_t* s) } +/* *************************************************************************** +* GENERIC IM FUNCTIONS +*/ + +/** +* Default C IM event handler. +* +* @see im_read +*/ +static int im_event_c(IM_DATA* im, SDL_keysym ks) +{ + /* Handle event requests */ + im->s[0] = L'\0'; + if(im->request != IM_REQ_TRANSLATE) return 0; + + /* Handle key stroke */ + switch(ks.sym) { + case SDLK_BACKSPACE: im->s[0] = L'\b'; break; + case SDLK_TAB: im->s[0] = L'\t'; break; + case SDLK_RETURN: im->s[0] = L'\r'; break; + default: im->s[0] = ks.unicode; + } + im->s[1] = L'\0'; + im->buf[0] = L'\0'; + + return 0; +} + +/* *************************************************************************** +* PUBLIC IM FUNCTIONS +*/ + +/** +* IM-process a character. This function simply looks up the language from +* IM and calls the appropriate im_event_() language-specific IM event +* handler. im_event_c() is called by default if no language-specific +* function is specified for the specified language. +* +* @param im IM-processed data to return to the caller function. +* @param ks SDL_keysym typed on the keyboard. +* +* @return The number of characters in im->s that should not be committed. +* In other words, the returned number of characters at the end of +* im->s should be overwritten the next time im_read is called. +* +* @see im_event_c() +* @see im_event_fns +*/ +int im_read(IM_DATA* im, SDL_keysym ks) +{ + IM_EVENT_FN im_event_fp = NULL; + int redraw = 0; + + /* Sanity check */ + if(im->lang < 0 || im->lang >= NUM_LANGS) { + fprintf(stderr, "im->lang out of range (%d), using default\n", im->lang); + im->lang = LANG_DEFAULT; + } + + /* Function pointer to the language-specific im_event_* function */ + im_event_fp = im_event_fns[im->lang]; + + /* Run the language-specific IM or run the default C IM */ + if(im_event_fp) redraw = (*im_event_fp)(im, ks); + else redraw = im_event_c(im, ks); + + #ifdef IM_DEBUG + wprintf(L"* [%8ls] [%8ls] %2d %2d (%2d)\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf), im->redraw); + #endif + + return redraw; +} + +/* *************************************************************************** +* OTHER STATIC IM FUNCTIONS +*/ + +/** +* Generic event handler that calls the appropriate language handler. +* im->request should have the event ID. +*/ +static void im_event(IM_DATA* im) +{ + SDL_keysym ks; + + ks.sym = 0; + ks.unicode = 0; + + im_read(im, ks); +} + + +/** +* Make an event request and call the event handler. +*/ +static void im_request(IM_DATA* im, int request) +{ + im->request = request; + im_event(im); + im->request = IM_REQ_TRANSLATE; +} + +/* *************************************************************************** +* PUBLIC IM FUNCTIONS +*/ + +/** +* Free any allocated resources. +*/ +static void im_free(IM_DATA* im) +{ + im_request(im, IM_REQ_FREE); +} + + +void im_softreset(IM_DATA* im) +{ + im->s[0] = L'\0'; + im->buf[0] = L'\0'; + + im_request(im, IM_REQ_RESET_SOFT); +} + + +static void im_fullreset(IM_DATA* im) +{ + im->s[0] = L'\0'; + im->buf[0] = L'\0'; + + im_request(im, IM_REQ_RESET_FULL); +} + + /* *************************************************************************** * LANGUAGE-SPECIFIC IM FUNCTIONS * @@ -690,30 +823,6 @@ static const wchar_t* charmap_search(CHARMAP* cm, wchar_t* s) * functions. */ -/** -* Default C IM event handler. -* -* @see im_read -*/ -static int im_event_c(IM_DATA* im, SDL_keysym ks) -{ - /* Handle event requests */ - im->s[0] = L'\0'; - if(im->request != IM_REQ_TRANSLATE) return 0; - - /* Handle key stroke */ - switch(ks.sym) { - case SDLK_BACKSPACE: im->s[0] = L'\b'; break; - case SDLK_TAB: im->s[0] = L'\t'; break; - case SDLK_RETURN: im->s[0] = L'\r'; break; - default: im->s[0] = ks.unicode; - } - im->s[1] = L'\0'; - im->buf[0] = L'\0'; - - return 0; -} - /** * Chinese Traditional IM. * @@ -1529,36 +1638,6 @@ static int im_event_ko(IM_DATA* im, SDL_keysym ks) } -/* *************************************************************************** -* OTHER STATIC IM FUNCTIONS -*/ - -/** -* Generic event handler that calls the appropriate language handler. -* im->request should have the event ID. -*/ -static void im_event(IM_DATA* im) -{ - SDL_keysym ks; - - ks.sym = 0; - ks.unicode = 0; - - im_read(im, ks); -} - - -/** -* Make an event request and call the event handler. -*/ -static void im_request(IM_DATA* im, int request) -{ - im->request = request; - im_event(im); - im->request = IM_REQ_TRANSLATE; -} - - /* *************************************************************************** * PUBLIC IM FUNCTIONS */ @@ -1601,73 +1680,6 @@ void im_init(IM_DATA* im, int lang) } -void im_softreset(IM_DATA* im) -{ - im->s[0] = L'\0'; - im->buf[0] = L'\0'; - - im_request(im, IM_REQ_RESET_SOFT); -} - - -void im_fullreset(IM_DATA* im) -{ - im->s[0] = L'\0'; - im->buf[0] = L'\0'; - - im_request(im, IM_REQ_RESET_FULL); -} - - -/** -* Free any allocated resources. -*/ -void im_free(IM_DATA* im) -{ - im_request(im, IM_REQ_FREE); -} - - -/** -* IM-process a character. This function simply looks up the language from -* IM and calls the appropriate im_event_() language-specific IM event -* handler. im_event_c() is called by default if no language-specific -* function is specified for the specified language. -* -* @param im IM-processed data to return to the caller function. -* @param ks SDL_keysym typed on the keyboard. -* -* @return The number of characters in im->s that should not be committed. -* In other words, the returned number of characters at the end of -* im->s should be overwritten the next time im_read is called. -* -* @see im_event_c() -* @see im_event_fns -*/ -int im_read(IM_DATA* im, SDL_keysym ks) -{ - IM_EVENT_FN im_event_fp = NULL; - int redraw = 0; - - /* Sanity check */ - if(im->lang < 0 || im->lang >= NUM_LANGS) { - fprintf(stderr, "im->lang out of range (%d), using default\n", im->lang); - im->lang = LANG_DEFAULT; - } - - /* Function pointer to the language-specific im_event_* function */ - im_event_fp = im_event_fns[im->lang]; - - /* Run the language-specific IM or run the default C IM */ - if(im_event_fp) redraw = (*im_event_fp)(im, ks); - else redraw = im_event_c(im, ks); - - #ifdef IM_DEBUG - wprintf(L"* [%8ls] [%8ls] %2d %2d (%2d)\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf), im->redraw); - #endif - - return redraw; -} /* vim:ts=2:et diff --git a/src/im.h b/src/im.h index 96636863c..a2f349cd3 100644 --- a/src/im.h +++ b/src/im.h @@ -50,10 +50,7 @@ typedef struct IM_DATA { */ void im_init(IM_DATA* im, int lang); /* Initialize IM */ -void im_fullreset(IM_DATA* im); /* Full Reset IM */ void im_softreset(IM_DATA* im); /* Soft Reset IM */ -void im_free(IM_DATA* im); /* Free IM resources */ - int im_read(IM_DATA* im, SDL_keysym ks); diff --git a/src/parse.gperf b/src/parse.gperf index c677c3b12..386376cbc 100644 --- a/src/parse.gperf +++ b/src/parse.gperf @@ -14,7 +14,7 @@ #include #include -const char PARSE_YES[] = "yes"; +static const char PARSE_YES[] = "yes"; const char PARSE_NO[] = "no"; const char PARSE_CLOBBER[] = ":-("; // for painful lang/locale priority situation diff --git a/src/parse.h b/src/parse.h index 8b11a0538..22c4b15b3 100644 --- a/src/parse.h +++ b/src/parse.h @@ -1,7 +1,7 @@ #pragma once #include "compiler.h" -extern const char PARSE_YES[]; +//extern const char PARSE_YES[]; extern const char PARSE_NO[]; extern const char PARSE_CLOBBER[]; diff --git a/src/pixels.c b/src/pixels.c index b22691730..a3737d6e9 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -32,7 +32,7 @@ #include "debug.h" /* Draw a single pixel into the surface: */ -void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel) +static void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel) { Uint8 *p; @@ -55,7 +55,7 @@ void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel) } /* Draw a single pixel into the surface: */ -void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel) +static void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel) { Uint8 *p; @@ -78,7 +78,7 @@ void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel) } /* Draw a single pixel into the surface: */ -void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel) +static void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel) { Uint8 *p; @@ -113,7 +113,7 @@ void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel) } /* Draw a single pixel into the surface: */ -void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel) +static void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel) { Uint8 *p; @@ -136,7 +136,7 @@ void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel) } /* Get a pixel: */ -Uint32 getpixel8(SDL_Surface * surface, int x, int y) +static Uint32 getpixel8(SDL_Surface * surface, int x, int y) { Uint8 *p; @@ -162,7 +162,7 @@ Uint32 getpixel8(SDL_Surface * surface, int x, int y) } /* Get a pixel: */ -Uint32 getpixel16(SDL_Surface * surface, int x, int y) +static Uint32 getpixel16(SDL_Surface * surface, int x, int y) { Uint8 *p; @@ -188,7 +188,7 @@ Uint32 getpixel16(SDL_Surface * surface, int x, int y) } /* Get a pixel: */ -Uint32 getpixel24(SDL_Surface * surface, int x, int y) +static Uint32 getpixel24(SDL_Surface * surface, int x, int y) { Uint8 *p; Uint32 pixel; @@ -222,7 +222,7 @@ Uint32 getpixel24(SDL_Surface * surface, int x, int y) } /* Get a pixel: */ -Uint32 getpixel32(SDL_Surface * surface, int x, int y) +static Uint32 getpixel32(SDL_Surface * surface, int x, int y) { Uint8 *p; diff --git a/src/pixels.h b/src/pixels.h index 21ef4b3fb..853c5d2a5 100644 --- a/src/pixels.h +++ b/src/pixels.h @@ -32,18 +32,7 @@ #include "SDL.h" -void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel); -void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel); -void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel); -void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel); - extern void (*putpixels[]) (SDL_Surface *, int, int, Uint32); - -Uint32 getpixel8(SDL_Surface * surface, int x, int y); -Uint32 getpixel16(SDL_Surface * surface, int x, int y); -Uint32 getpixel24(SDL_Surface * surface, int x, int y); -Uint32 getpixel32(SDL_Surface * surface, int x, int y); - extern Uint32(*getpixels[]) (SDL_Surface *, int, int); #endif diff --git a/src/playsound.c b/src/playsound.c index 4e272fa46..4238bdabf 100644 --- a/src/playsound.c +++ b/src/playsound.c @@ -31,7 +31,7 @@ Mix_Chunk *sounds[NUM_SOUNDS]; int mute; int use_sound = 1; -int old_sound[4] = { -1, -1, -1, -1 }; +static int old_sound[4] = { -1, -1, -1, -1 }; void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y) diff --git a/src/postscript_print.c b/src/postscript_print.c index 6b603b754..03c07af3a 100644 --- a/src/postscript_print.c +++ b/src/postscript_print.c @@ -66,15 +66,12 @@ #define my_min(x,y) ((x < y) ? (x) : (y)) -int f2int(float f); -int f2dec(float f); - -int f2int(float f) +static int f2int(float f) { return ((int)f); } -int f2dec(float f) +static int f2dec(float f) { return (int)((f - f2int(f)) * 100); } diff --git a/src/tuxpaint.c b/src/tuxpaint.c index b08bbe567..aeecd4c46 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -529,9 +529,9 @@ enum /* Color globals (copied from colors.h, if no colors specified by user) */ -int NUM_COLORS; -Uint8 * * color_hexes; -char * * color_names; +static int NUM_COLORS; +static Uint8 * * color_hexes; +static char * * color_names; /* Show debugging stuff: */ @@ -619,8 +619,8 @@ static int WINDOW_WIDTH = 800; static int WINDOW_HEIGHT = 600; #endif -void magic_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel); -Uint32 magic_getpixel(SDL_Surface * surface, int x, int y); +static void magic_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel); +static Uint32 magic_getpixel(SDL_Surface * surface, int x, int y); static void setup_normal_screen_layout(void) @@ -965,9 +965,9 @@ static int starter_personal; static int template_personal; static Uint8 canvas_color_r, canvas_color_g, canvas_color_b; -Uint8 * touched; +static Uint8 * touched; -int shape_radius; +static int shape_radius; /* Text label tool struct to hold information about text on the label layer */ typedef struct label_node @@ -1010,37 +1010,37 @@ static unsigned select_text_size; static int coming_from_undo_or_redo = FALSE; -void add_label_node(int, int, Uint16, Uint16, struct label_node**, SDL_Surface* label_node_surface); -void load_info_about_label_surface(char[1024]); +static void add_label_node(int, int, Uint16, Uint16, struct label_node**, SDL_Surface* label_node_surface); +static void load_info_about_label_surface(char[1024]); -struct label_node* search_label_list(struct label_node**, Uint16, Uint16, int hover); +static struct label_node* search_label_list(struct label_node**, Uint16, Uint16, int hover); -void do_undo_label_node(void); -void do_redo_label_node(void); -void rec_undo_label(void); +static void do_undo_label_node(void); +static void do_redo_label_node(void); +static void rec_undo_label(void); -void render_all_nodes_starting_at(struct label_node**); -void simply_render_node(struct label_node*); +static void render_all_nodes_starting_at(struct label_node**); +static void simply_render_node(struct label_node*); -void derender_node(struct label_node**); +static void derender_node(struct label_node**); -void delete_label_list(struct label_node**); +static void delete_label_list(struct label_node**); static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, SDL_Surface * dest_surf, SDL_Rect * dest_rect); -void set_label_fonts(void); +static void set_label_fonts(void); -void tmp_apply_uncommited_text(void); -void undo_tmp_applied_text(void); +static void tmp_apply_uncommited_text(void); +static void undo_tmp_applied_text(void); /* Magic tools API and tool handles: */ #include "tp_magic_api.h" -void update_progress_bar(void); -void special_notify(int flags); +static void update_progress_bar(void); +static void special_notify(int flags); typedef struct magic_funcs_s { int (*get_tool_count)(magic_api *); @@ -1078,10 +1078,10 @@ typedef struct magic_s { /* FIXME: Drop the 512 constants :^P */ static int num_plugin_files; /* How many shared object files we went through */ -void * magic_handle[512]; /* Handle to shared object (to be unloaded later) */ /* FIXME: Unload them! */ -magic_funcs_t magic_funcs[512]; /* Pointer to shared objects' functions */ +static void * magic_handle[512]; /* Handle to shared object (to be unloaded later) */ /* FIXME: Unload them! */ +static magic_funcs_t magic_funcs[512]; /* Pointer to shared objects' functions */ -magic_t magics[512]; +static magic_t magics[512]; static int num_magics; /* How many magic tools were loaded (note: shared objs may report more than 1 tool) */ enum { @@ -1093,7 +1093,7 @@ enum { NUM_MAGIC_PLACES }; -magic_api *magic_api_struct; /* Pointer to our internal functions; passed to shared object's functions when we call them */ +static magic_api *magic_api_struct; /* Pointer to our internal functions; passed to shared object's functions when we call them */ #if !defined(WIN32) && !defined(__APPLE__) && !defined(__BEOS__) @@ -1160,7 +1160,7 @@ static SDL_Surface *img_magic_paint, *img_magic_fullscreen; static SDL_Surface *img_bold, *img_italic; static SDL_Surface *img_label, *img_label_select; static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_paintwell; -int color_picker_x, color_picker_y; +static int color_picker_x, color_picker_y; static SDL_Surface *img_title_on, *img_title_off, *img_title_large_on, *img_title_large_off; @@ -1247,6 +1247,8 @@ static Uint16 *wcstou16(const wchar_t * str) /* This is a bodge, but it seems unlikely that a case-conversion will cause a change from one utf16 character into two.... (though at least UTF-8 suffers from this problem) */ + + // FIXME: mangles non-BMP characters rather than using UTF-16 surrogates! res[i] = (Uint16) str[i]; } @@ -1409,7 +1411,7 @@ static unsigned int stamp_group_dir_depth = 1; /* How deep (how many slashes in static int stamp_group = 0; -const char *load_stamp_basedir; +static const char *load_stamp_basedir; static int num_stamp_groups = 0; static int num_stamps[MAX_STAMP_GROUPS]; static int max_stamps[MAX_STAMP_GROUPS]; @@ -1469,7 +1471,7 @@ enum { }; static SDL_Surface *img_cur_brush; -int img_cur_brush_frame_w, img_cur_brush_w, img_cur_brush_h, +static int img_cur_brush_frame_w, img_cur_brush_w, img_cur_brush_h, img_cur_brush_frames, img_cur_brush_directional, img_cur_brush_spacing; static int brush_counter, brush_frame; @@ -1575,8 +1577,8 @@ static void rect_xor(int x1, int y1, int x2, int y2); static void draw_blinking_cursor(void); static void hide_blinking_cursor(void); -void reset_brush_counter_and_frame(void); -void reset_brush_counter(void); +static void reset_brush_counter_and_frame(void); +static void reset_brush_counter(void); #ifdef LOW_QUALITY_STAMP_OUTLINE #define stamp_xor(x,y) rect_xor( \ @@ -1656,21 +1658,21 @@ static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf); static void get_new_file_id(void); static int do_quit(int tool); -int do_open(void); -int do_new_dialog(void); -int do_color_picker(void); -int do_slideshow(void); -void play_slideshow(int * selected, int num_selected, char * dirname, +static int do_open(void); +static int do_new_dialog(void); +static int do_color_picker(void); +static int do_slideshow(void); +static void play_slideshow(int * selected, int num_selected, char * dirname, char **d_names, char **d_exts, int speed); -void draw_selection_digits(int right, int bottom, int n); +static void draw_selection_digits(int right, int bottom, int n); static void wait_for_sfx(void); static void rgbtohsv(Uint8 r8, Uint8 g8, Uint8 b8, float *h, float *s, float *v); static void hsvtorgb(float h, float s, float v, Uint8 * r8, Uint8 * g8, Uint8 * b8); -SDL_Surface *flip_surface(SDL_Surface * s); -SDL_Surface *mirror_surface(SDL_Surface * s); +static SDL_Surface *flip_surface(SDL_Surface * s); +static SDL_Surface *mirror_surface(SDL_Surface * s); static void print_image(void); static void do_print(void); @@ -1700,45 +1702,45 @@ static void load_template(char *img_id); static SDL_Surface *duplicate_surface(SDL_Surface * orig); static void mirror_starter(void); static void flip_starter(void); -int valid_click(Uint8 button); -int in_circle(int x, int y); -int in_circle_rad(int x, int y, int rad); -int paintsound(int size); -void load_magic_plugins(void); -int magic_sort(const void * a, const void * b); +static int valid_click(Uint8 button); +static int in_circle(int x, int y); +static int in_circle_rad(int x, int y, int rad); +static int paintsound(int size); +static void load_magic_plugins(void); +static int magic_sort(const void * a, const void * b); Mix_Chunk * magic_current_snd_ptr; -void magic_playsound(Mix_Chunk * snd, int left_right, int up_down); -void magic_stopsound(void); -void magic_line_func(void * mapi, +static void magic_playsound(Mix_Chunk * snd, int left_right, int up_down); +static void magic_stopsound(void); +static void magic_line_func(void * mapi, int which, SDL_Surface * canvas, SDL_Surface * last, int x1, int y1, int x2, int y2, int step, void (*cb)(void *, int, SDL_Surface *, SDL_Surface *, int, int)); -Uint8 magic_linear_to_sRGB(float lin); -float magic_sRGB_to_linear(Uint8 srgb); -int magic_button_down(void); -SDL_Surface * magic_scale(SDL_Surface * surf, int w, int h, int aspect); -void reset_touched(void); -Uint8 magic_touched(int x, int y); +static Uint8 magic_linear_to_sRGB(float lin); +static float magic_sRGB_to_linear(Uint8 srgb); +static int magic_button_down(void); +static SDL_Surface * magic_scale(SDL_Surface * surf, int w, int h, int aspect); +static void reset_touched(void); +static Uint8 magic_touched(int x, int y); -void magic_switchin(SDL_Surface * last); -void magic_switchout(SDL_Surface * last); -int magic_modeint(int mode); +static void magic_switchin(SDL_Surface * last); +static void magic_switchout(SDL_Surface * last); +static int magic_modeint(int mode); #ifdef DEBUG static char *debug_gettext(const char *str); static int charsize(Uint16 c); #endif -SDL_Surface * load_kpx(char * file); +static SDL_Surface * load_kpx(char * file); #ifndef NOSVG -SDL_Surface * load_svg(char * file); -float pick_best_scape(unsigned int orig_w, unsigned int orig_h, +static SDL_Surface * load_svg(char * file); +static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h); #endif -SDL_Surface * myIMG_Load(char * file); +static SDL_Surface * myIMG_Load(char * file); #define MAX_UTF8_CHAR_LENGTH 6 @@ -3753,7 +3755,7 @@ static void mainloop(void) { if(cur_select == SELECT_OFF) { - label_node_to_edit=search_label_list(¤t_label_node, old_x, old_y, 0); + label_node_to_edit=search_label_list(¤t_label_node, old_x, old_y, 0); if(label_node_to_edit) { cur_thing=label_node_to_edit->save_cur_font; @@ -4409,12 +4411,13 @@ static void mainloop(void) if (cur_label == LABEL_LABEL) do_setcursor(cursor_insertion); else if (cur_label == LABEL_SELECT && cur_select == SELECT_OFF) - { - if (search_label_list(¤t_label_node, event.button.x - 96, event.button.y, 1)) - do_setcursor(cursor_hand); - else - do_setcursor(cursor_arrow); - } + { + do_setcursor(cursor_arrow); + if (search_label_list(¤t_label_node, event.button.x - 96, event.button.y, 1)) + do_setcursor(cursor_hand); + else + do_setcursor(cursor_arrow); + } else if (cur_label == LABEL_SELECT && cur_select == SELECT_ON) do_setcursor(cursor_insertion); /* else if (cur_label == LABEL_ROTATE &&cur_select == SELECT_OFF) */ @@ -9065,10 +9068,10 @@ static void draw_tux_text(int which_tux, const char *const str, draw_tux_text_ex(which_tux, str, want_right_to_left, 0); } -int latest_tux; -const char * latest_tux_text; -int latest_r2l; -Uint8 latest_locale_text; +static int latest_tux; +static const char * latest_tux_text; +static int latest_r2l; +static Uint8 latest_locale_text; static void redraw_tux_text(void) { @@ -12160,7 +12163,7 @@ static int do_quit(int tool) /* FIXME: This, do_slideshow() and do_new_dialog() should be combined and modularized! */ -int do_open(void) +static int do_open(void) { SDL_Surface *img, *img1, *img2; int things_alloced; @@ -13249,7 +13252,7 @@ int do_open(void) /* Slide Show Selection Screen: */ -int do_slideshow(void) +static int do_slideshow(void) { SDL_Surface *img, *img1, *img2; int things_alloced; @@ -13998,7 +14001,7 @@ int do_slideshow(void) } -void play_slideshow(int * selected, int num_selected, char * dirname, +static void play_slideshow(int * selected, int num_selected, char * dirname, char **d_names, char **d_exts, int speed) { int i, which, next, done; @@ -14223,7 +14226,7 @@ void play_slideshow(int * selected, int num_selected, char * dirname, /* Draws large, bitmap digits over thumbnails in slideshow selection screen: */ -void draw_selection_digits(int right, int bottom, int n) +static void draw_selection_digits(int right, int bottom, int n) { SDL_Rect src, dest; int i, v, len, place; @@ -15438,7 +15441,7 @@ static void flip_starter(void) } -int valid_click(Uint8 button) +static int valid_click(Uint8 button) { if (button == 1 || ((button == 2 || button == 3) && no_button_distinction)) return (1); @@ -15447,7 +15450,7 @@ int valid_click(Uint8 button) } -int in_circle(int x, int y) +static int in_circle(int x, int y) { if ((x * x) + (y * y) - (16 * 16) < 0) return (1); @@ -15455,7 +15458,7 @@ int in_circle(int x, int y) return (0); } -int in_circle_rad(int x, int y, int rad) +static int in_circle_rad(int x, int y, int rad) { if ((x * x) + (y * y) - (rad * rad) < 0) return (1); @@ -15463,7 +15466,7 @@ int in_circle_rad(int x, int y, int rad) return (0); } -int paintsound(int size) +static int paintsound(int size) { if (SND_PAINT1 + (size / 12) >= SND_PAINT4) return(SND_PAINT4); @@ -15480,7 +15483,7 @@ int paintsound(int size) Based on cairo-demo/sdl/main.c from Cairo (GPL'd, (c) 2004 Eric Windisch): */ -SDL_Surface * load_svg(char * file) +static SDL_Surface * load_svg(char * file) { svg_cairo_t * scr; int bpp, btpp, stride; @@ -15640,7 +15643,7 @@ SDL_Surface * load_svg(char * file) #else /* New libcairo2, rsvg and rsvg-cairo based code */ -SDL_Surface * load_svg(char * file) +static SDL_Surface * load_svg(char * file) { cairo_surface_t * cairo_surf; cairo_t * cr; @@ -15819,7 +15822,7 @@ SDL_Surface * load_svg(char * file) #endif -float pick_best_scape(unsigned int orig_w, unsigned int orig_h, +static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h) { float aspect, scale, wscale, hscale; @@ -15906,7 +15909,7 @@ float pick_best_scape(unsigned int orig_w, unsigned int orig_h, if we notice it's an SVG file (if available!); call load_kpx() if we notice it's a KPX file (JPEG with wrapper); otherwise call SDL_Image lib's IMG_Load() (for PNGs, JPEGs, BMPs, etc.) */ -SDL_Surface * myIMG_Load(char * file) +static SDL_Surface * myIMG_Load(char * file) { if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".kpx") == 0) return(load_kpx(file)); @@ -15918,7 +15921,7 @@ SDL_Surface * myIMG_Load(char * file) return(IMG_Load(file)); } -SDL_Surface * load_kpx(char * file) +static SDL_Surface * load_kpx(char * file) { SDL_RWops * data; FILE * fi; @@ -15946,7 +15949,7 @@ SDL_Surface * load_kpx(char * file) } -void load_magic_plugins(void) +static void load_magic_plugins(void) { int res, n, i, plc; char * place; @@ -16347,7 +16350,7 @@ void load_magic_plugins(void) -int magic_sort(const void * a, const void * b) +static int magic_sort(const void * a, const void * b) { magic_t * am = (magic_t *) a; magic_t * bm = (magic_t *) b; @@ -16356,12 +16359,12 @@ int magic_sort(const void * a, const void * b) } -void update_progress_bar(void) +static void update_progress_bar(void) { show_progress_bar(screen); } -void magic_line_func(void * mapi, +static void magic_line_func(void * mapi, int which, SDL_Surface * canvas, SDL_Surface * last, int x1, int y1, int x2, int y2, int step, void (*cb)(void *, int, SDL_Surface *, SDL_Surface *, @@ -16443,7 +16446,7 @@ void magic_line_func(void * mapi, /* Handle special things that some magic tools do that need to affect more than just the current canvas: */ -void special_notify(int flags) +static void special_notify(int flags) { int tmp_int; @@ -16475,7 +16478,7 @@ void special_notify(int flags) } } -void magic_stopsound(void) +static void magic_stopsound(void) { #ifndef NOSOUND if (mute || !use_sound) @@ -16485,7 +16488,7 @@ void magic_stopsound(void) #endif } -void magic_playsound(Mix_Chunk * snd, int left_right, int up_down) +static void magic_playsound(Mix_Chunk * snd, int left_right, int up_down) { #ifndef NOSOUND @@ -16527,29 +16530,29 @@ void magic_playsound(Mix_Chunk * snd, int left_right, int up_down) #endif } -Uint8 magic_linear_to_sRGB(float lin) +static Uint8 magic_linear_to_sRGB(float lin) { return(linear_to_sRGB(lin)); } -float magic_sRGB_to_linear(Uint8 srgb) +static float magic_sRGB_to_linear(Uint8 srgb) { return(sRGB_to_linear_table[srgb]); } -int magic_button_down(void) +static int magic_button_down(void) { return(button_down); } -SDL_Surface * magic_scale(SDL_Surface * surf, int w, int h, int aspect) +static SDL_Surface * magic_scale(SDL_Surface * surf, int w, int h, int aspect) { return(thumbnail2(surf, w, h, aspect, 1)); } /* FIXME: This, do_open() and do_slideshow() should be combined and modularized! */ -int do_new_dialog(void) +static int do_new_dialog(void) { SDL_Surface *img, *img1, *img2; int things_alloced; @@ -17676,7 +17679,7 @@ int do_new_dialog(void) /* FIXME: Use a bitmask! */ -void reset_touched(void) +static void reset_touched(void) { int x, y; @@ -17689,7 +17692,7 @@ void reset_touched(void) } } -Uint8 magic_touched(int x, int y) +static Uint8 magic_touched(int x, int y) { Uint8 res; @@ -17702,7 +17705,7 @@ Uint8 magic_touched(int x, int y) return(res); } -int do_color_picker(void) +static int do_color_picker(void) { #ifndef NO_PROMPT_SHADOWS int i; @@ -18134,18 +18137,18 @@ int do_color_picker(void) return(chose); } -void magic_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel) +static void magic_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel) { putpixels[surface->format->BytesPerPixel](surface, x, y, pixel); } -Uint32 magic_getpixel(SDL_Surface * surface, int x, int y) +static Uint32 magic_getpixel(SDL_Surface * surface, int x, int y) { return(getpixels[surface->format->BytesPerPixel](surface, x, y)); } -void magic_switchout(SDL_Surface * last) +static void magic_switchout(SDL_Surface * last) { if (cur_tool == TOOL_MAGIC) { @@ -18157,7 +18160,7 @@ void magic_switchout(SDL_Surface * last) } } -void magic_switchin(SDL_Surface * last) +static void magic_switchin(SDL_Surface * last) { if (cur_tool == TOOL_MAGIC) { @@ -18175,7 +18178,7 @@ void magic_switchin(SDL_Surface * last) } } -int magic_modeint(int mode) +static int magic_modeint(int mode) { if (mode == MODE_PAINT) return 0; @@ -18185,7 +18188,7 @@ int magic_modeint(int mode) return 0; } -void add_label_node(int w, int h, Uint16 x, Uint16 y, struct label_node** node_to_disable, SDL_Surface* label_node_surface) +static void add_label_node(int w, int h, Uint16 x, Uint16 y, struct label_node** node_to_disable, SDL_Surface* label_node_surface) { struct label_node* new_node = malloc(sizeof(struct label_node)); struct label_node* aux_node; @@ -18239,7 +18242,7 @@ void add_label_node(int w, int h, Uint16 x, Uint16 y, struct label_node** node_t } -struct label_node* search_label_list(struct label_node** ref_head, Uint16 x, Uint16 y, int hover) +static struct label_node* search_label_list(struct label_node** ref_head, Uint16 x, Uint16 y, int hover) { struct label_node* current_node; struct label_node* tmp_node = NULL; @@ -18263,11 +18266,11 @@ struct label_node* search_label_list(struct label_node** ref_head, Uint16 x, Uin if (current_node->is_enabled == TRUE) { if (tmp_node == NULL) /* Preselecting the top label at x,y position*/ - { - if (hover == 1) - return(current_node); - tmp_node = current_node; - } + { + if (hover == 1) + return(current_node); + tmp_node = current_node; + } SDL_GetRGBA(getpixels[current_node->label_node_surface->format->BytesPerPixel](current_node->label_node_surface, x - current_node->save_x, y - current_node->save_y), current_node->label_node_surface->format, &r, &g, &b, &a); if (a != SDL_ALPHA_TRANSPARENT) @@ -18313,7 +18316,7 @@ struct label_node* search_label_list(struct label_node** ref_head, Uint16 x, Uin return NULL; } -void rec_undo_label(void) +static void rec_undo_label(void) { printf("rec\n"); if (first_label_node_in_redo_stack != NULL) @@ -18356,7 +18359,7 @@ void rec_undo_label(void) } } -void do_undo_label_node() +static void do_undo_label_node() { if (text_undo[(cur_undo + 1) % NUM_UNDO_BUFS] == 1) if (current_label_node != NULL) @@ -18378,7 +18381,7 @@ void do_undo_label_node() } } -void do_redo_label_node() +static void do_redo_label_node() { if ( (text_undo[cur_undo] == 1) && (first_label_node_in_redo_stack != NULL) ) @@ -18404,7 +18407,7 @@ void do_redo_label_node() } -void simply_render_node(struct label_node* node) +static void simply_render_node(struct label_node* node) { SDL_Surface *tmp_surf; @@ -18491,7 +18494,7 @@ void simply_render_node(struct label_node* node) } } -void render_all_nodes_starting_at(struct label_node** node) +static void render_all_nodes_starting_at(struct label_node** node) { struct label_node* current_node; if (*node!=NULL) @@ -18511,7 +18514,7 @@ void render_all_nodes_starting_at(struct label_node** node) } /* FIXME: This should search for the top-down of the overlaping labels and only re-render from it */ -void derender_node(struct label_node** ref_head) +static void derender_node(struct label_node** ref_head) { struct label_node* current_node; SDL_Rect r_tmp_derender; @@ -18526,7 +18529,7 @@ void derender_node(struct label_node** ref_head) render_all_nodes_starting_at(&start_label_node); } -void delete_label_list(struct label_node** ref_head) +static void delete_label_list(struct label_node** ref_head) { struct label_node* current = *ref_head; struct label_node* next; @@ -18584,7 +18587,7 @@ static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, } } -void load_info_about_label_surface(char lfname[1024]) +static void load_info_about_label_surface(char lfname[1024]) { struct label_node* new_node; int list_ctr; @@ -18756,7 +18759,7 @@ void load_info_about_label_surface(char lfname[1024]) set_label_fonts(); } -void set_label_fonts() +static void set_label_fonts() { struct label_node* node; int i; @@ -18815,7 +18818,7 @@ void set_label_fonts() } -void tmp_apply_uncommited_text() +static void tmp_apply_uncommited_text() { if (texttool_len > 0) { @@ -18862,7 +18865,7 @@ void tmp_apply_uncommited_text() } } -void undo_tmp_applied_text() +static void undo_tmp_applied_text() { struct label_node* aux_label_node; @@ -20101,8 +20104,11 @@ static void setup(void) } +#ifdef NO_SDLPANGO locale_font = load_locale_font(medium_font, 18); - +#else + locale_font = medium_font; +#endif #if 0