Ability to specify fonts on a per-locale basis
Add to the list found in `src/fonts.c` (use language IDs found in `src/i18n.h`, e.g. "LANG_DE" for German). h/t Shin-ichi for the suggestion Closes https://sourceforge.net/p/tuxpaint/feature-requests/240/
This commit is contained in:
parent
1f623cbe36
commit
3c8f25e6e9
4 changed files with 43 additions and 4 deletions
|
|
@ -70,6 +70,13 @@ https://tuxpaint.org/
|
||||||
Closes https://sourceforge.net/p/tuxpaint/feature-requests/146/
|
Closes https://sourceforge.net/p/tuxpaint/feature-requests/146/
|
||||||
Bill Kendrick <bill@newbreedsoftware.com>
|
Bill Kendrick <bill@newbreedsoftware.com>
|
||||||
|
|
||||||
|
* 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 <bill@newbreedsoftware.com> (code)
|
||||||
|
|
||||||
* Bug Fixes:
|
* Bug Fixes:
|
||||||
----------
|
----------
|
||||||
* In some window size / button size combinations, Eraser
|
* In some window size / button size combinations, Eraser
|
||||||
|
|
|
||||||
12
src/fonts.c
12
src/fonts.c
|
|
@ -19,7 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
Last modified: June 1, 2023
|
Last modified: June 8, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -173,6 +173,16 @@ int button_label_y_nudge;
|
||||||
static void reliable_read(int fd, void *buf, size_t count);
|
static void reliable_read(int fd, void *buf, size_t count);
|
||||||
#endif
|
#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)
|
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
18
src/fonts.h
18
src/fonts.h
|
|
@ -19,7 +19,7 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
(See COPYING.txt)
|
(See COPYING.txt)
|
||||||
|
|
||||||
Last updated: May 31, 2023
|
Last updated: June 8, 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FONTS_H
|
#ifndef FONTS_H
|
||||||
|
|
@ -39,11 +39,23 @@
|
||||||
#include "SDL_ttf.h"
|
#include "SDL_ttf.h"
|
||||||
#include "SDL2_Pango.h"
|
#include "SDL2_Pango.h"
|
||||||
|
|
||||||
|
#include "i18n.h"
|
||||||
|
|
||||||
/* UI font, which as of 0.9.31, can be overridden by "uifont"
|
/* UI font, which as of 0.9.31, can be overridden by "uifont"
|
||||||
setting (also, this will be used if "uifont=default" is specified,
|
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"
|
#include "compiler.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27921,6 +27921,7 @@ static void setup_config(char *argv[])
|
||||||
{
|
{
|
||||||
char str[128];
|
char str[128];
|
||||||
char *picturesdir;
|
char *picturesdir;
|
||||||
|
int i;
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__ANDROID__)
|
#if !defined(_WIN32) && !defined(__ANDROID__)
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
|
|
@ -28097,6 +28098,15 @@ static void setup_config(char *argv[])
|
||||||
tmpcfg.parsertmp_locale = NULL;
|
tmpcfg.parsertmp_locale = NULL;
|
||||||
button_label_y_nudge = setup_i18n(tmpcfg.parsertmp_lang, tmpcfg.parsertmp_locale, &num_wished_langs);
|
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)
|
if (tmpcfg.tp_ui_font)
|
||||||
{
|
{
|
||||||
char * tmp_str;
|
char * tmp_str;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue