diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 312b0d640..e4011c276 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -70,6 +70,13 @@ https://tuxpaint.org/ Closes https://sourceforge.net/p/tuxpaint/feature-requests/146/ Bill Kendrick + * WIP Different default fonts may be set on a per-locale basis + (hard-coded into Tux Paint). Most locales still use "DejaVu Sans", + if available. As of 0.9.31, things are configured as: + + Japanese: TBD + Closes https://sourceforge.net/p/tuxpaint/feature-requests/240/ + Bill Kendrick (code) + * Bug Fixes: ---------- * In some window size / button size combinations, Eraser diff --git a/src/fonts.c b/src/fonts.c index c9d39c52a..ad499b68e 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last modified: June 1, 2023 + Last modified: June 8, 2023 */ #include @@ -173,6 +173,16 @@ int button_label_y_nudge; static void reliable_read(int fd, void *buf, size_t count); #endif +const char * PANGO_DEFAULT_FONT = "DejaVu Sans"; + +default_locale_font_t default_local_fonts[] = { + { + LANG_JA, + "TakaoPGothic" /* Included in Ubuntu "fonts-takao-gothic" package */ + // FIXME: Shin-ichi recommend something, please! -bjk 2023.06.08 + }, + {-1, NULL}, +}; void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) { diff --git a/src/fonts.h b/src/fonts.h index b7b2d665d..2cb34c2a8 100644 --- a/src/fonts.h +++ b/src/fonts.h @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: May 31, 2023 + Last updated: June 8, 2023 */ #ifndef FONTS_H @@ -39,11 +39,23 @@ #include "SDL_ttf.h" #include "SDL2_Pango.h" +#include "i18n.h" + /* UI font, which as of 0.9.31, can be overridden by "uifont" setting (also, this will be used if "uifont=default" is specified, - e.g. to override a config. file option using a command-line option) */ + e.g. to override a config. file option using a command-line option). -#define PANGO_DEFAULT_FONT "DejaVu Sans" + Also, starting in 0.9.31, we can specify different preferred fonts + based on locale. +*/ + +typedef struct default_locale_font_s { + int locale_id; + const char * font_name; +} default_locale_font_t; + +extern default_locale_font_t default_local_fonts[]; +extern const char * PANGO_DEFAULT_FONT; #include "compiler.h" diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 007af6736..420ed1773 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -27921,6 +27921,7 @@ static void setup_config(char *argv[]) { char str[128]; char *picturesdir; + int i; #if !defined(_WIN32) && !defined(__ANDROID__) const char *home = getenv("HOME"); @@ -28097,6 +28098,15 @@ static void setup_config(char *argv[]) tmpcfg.parsertmp_locale = NULL; button_label_y_nudge = setup_i18n(tmpcfg.parsertmp_lang, tmpcfg.parsertmp_locale, &num_wished_langs); + /* Determine the referred font for the current locale */ + for (i = 0; default_local_fonts[i].locale_id != -1; i++) + { + if (default_local_fonts[i].locale_id == get_current_language()) + { + PANGO_DEFAULT_FONT = default_local_fonts[i].font_name; + } + } + if (tmpcfg.tp_ui_font) { char * tmp_str;