indent fonts.c fonts.h

This commit is contained in:
Bill Kendrick 2017-10-15 10:53:55 -07:00
parent b37621c2f0
commit 81ff48ccbc
2 changed files with 804 additions and 782 deletions

View file

@ -189,6 +189,7 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
else else
{ {
char str[128]; 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); ret = TuxPaint_Font_OpenFont("", str, size);
@ -238,7 +239,8 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
#ifdef DEBUG #ifdef DEBUG
printf("TuxPaint_Font_CloseFont step 1 (%p)\n", tpf); //EP printf("TuxPaint_Font_CloseFont step 1 (%p)\n", tpf); //EP
#endif #endif
if (!tpf) return; //EP if (!tpf)
return; //EP
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
#ifdef DEBUG #ifdef DEBUG
@ -265,7 +267,8 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
tpf->ttf_font = NULL; tpf->ttf_font = NULL;
} }
if (tpf->desc != NULL) { if (tpf->desc != NULL)
{
free(tpf->desc); free(tpf->desc);
tpf->desc = NULL; tpf->desc = NULL;
} }
@ -277,6 +280,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile
{ {
TuxPaint_Font *tpf = NULL; TuxPaint_Font *tpf = NULL;
int i; int i;
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
char desc[1024]; char desc[1024];
#endif #endif
@ -381,9 +385,11 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile
void reliable_write(int fd, const void *buf, size_t count) void reliable_write(int fd, const void *buf, size_t count)
{ {
struct pollfd p; struct pollfd p;
do do
{ {
ssize_t rc = write(fd, buf, count); ssize_t rc = write(fd, buf, count);
if (rc == -1) if (rc == -1)
{ {
switch (errno) switch (errno)
@ -412,9 +418,11 @@ void reliable_write(int fd, const void *buf, size_t count)
static void reliable_read(int fd, void *buf, size_t count) static void reliable_read(int fd, void *buf, size_t count)
{ {
struct pollfd p; struct pollfd p;
do do
{ {
ssize_t rc = read(fd, buf, count); ssize_t rc = read(fd, buf, count);
if (rc == -1) if (rc == -1)
{ {
switch (errno) switch (errno)
@ -570,6 +578,7 @@ static void groupfonts_range(style_info ** base, int count)
while (i--) while (i--)
{ {
int b = boldmap[base[i]->boldness]; int b = boldmap[base[i]->boldness];
if (b == -1) if (b == -1)
{ {
#if 0 #if 0
@ -717,6 +726,7 @@ static void parse_font_style(style_info * si)
{ {
size_t len = strlen(si->family); size_t len = strlen(si->family);
char *name = malloc(len + strlen(" Condensed") + 1); char *name = malloc(len + strlen(" Condensed") + 1);
sp += strlen("Condensed"); sp += strlen("Condensed");
memcpy(name, si->family, len); memcpy(name, si->family, len);
strcpy(name + len, " Condensed"); strcpy(name + len, " Condensed");
@ -818,9 +828,11 @@ static void dupe_markdown_range(family_info ** base, int count)
int bestscore = -999; int bestscore = -999;
int bestslot = 0; int bestslot = 0;
int i = count; int i = count;
while (i--) while (i--)
{ {
int score = base[i]->score; int score = base[i]->score;
if (score <= bestscore) if (score <= bestscore)
continue; continue;
bestscore = score; bestscore = score;
@ -852,6 +864,7 @@ static void groupfonts(void)
for (;;) for (;;)
{ {
int high = low; int high = low;
if (low >= num_font_styles) if (low >= num_font_styles)
break; break;
for (;;) for (;;)
@ -882,6 +895,7 @@ static void groupfonts(void)
for (;;) for (;;)
{ {
int high = low; int high = low;
if (low >= num_font_families) if (low >= num_font_families)
break; break;
for (;;) for (;;)
@ -964,6 +978,7 @@ static void loadfonts(SDL_Surface * screen, const char *const dir)
dev_t volume = dev_for_path("/boot"); dev_t volume = dev_for_path("/boot");
char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH]; char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
status_t result; 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, buffer); loadfonts(screen, buffer);
result = find_directory(B_COMMON_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); result = find_directory(B_COMMON_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
@ -1051,6 +1066,7 @@ void run_font_scanner(SDL_Surface * screen, const char *restrict const locale)
while (i--) while (i--)
{ {
char *s; char *s;
s = user_font_families[i]->directory; s = user_font_families[i]->directory;
if (s) if (s)
size += strlen(s); size += strlen(s);
@ -1222,6 +1238,7 @@ void receive_some_font_info(SDL_Surface * screen)
while (i--) while (i--)
{ {
unsigned len; unsigned len;
user_font_families[i] = fip + i; user_font_families[i] = fip + i;
len = strlen(walk); len = strlen(walk);
@ -1453,6 +1470,7 @@ static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * c
{ {
const char *const c1 = (char *const)s1->pixels; const char *const c1 = (char *const)s1->pixels;
const char *const c2 = (char *const)s2->pixels; const char *const c2 = (char *const)s2->pixels;
width = s1->format->BytesPerPixel * s1->w; width = s1->format->BytesPerPixel * s1->w;
if (width == s1->pitch) if (width == s1->pitch)
return memcmp(c1, c2, width * s1->h); return memcmp(c1, c2, width * s1->h);
@ -1473,6 +1491,7 @@ static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * c
static int surfcmp(const void *s1, const void *s2) static int surfcmp(const void *s1, const void *s2)
{ {
int diff = do_surfcmp(s1, s2); int diff = do_surfcmp(s1, s2);
if (!diff) if (!diff)
was_bad_font = 1; was_bad_font = 1;
return diff; return diff;
@ -1488,6 +1507,7 @@ int charset_works(TuxPaint_Font * font, const char *s)
SDL_Surface **surfs = malloc(strlen(s) * sizeof surfs[0]); SDL_Surface **surfs = malloc(strlen(s) * sizeof surfs[0]);
unsigned count = 0; unsigned count = 0;
int ret = 0; int ret = 0;
while (*s) while (*s)
{ {
char c[8]; char c[8];

View file

@ -91,14 +91,16 @@ TTF_Font *BUGFIX_TTF_OpenFont206(const char *const file, int ptsize);
/* Stuff that wraps either SDL_Pango or SDL_TTF for font rendering: */ /* Stuff that wraps either SDL_Pango or SDL_TTF for font rendering: */
enum { enum
{
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
FONT_TYPE_PANGO, FONT_TYPE_PANGO,
#endif #endif
FONT_TYPE_TTF FONT_TYPE_TTF
}; };
typedef struct TuxPaint_Font_s { typedef struct TuxPaint_Font_s
{
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
SDLPango_Context *pango_context; SDLPango_Context *pango_context;
#endif #endif