Adding "indent.sh" to re-indent code; ran it!!!
This commit is contained in:
parent
16336cc854
commit
18f9cad6fe
98 changed files with 5798 additions and 9001 deletions
190
src/fonts.c
190
src/fonts.c
|
|
@ -142,6 +142,7 @@ int all_locale_fonts;
|
|||
volatile long font_thread_done;
|
||||
volatile long font_thread_aborted;
|
||||
volatile long waiting_for_fonts;
|
||||
|
||||
#ifdef FORKED_FONTS
|
||||
static int font_scanner_pid;
|
||||
#endif
|
||||
|
|
@ -180,8 +181,7 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
|
|||
{
|
||||
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);
|
||||
|
||||
|
|
@ -214,16 +214,14 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
|
|||
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_CloseFont step 1 (%p)\n", __FILE__, __LINE__,
|
||||
tpf);
|
||||
printf("%s:%d - TuxPaint_Font_CloseFont step 1 (%p)\n", __FILE__, __LINE__, tpf);
|
||||
#endif
|
||||
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);
|
||||
printf("%s:%d - TuxPaint_Font_CloseFont step 2 (%p, %d)\n", __FILE__, __LINE__, tpf->pango_context, tpf->typ);
|
||||
#endif
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
if (tpf->pango_context)
|
||||
|
|
@ -236,8 +234,7 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_CloseFont step 3 (%p, %d)\n", __FILE__,
|
||||
__LINE__, tpf->ttf_font, tpf->typ);
|
||||
printf("%s:%d - TuxPaint_Font_CloseFont step 3 (%p, %d)\n", __FILE__, __LINE__, tpf->ttf_font, tpf->typ);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
if (tpf->typ == FONT_TYPE_TTF)
|
||||
|
|
@ -256,8 +253,7 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
|
|||
free(tpf);
|
||||
}
|
||||
|
||||
TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
||||
const char *ttffilename, int size)
|
||||
TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffilename, int size)
|
||||
{
|
||||
TTF_Font *ttf_font;
|
||||
TuxPaint_Font *tpf = NULL;
|
||||
|
|
@ -269,8 +265,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - OpenFont(pango:\"%s\", ttf:\"%s\")\n", __FILE__, __LINE__,
|
||||
pangodesc, ttffilename);
|
||||
printf("%s:%d - OpenFont(pango:\"%s\", ttf:\"%s\")\n", __FILE__, __LINE__, pangodesc, ttffilename);
|
||||
#endif
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
|
|
@ -282,16 +277,15 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
tpf->desc = strdup(desc);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Creating Pango context: \"%s\"\n", __FILE__, __LINE__,
|
||||
desc);
|
||||
printf("%s:%d - Creating Pango context: \"%s\"\n", __FILE__, __LINE__, desc);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
* SDLPango_CreateContext_GivenFontDesc() defaults to ASCII character set
|
||||
* (at least on the macOS) unless the CHARSET environment varaible is set.
|
||||
* May also want to set on non-macOS platforms, also.
|
||||
*/
|
||||
* SDLPango_CreateContext_GivenFontDesc() defaults to ASCII character set
|
||||
* (at least on the macOS) unless the CHARSET environment varaible is set.
|
||||
* May also want to set on non-macOS platforms, also.
|
||||
*/
|
||||
|
||||
mysetenv("CHARSET", "UTF-8");
|
||||
#endif
|
||||
|
|
@ -325,8 +319,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
if (ttffilename != NULL && ttffilename[0] != '\0')
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Considering loading TTF \"%s\"\n", __FILE__, __LINE__,
|
||||
ttffilename);
|
||||
printf("%s:%d - Considering loading TTF \"%s\"\n", __FILE__, __LINE__, ttffilename);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
@ -336,8 +329,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
if (!strcmp(ttffilename, problemFonts[i++]))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Notice: Skipping problematic font: \"%s\"\n",
|
||||
ttffilename);
|
||||
fprintf(stderr, "Notice: Skipping problematic font: \"%s\"\n", ttffilename);
|
||||
#endif
|
||||
return NULL; /* bail on known problematic fonts that cause TTF_OpenFont to crash */
|
||||
}
|
||||
|
|
@ -349,9 +341,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
if (strstr(ttffilename, problemFontExtensions[i++]))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
"Notice: Skipping font with problematic extension: \"%s\"\n",
|
||||
ttffilename);
|
||||
fprintf(stderr, "Notice: Skipping font with problematic extension: \"%s\"\n", ttffilename);
|
||||
#endif
|
||||
return NULL; /* bail on known problematic font types that cause TTF_OpenFont to crash */
|
||||
}
|
||||
|
|
@ -361,13 +351,12 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
|
||||
if (ttf_font == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot open TTF font '%s' (size %d)\n", ttffilename,
|
||||
size);
|
||||
fprintf(stderr, "Cannot open TTF font '%s' (size %d)\n", ttffilename, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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 NO_SDLPANGO is set, or 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,
|
||||
|
|
@ -406,8 +395,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
tpf->desc = strdup(ttffilename);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Succeeded loading %s via SDL_ttf\n", __FILE__, __LINE__,
|
||||
ttffilename);
|
||||
printf("%s:%d - Succeeded loading %s via SDL_ttf\n", __FILE__, __LINE__, ttffilename);
|
||||
#endif
|
||||
tpf->height = TTF_FontHeight(tpf->ttf_font);
|
||||
|
||||
|
|
@ -614,9 +602,7 @@ static void groupfonts_range(style_info ** base, int count)
|
|||
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);
|
||||
user_font_families = realloc(user_font_families, num_font_families_max * sizeof *user_font_families);
|
||||
}
|
||||
|
||||
fi = calloc(1, sizeof *fi);
|
||||
|
|
@ -633,8 +619,7 @@ static void groupfonts_range(style_info ** base, int count)
|
|||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("too many boldness levels, discarding: %s, %s\n",
|
||||
base[i]->family, base[i]->style);
|
||||
printf("too many boldness levels, discarding: %s, %s\n", base[i]->family, base[i]->style);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
|
@ -644,11 +629,9 @@ static void groupfonts_range(style_info ** base, int count)
|
|||
{
|
||||
#if 0
|
||||
// THREADED_FONTS
|
||||
printf("duplicates, discarding: %s, %s\n", base[i]->family,
|
||||
base[i]->style);
|
||||
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]);
|
||||
printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1], fi->filename[2], fi->filename[3]);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
|
@ -872,8 +855,7 @@ static void parse_font_style(style_info * si)
|
|||
si->boldness = 1;
|
||||
|
||||
// we'll count both TrueType and OpenType
|
||||
si->truetype = !!strcasestr(si->filename, ".ttf")
|
||||
|| !!strcasestr(si->filename, ".otf");
|
||||
si->truetype = !!strcasestr(si->filename, ".ttf") || !!strcasestr(si->filename, ".otf");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -911,8 +893,7 @@ static void groupfonts(void)
|
|||
while (i--)
|
||||
parse_font_style(user_font_styles[i]);
|
||||
|
||||
qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0],
|
||||
compar_fontgroup);
|
||||
qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0], compar_fontgroup);
|
||||
//printf("groupfonts() qsort(user_font_styles...)\n");
|
||||
//fflush(stdout);
|
||||
|
||||
|
|
@ -945,8 +926,7 @@ static void groupfonts(void)
|
|||
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);
|
||||
qsort(user_font_families, num_font_families, sizeof user_font_families[0], compar_fontkiller);
|
||||
low = 0;
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -958,15 +938,13 @@ static void groupfonts(void)
|
|||
{
|
||||
if (++high >= num_font_families)
|
||||
break;
|
||||
if (strcmp
|
||||
(user_font_families[low]->family, user_font_families[high]->family))
|
||||
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);
|
||||
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 (num_font_families > 0 && user_font_families[0]->score < 0)
|
||||
|
|
@ -975,8 +953,7 @@ static void groupfonts(void)
|
|||
// 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)
|
||||
while (num_font_families > 1 && user_font_families[num_font_families - 1]->score < 0)
|
||||
{
|
||||
i = --num_font_families;
|
||||
free(user_font_families[i]->directory);
|
||||
|
|
@ -1002,9 +979,7 @@ static void groupfonts(void)
|
|||
|
||||
static void loadfonts_locale_filter(SDL_Surface * screen,
|
||||
SDL_Texture * texture,
|
||||
SDL_Renderer * renderer,
|
||||
const char *const dir,
|
||||
const char *restrict const locale)
|
||||
SDL_Renderer * renderer, const char *const dir, const char *restrict const locale)
|
||||
{
|
||||
char buf[TP_FTW_PATHSIZE];
|
||||
unsigned dirlen = strlen(dir);
|
||||
|
|
@ -1012,27 +987,23 @@ static void loadfonts_locale_filter(SDL_Surface * screen,
|
|||
DEBUG_PRINTF("Loading fonts from [%s]\n", dir);
|
||||
|
||||
memcpy(buf, dir, dirlen);
|
||||
tp_ftw(screen, texture, renderer, buf, dirlen, 1, loadfont_callback,
|
||||
locale);
|
||||
tp_ftw(screen, texture, renderer, buf, dirlen, 1, loadfont_callback, locale);
|
||||
}
|
||||
|
||||
static void loadfonts(SDL_Surface * screen, SDL_Texture * texture,
|
||||
SDL_Renderer * renderer, const char *const dir)
|
||||
static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *const dir)
|
||||
{
|
||||
loadfonts_locale_filter(screen, texture, renderer, dir, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* static */ int load_user_fonts(SDL_Surface * screen, SDL_Texture * texture,
|
||||
SDL_Renderer * renderer, void *vp,
|
||||
const char *restrict const locale)
|
||||
SDL_Renderer * renderer, void *vp, const char *restrict const locale)
|
||||
{
|
||||
char *homedirdir;
|
||||
|
||||
(void) vp; // junk passed by threading library
|
||||
(void)vp; // junk passed by threading library
|
||||
|
||||
loadfonts_locale_filter(screen, texture, renderer, DATA_PREFIX "fonts",
|
||||
locale);
|
||||
loadfonts_locale_filter(screen, texture, renderer, DATA_PREFIX "fonts", locale);
|
||||
|
||||
if (!no_system_fonts)
|
||||
{
|
||||
|
|
@ -1049,21 +1020,13 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture,
|
|||
char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
|
||||
status_t result;
|
||||
|
||||
result =
|
||||
find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer,
|
||||
sizeof(buffer));
|
||||
result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
|
||||
loadfonts(screen, texture, renderer, buffer);
|
||||
result =
|
||||
find_directory(B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, volume, false,
|
||||
buffer, sizeof(buffer));
|
||||
result = find_directory(B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
|
||||
loadfonts(screen, texture, renderer, buffer);
|
||||
result =
|
||||
find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer,
|
||||
sizeof(buffer));
|
||||
result = find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
|
||||
loadfonts(screen, texture, renderer, buffer);
|
||||
result =
|
||||
find_directory(B_USER_NONPACKAGED_FONTS_DIRECTORY, volume, false,
|
||||
buffer, sizeof(buffer));
|
||||
result = find_directory(B_USER_NONPACKAGED_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
|
||||
loadfonts(screen, texture, renderer, buffer);
|
||||
#elif defined(__APPLE__)
|
||||
loadfonts(screen, texture, renderer, "/System/Library/Fonts");
|
||||
|
|
@ -1102,8 +1065,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture,
|
|||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
homedirdir =
|
||||
malloc(snprintf(NULL, 0, "%s/fonts", apple_globalPreferencesPath()) + 1);
|
||||
homedirdir = malloc(snprintf(NULL, 0, "%s/fonts", apple_globalPreferencesPath()) + 1);
|
||||
if (homedirdir)
|
||||
{
|
||||
sprintf(homedirdir, "%s/fonts", apple_globalPreferencesPath());
|
||||
|
|
@ -1113,8 +1075,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture,
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Grouping %d fonts...\n", __FILE__, __LINE__,
|
||||
num_font_styles);
|
||||
printf("%s:%d - Grouping %d fonts...\n", __FILE__, __LINE__, num_font_styles);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
@ -1135,8 +1096,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture,
|
|||
#ifdef FORKED_FONTS
|
||||
|
||||
void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture,
|
||||
SDL_Renderer * renderer,
|
||||
const char *restrict const locale)
|
||||
SDL_Renderer * renderer, const char *restrict const locale)
|
||||
{
|
||||
int sv[2];
|
||||
int size, i;
|
||||
|
|
@ -1202,8 +1162,7 @@ void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture,
|
|||
buf = malloc(size);
|
||||
walk = buf;
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Sending %u bytes with %u families.\n", __FILE__, __LINE__,
|
||||
size, num_font_families);
|
||||
printf("%s:%d - Sending %u bytes with %u families.\n", __FILE__, __LINE__, size, num_font_families);
|
||||
#endif
|
||||
*walk++ = num_font_families & 0xffu;
|
||||
*walk++ = num_font_families >> 8u;
|
||||
|
|
@ -1272,8 +1231,7 @@ void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture,
|
|||
}
|
||||
|
||||
|
||||
void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture,
|
||||
SDL_Renderer * renderer)
|
||||
void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer)
|
||||
{
|
||||
char *buf = NULL;
|
||||
unsigned buf_size = 0;
|
||||
|
|
@ -1298,7 +1256,7 @@ void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture,
|
|||
rc = read(font_socket_fd, buf + buf_fill, buf_size - buf_fill);
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", __FILE__,
|
||||
__LINE__, font_socket_fd, buf_fill, buf_size, (long int) rc);
|
||||
__LINE__, font_socket_fd, buf_fill, buf_size, (long int)rc);
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
|
|
@ -1339,11 +1297,10 @@ void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture,
|
|||
|
||||
show_progress_bar_(screen, texture, renderer);
|
||||
walk = buf;
|
||||
num_font_families = *(unsigned char *) walk++;
|
||||
num_font_families += *(unsigned char *) walk++ << 8u;
|
||||
num_font_families = *(unsigned char *)walk++;
|
||||
num_font_families += *(unsigned char *)walk++ << 8u;
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Got %u bytes with %u families.\n", __FILE__, __LINE__,
|
||||
buf_fill, num_font_families);
|
||||
printf("%s:%d - Got %u bytes with %u families.\n", __FILE__, __LINE__, buf_fill, num_font_families);
|
||||
#endif
|
||||
user_font_families = malloc(num_font_families * sizeof *user_font_families);
|
||||
|
||||
|
|
@ -1409,8 +1366,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
if (fi == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - getfonthandle(%d) points to a NULL family\n", __FILE__,
|
||||
__LINE__, desire);
|
||||
printf("%s:%d - getfonthandle(%d) points to a NULL family\n", __FILE__, __LINE__, desire);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return NULL;
|
||||
|
|
@ -1419,8 +1375,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
if (fi->filename != NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - Setting 'name' to fi->filename[%d (0x%x)]\n", __FILE__,
|
||||
__LINE__, (int) text_state, (int) text_state);
|
||||
printf("%s:%d - Setting 'name' to fi->filename[%d (0x%x)]\n", __FILE__, __LINE__, (int)text_state, (int)text_state);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
@ -1444,8 +1399,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
if (fi->handle)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - fi->handle was set (0x%x)\n", __FILE__, __LINE__,
|
||||
(int) (intptr_t) fi->handle);
|
||||
printf("%s:%d - fi->handle was set (0x%x)\n", __FILE__, __LINE__, (int)(intptr_t) fi->handle);
|
||||
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
|
@ -1511,8 +1465,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
strcpy(description, "");
|
||||
}
|
||||
|
||||
fi->handle =
|
||||
TuxPaint_Font_OpenFont(description, pathname, text_sizes[text_size]);
|
||||
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
|
||||
|
||||
if (fi->handle == NULL)
|
||||
|
|
@ -1536,8 +1489,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - calling TTF_SetFontStyle(0x%x)\n", __FILE__, __LINE__,
|
||||
missing);
|
||||
printf("%s:%d - calling TTF_SetFontStyle(0x%x)\n", __FILE__, __LINE__, missing);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
@ -1557,8 +1509,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
static int was_bad_font;
|
||||
|
||||
// see if two font surfaces are the same
|
||||
static int do_surfcmp(const SDL_Surface * const *const v1,
|
||||
const SDL_Surface * const *const v2)
|
||||
static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * const *const v2)
|
||||
{
|
||||
const SDL_Surface *const s1 = *v1;
|
||||
const SDL_Surface *const s2 = *v2;
|
||||
|
|
@ -1572,8 +1523,7 @@ static int do_surfcmp(const SDL_Surface * const *const v1,
|
|||
fprintf(stderr, "s1==s2?\n");
|
||||
return 0;
|
||||
}
|
||||
if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format
|
||||
|| !s2->format)
|
||||
if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format || !s2->format)
|
||||
{
|
||||
/* One or the other or both SDL_Surfaces were invalid!? */
|
||||
was_bad_font = 1;
|
||||
|
|
@ -1596,11 +1546,12 @@ static int do_surfcmp(const SDL_Surface * const *const v1,
|
|||
/* Otherwise, compare the pixels in the surfaces
|
||||
(using `memcmp()`) */
|
||||
{
|
||||
const char *const c1 = (char *const) s1->pixels;
|
||||
const char *const c2 = (char *const) s2->pixels;
|
||||
const char *const c1 = (char *const)s1->pixels;
|
||||
const char *const c2 = (char *const)s2->pixels;
|
||||
|
||||
width = s1->format->BytesPerPixel * s1->w;
|
||||
if (width == s1->pitch) {
|
||||
if (width == s1->pitch)
|
||||
{
|
||||
/* Same width, just compare scanline */
|
||||
return memcmp(c1, c2, width * s1->h);
|
||||
}
|
||||
|
|
@ -1625,7 +1576,8 @@ static int surfcmp(const void *s1, const void *s2)
|
|||
{
|
||||
int diff = do_surfcmp(s1, s2);
|
||||
|
||||
if (!diff) {
|
||||
if (!diff)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("surfcmp found two identical renders!\n");
|
||||
#endif
|
||||
|
|
@ -1708,8 +1660,7 @@ int TuxPaint_Font_FontHeight(TuxPaint_Font * tpf)
|
|||
if (tpf == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_FontHeight() received NULL\n", __FILE__,
|
||||
__LINE__);
|
||||
printf("%s:%d - TuxPaint_Font_FontHeight() received NULL\n", __FILE__, __LINE__);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return (1);
|
||||
|
|
@ -1723,8 +1674,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf)
|
|||
if (tpf == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() received NULL\n",
|
||||
__FILE__, __LINE__);
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() received NULL\n", __FILE__, __LINE__);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return ("");
|
||||
|
|
@ -1733,7 +1683,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf)
|
|||
#ifndef NO_SDLPANGO
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
(void) (tpf);
|
||||
(void)(tpf);
|
||||
/* FIXME */
|
||||
|
||||
return ("");
|
||||
|
|
@ -1744,8 +1694,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf)
|
|||
return (TTF_FontFaceFamilyName(tpf->ttf_font));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() is confused\n", __FILE__,
|
||||
__LINE__);
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() is confused\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
|
||||
return ("");
|
||||
|
|
@ -1756,8 +1705,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf)
|
|||
if (tpf == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceStyleName() received NULL\n",
|
||||
__FILE__, __LINE__);
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceStyleName() received NULL\n", __FILE__, __LINE__);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return ("");
|
||||
|
|
@ -1766,7 +1714,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf)
|
|||
#ifndef NO_SDLPANGO
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
(void) (tpf);
|
||||
(void)(tpf);
|
||||
/* FIXME */
|
||||
|
||||
return ("");
|
||||
|
|
@ -1777,8 +1725,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf)
|
|||
return (TTF_FontFaceStyleName(tpf->ttf_font));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceStyleName() is confused\n", __FILE__,
|
||||
__LINE__);
|
||||
printf("%s:%d - TuxPaint_Font_FontFaceStyleName() is confused\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
|
||||
return ("");
|
||||
|
|
@ -1787,8 +1734,7 @@ 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)
|
||||
void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color)
|
||||
{
|
||||
Uint8 pc[4][4];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue