More splits from "tuxpaint.c":
+ "debug.h": Defines whether debugging printf() calls should be enabled. + "dirwalk.c/h": Callback functions for recursive directory traversal. + "fonts.c/h": Font loading/grouping/discarding variables and functions. + "get_fname.c/h": Functions for constructing preferred file paths.
This commit is contained in:
parent
ce30f735f1
commit
e964eb17a0
19 changed files with 1796 additions and 1568 deletions
120
src/fonts.h
Normal file
120
src/fonts.h
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
fonts.h
|
||||
*/
|
||||
|
||||
#ifndef FONTS_H
|
||||
#define FONTS_H
|
||||
|
||||
// plan to rip this out as soon as it is considered stable
|
||||
//#define THREADED_FONTS
|
||||
#define FORKED_FONTS
|
||||
#ifdef WIN32
|
||||
#undef FORKED_FONTS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_ttf.h"
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#ifndef FORKED_FONTS
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_mutex.h"
|
||||
|
||||
extern SDL_Thread *font_thread;
|
||||
#endif
|
||||
|
||||
extern volatile long font_thread_done, font_thread_aborted;
|
||||
extern volatile long waiting_for_fonts;
|
||||
extern int font_scanner_pid;
|
||||
extern int font_socket_fd;
|
||||
|
||||
extern int no_system_fonts;
|
||||
extern int was_bad_font;
|
||||
|
||||
|
||||
TTF_Font *BUGFIX_TTF_OpenFont206(const char * const file, int ptsize);
|
||||
#define TTF_OpenFont BUGFIX_TTF_OpenFont206
|
||||
|
||||
TTF_Font *try_alternate_font(int size);
|
||||
TTF_Font *load_locale_font(TTF_Font *fallback, int size);
|
||||
int load_user_fonts(SDL_Surface * screen, void *vp);
|
||||
|
||||
#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);
|
||||
void receive_some_font_info(SDL_Surface * screen);
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// font stuff
|
||||
|
||||
// example from a Debian box with MS fonts:
|
||||
// start with 232 files
|
||||
// remove "Cursor", "Webdings", "Dingbats", "Standard Symbols L"
|
||||
// split "Condensed" faces out into own family
|
||||
// group by family
|
||||
// end up with 34 user choices
|
||||
|
||||
extern int text_state;
|
||||
// nice progression (alternating 33% and 25%) 9 12 18 24 36 48 72 96 144 192
|
||||
// commonly hinted sizes seem to be: 9, 10, 12, 14, 18, 20 (less so), 24
|
||||
// reasonable: 9,12,18... and 10,14,18...
|
||||
static int text_sizes[] = {9, 12, 18, 24, 36, 48,
|
||||
56, 64, 96, 112, 128, 160}; // point sizes
|
||||
#define MIN_TEXT_SIZE 0u
|
||||
#define MAX_TEXT_SIZE (sizeof text_sizes / sizeof text_sizes[0] - 1)
|
||||
static unsigned text_size = 4; // initial text size
|
||||
|
||||
// for sorting through the font files at startup
|
||||
typedef struct style_info {
|
||||
char *filename;
|
||||
char *directory;
|
||||
char *family; // name like "FooCorp Thunderstruck"
|
||||
char *style; // junk like "Oblique Demi-Bold"
|
||||
int italic;
|
||||
int boldness;
|
||||
int score;
|
||||
int truetype; // Is it? (TrueType gets priority)
|
||||
} style_info;
|
||||
|
||||
// user's notion of a font
|
||||
typedef struct family_info {
|
||||
char *directory;
|
||||
char *family;
|
||||
char *filename[4];
|
||||
TTF_Font *handle;
|
||||
int score;
|
||||
} family_info;
|
||||
|
||||
extern TTF_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;
|
||||
extern int num_font_styles_max;
|
||||
|
||||
|
||||
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);
|
||||
TTF_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(TTF_Font *font, const char *s);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue