Skipping locale-specific fonts, unless we're in that locale.
Providing option to load all locale fonts anyway (the old behavior). Renaming zh_tw.ttf to zh_TW.ttf.
This commit is contained in:
parent
230dac43fa
commit
a219080838
7 changed files with 73 additions and 21 deletions
19
src/fonts.c
19
src/fonts.c
|
|
@ -100,6 +100,7 @@ SDL_Thread *font_thread;
|
|||
|
||||
|
||||
int no_system_fonts;
|
||||
int all_locale_fonts;
|
||||
volatile long font_thread_done = 0, font_thread_aborted = 0;
|
||||
volatile long waiting_for_fonts = 0;
|
||||
int font_scanner_pid;
|
||||
|
|
@ -119,6 +120,9 @@ int text_state = 0;
|
|||
unsigned text_size = 4; // initial text size
|
||||
|
||||
|
||||
void loadfonts_locale_filter(SDL_Surface * screen, const char *const dir, char * 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
|
||||
TTF_OpenFont() with the filename of a font that doesn't exist. This
|
||||
|
|
@ -416,7 +420,7 @@ void reliable_read(int fd, void *buf, size_t count)
|
|||
}
|
||||
|
||||
|
||||
void run_font_scanner(SDL_Surface * screen)
|
||||
void run_font_scanner(SDL_Surface * screen, char * locale)
|
||||
{
|
||||
int sv[2];
|
||||
int size, i;
|
||||
|
|
@ -442,7 +446,7 @@ void run_font_scanner(SDL_Surface * screen)
|
|||
sched_yield(); // try to let the parent run right now
|
||||
SDL_Init(SDL_INIT_NOPARACHUTE);
|
||||
TTF_Init();
|
||||
load_user_fonts(screen, NULL);
|
||||
load_user_fonts(screen, NULL, locale);
|
||||
|
||||
size = 0;
|
||||
i = num_font_families;
|
||||
|
|
@ -657,13 +661,13 @@ void receive_some_font_info(SDL_Surface * screen)
|
|||
#endif
|
||||
|
||||
|
||||
int load_user_fonts(SDL_Surface * screen, void *vp)
|
||||
int load_user_fonts(SDL_Surface * screen, void *vp, char * locale)
|
||||
{
|
||||
char *homedirdir;
|
||||
|
||||
(void) vp; // junk passed by threading library
|
||||
|
||||
loadfonts(screen, DATA_PREFIX "fonts");
|
||||
loadfonts_locale_filter(screen, DATA_PREFIX "fonts", locale);
|
||||
|
||||
if (!no_system_fonts)
|
||||
{
|
||||
|
|
@ -1365,12 +1369,17 @@ 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, char * locale)
|
||||
{
|
||||
char buf[TP_FTW_PATHSIZE];
|
||||
unsigned dirlen = strlen(dir);
|
||||
|
||||
memcpy(buf, dir, dirlen);
|
||||
tp_ftw(screen, buf, dirlen, 1, loadfont_callback);
|
||||
tp_ftw(screen, buf, dirlen, 1, loadfont_callback, locale);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue