indent fonts.c fonts.h
This commit is contained in:
parent
b37621c2f0
commit
81ff48ccbc
2 changed files with 804 additions and 782 deletions
46
src/fonts.c
46
src/fonts.c
|
|
@ -189,6 +189,7 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
|
|||
else
|
||||
{
|
||||
char str[128];
|
||||
|
||||
snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, lang_prefix);
|
||||
|
||||
ret = TuxPaint_Font_OpenFont("", str, size);
|
||||
|
|
@ -238,7 +239,8 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
|
|||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_CloseFont step 1 (%p)\n", tpf); //EP
|
||||
#endif
|
||||
if (!tpf) return; //EP
|
||||
if (!tpf)
|
||||
return; //EP
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
#ifdef DEBUG
|
||||
|
|
@ -265,7 +267,8 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
|
|||
tpf->ttf_font = NULL;
|
||||
}
|
||||
|
||||
if (tpf->desc != NULL) {
|
||||
if (tpf->desc != NULL)
|
||||
{
|
||||
free(tpf->desc);
|
||||
tpf->desc = NULL;
|
||||
}
|
||||
|
|
@ -277,6 +280,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile
|
|||
{
|
||||
TuxPaint_Font *tpf = NULL;
|
||||
int i;
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
char desc[1024];
|
||||
#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)
|
||||
{
|
||||
struct pollfd p;
|
||||
|
||||
do
|
||||
{
|
||||
ssize_t rc = write(fd, buf, count);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
struct pollfd p;
|
||||
|
||||
do
|
||||
{
|
||||
ssize_t rc = read(fd, buf, count);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
switch (errno)
|
||||
|
|
@ -570,6 +578,7 @@ static void groupfonts_range(style_info ** base, int count)
|
|||
while (i--)
|
||||
{
|
||||
int b = boldmap[base[i]->boldness];
|
||||
|
||||
if (b == -1)
|
||||
{
|
||||
#if 0
|
||||
|
|
@ -717,6 +726,7 @@ static void parse_font_style(style_info * si)
|
|||
{
|
||||
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");
|
||||
|
|
@ -809,7 +819,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");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -818,9 +828,11 @@ 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;
|
||||
|
|
@ -852,6 +864,7 @@ static void groupfonts(void)
|
|||
for (;;)
|
||||
{
|
||||
int high = low;
|
||||
|
||||
if (low >= num_font_styles)
|
||||
break;
|
||||
for (;;)
|
||||
|
|
@ -882,6 +895,7 @@ static void groupfonts(void)
|
|||
for (;;)
|
||||
{
|
||||
int high = low;
|
||||
|
||||
if (low >= num_font_families)
|
||||
break;
|
||||
for (;;)
|
||||
|
|
@ -946,7 +960,7 @@ static void loadfonts(SDL_Surface * screen, const char *const dir)
|
|||
{
|
||||
char *homedirdir;
|
||||
|
||||
(void) vp; // junk passed by threading library
|
||||
(void)vp; // junk passed by threading library
|
||||
|
||||
loadfonts_locale_filter(screen, DATA_PREFIX "fonts", locale);
|
||||
|
||||
|
|
@ -962,8 +976,9 @@ static void loadfonts(SDL_Surface * screen, const char *const dir)
|
|||
loadfonts(screen, "/usr/X11R6/lib/X11/fonts");
|
||||
#elif defined(__HAIKU__)
|
||||
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;
|
||||
|
||||
result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
|
||||
loadfonts(screen, 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--)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = user_font_families[i]->directory;
|
||||
if (s)
|
||||
size += strlen(s);
|
||||
|
|
@ -1168,7 +1184,7 @@ void receive_some_font_info(SDL_Surface * screen)
|
|||
}
|
||||
rc = read(font_socket_fd, buf + buf_fill, buf_size - buf_fill);
|
||||
#ifdef DEBUG
|
||||
printf("read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", font_socket_fd, buf_fill, buf_size, (long int) rc);
|
||||
printf("read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", font_socket_fd, buf_fill, buf_size, (long int)rc);
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
|
|
@ -1208,8 +1224,8 @@ void receive_some_font_info(SDL_Surface * screen)
|
|||
|
||||
show_progress_bar(screen);
|
||||
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("Got %u bytes with %u families.\n", buf_fill, num_font_families);
|
||||
#endif
|
||||
|
|
@ -1222,6 +1238,7 @@ void receive_some_font_info(SDL_Surface * screen)
|
|||
while (i--)
|
||||
{
|
||||
unsigned len;
|
||||
|
||||
user_font_families[i] = fip + i;
|
||||
|
||||
len = strlen(walk);
|
||||
|
|
@ -1285,7 +1302,7 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
if (fi->filename != NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Setting 'name' to fi->filename[%d (0x%x)]\n", (int) text_state, (int) text_state);
|
||||
printf("Setting 'name' to fi->filename[%d (0x%x)]\n", (int)text_state, (int)text_state);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
@ -1451,8 +1468,9 @@ static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * c
|
|||
return s1->h - s2->h;
|
||||
|
||||
{
|
||||
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)
|
||||
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)
|
||||
{
|
||||
int diff = do_surfcmp(s1, s2);
|
||||
|
||||
if (!diff)
|
||||
was_bad_font = 1;
|
||||
return diff;
|
||||
|
|
@ -1488,6 +1507,7 @@ int charset_works(TuxPaint_Font * font, const char *s)
|
|||
SDL_Surface **surfs = malloc(strlen(s) * sizeof surfs[0]);
|
||||
unsigned count = 0;
|
||||
int ret = 0;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
char c[8];
|
||||
|
|
@ -1571,7 +1591,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf)
|
|||
#ifndef NO_SDLPANGO
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
(void) (tpf);
|
||||
(void)(tpf);
|
||||
/* FIXME */
|
||||
|
||||
return ("");
|
||||
|
|
@ -1602,7 +1622,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf)
|
|||
#ifndef NO_SDLPANGO
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
(void) (tpf);
|
||||
(void)(tpf);
|
||||
/* FIXME */
|
||||
|
||||
return ("");
|
||||
|
|
|
|||
20
src/fonts.h
20
src/fonts.h
|
|
@ -91,21 +91,23 @@ TTF_Font *BUGFIX_TTF_OpenFont206(const char *const file, int ptsize);
|
|||
|
||||
/* Stuff that wraps either SDL_Pango or SDL_TTF for font rendering: */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
#ifndef NO_SDLPANGO
|
||||
FONT_TYPE_PANGO,
|
||||
#endif
|
||||
FONT_TYPE_TTF
|
||||
};
|
||||
|
||||
typedef struct TuxPaint_Font_s {
|
||||
typedef struct TuxPaint_Font_s
|
||||
{
|
||||
#ifndef NO_SDLPANGO
|
||||
SDLPango_Context * pango_context;
|
||||
SDLPango_Context *pango_context;
|
||||
#endif
|
||||
int typ;
|
||||
TTF_Font * ttf_font;
|
||||
TTF_Font *ttf_font;
|
||||
int height;
|
||||
char * desc;
|
||||
char *desc;
|
||||
} TuxPaint_Font;
|
||||
|
||||
int TuxPaint_Font_FontHeight(TuxPaint_Font * tpf);
|
||||
|
|
@ -183,15 +185,15 @@ TuxPaint_Font *getfonthandle(int desire);
|
|||
|
||||
int charset_works(TuxPaint_Font * font, const char *s);
|
||||
|
||||
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);
|
||||
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf);
|
||||
const char * TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf);
|
||||
const char * TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf);
|
||||
const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf);
|
||||
const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf);
|
||||
|
||||
#ifdef NO_SDLPANGO
|
||||
TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size);
|
||||
#else
|
||||
void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix *pango_color);
|
||||
void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color);
|
||||
#endif
|
||||
|
||||
int load_user_fonts(SDL_Surface * screen, void *vp, const char *restrict const locale);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue