Pango loads Tux Paint-supplied fonts on macOS.
Previously Pango loaded system-supplied fonts instead, which could lead to fonts not rendering in a human-readable text. This change fixes https://sourceforge.net/p/tuxpaint/bugs/265/
This commit is contained in:
parent
e00b6b4f4a
commit
3849480fd4
9 changed files with 178 additions and 6 deletions
26
src/debug.h
26
src/debug.h
|
|
@ -1,6 +1,32 @@
|
|||
//#define DEBUG
|
||||
//#define VERBOSE
|
||||
|
||||
/*
|
||||
Enable fontconfig debugging. The value of this variable, which must be a
|
||||
string, but is interpreted as a number, and each bit within that value
|
||||
controls different debugging messages. (from
|
||||
https://www.freedesktop.org/software/fontconfig/fontconfig-user.html#DEBUG)
|
||||
|
||||
Name Value Meaning
|
||||
---------------------------------------------------------
|
||||
MATCH 1 Brief information about font matching
|
||||
MATCHV 2 Extensive font matching information
|
||||
EDIT 4 Monitor match/test/edit execution
|
||||
FONTSET 8 Track loading of font information at startup
|
||||
CACHE 16 Watch cache files being written
|
||||
CACHEV 32 Extensive cache file writing information
|
||||
PARSE 64 (no longer in use)
|
||||
SCAN 128 Watch font files being scanned to build caches
|
||||
SCANV 256 Verbose font file scanning information
|
||||
MEMORY 512 Monitor fontconfig memory usage
|
||||
CONFIG 1024 Monitor which config files are loaded
|
||||
LANGSET 2048 Dump char sets used to construct lang values
|
||||
MATCH2 4096 Display font-matching transformation in patterns
|
||||
*/
|
||||
#if defined(DEBUG) && defined(VERBOSE)
|
||||
#define FC_DEBUG "1025"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enable verbose logging if requested on platforms that support it.
|
||||
*
|
||||
|
|
|
|||
10
src/fonts.c
10
src/fonts.c
|
|
@ -286,6 +286,16 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc,
|
|||
desc);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
* SDLPango_CreateContext_GivenFontDesc() defaults to ASCII character set
|
||||
* (at least on the macOS) unless the CHARSET environment varaible is set.
|
||||
* May also want to set on non-macOS platforms, also.
|
||||
*/
|
||||
|
||||
mysetenv("CHARSET", "UTF-8");
|
||||
#endif
|
||||
|
||||
tpf->pango_context = SDLPango_CreateContext_GivenFontDesc(desc);
|
||||
if (tpf->pango_context == NULL)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1064,7 +1064,7 @@ static void set_langint_from_locale_string(const char *restrict loc)
|
|||
* @param name Variable to set
|
||||
* @param value Value to set the variable to
|
||||
*/
|
||||
static void mysetenv(const char *name, const char *value)
|
||||
void mysetenv(const char *name, const char *value)
|
||||
{
|
||||
#ifndef HAVE_SETENV
|
||||
int len;
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ extern w_langs wished_langs[255];
|
|||
int get_current_language(void);
|
||||
int setup_i18n(const char *restrict lang, const char *restrict locale,
|
||||
int *ptr_num_wished_languages) MUST_CHECK;
|
||||
void mysetenv(const char *name, const char *value);
|
||||
|
||||
#ifdef NO_SDLPANGO
|
||||
int smash_i18n(void) MUST_CHECK;
|
||||
|
|
|
|||
|
|
@ -450,8 +450,12 @@ int iswprint(wchar_t wc)
|
|||
#error "---------------------------------------------------"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
/* These are required to display pango debugging information later in this file */
|
||||
#include <pango/pango.h>
|
||||
#include <pango/pangoft2.h>
|
||||
#endif
|
||||
|
||||
#endif /* !defined(NO_SDLPANGO) */
|
||||
|
||||
#ifndef NOSOUND
|
||||
|
||||
|
|
@ -30999,6 +31003,13 @@ int main(int argc, char *argv[])
|
|||
putenv((char *) "FONTCONFIG_PATH=Resources/etc");
|
||||
#endif
|
||||
|
||||
#if defined(FC_DEBUG)
|
||||
/*
|
||||
* Enable fontconfig debugging. See "debug.h"
|
||||
*/
|
||||
mysetenv("FC_DEBUG", FC_DEBUG);
|
||||
#endif
|
||||
|
||||
#ifdef FORKED_FONTS
|
||||
/* must start ASAP, but depends on locale which in turn needs the config */
|
||||
#ifdef NO_SDLPANGO
|
||||
|
|
@ -31044,6 +31055,31 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
|
||||
#if defined(DEBUG) && !defined(NO_SDLPANGO)
|
||||
/* Confirm pango's character set */
|
||||
if(1) {
|
||||
const char* charset;
|
||||
|
||||
g_get_charset(&charset);
|
||||
printf("pango charset: %s\n", charset);
|
||||
}
|
||||
|
||||
/* Display fonts available to pango */
|
||||
if(1) {
|
||||
PangoFontMap* fontmap;
|
||||
PangoFontFamily** families;
|
||||
int n_families;
|
||||
|
||||
fontmap = pango_ft2_font_map_new();
|
||||
pango_font_map_list_families(fontmap, &families, &n_families);
|
||||
|
||||
for(int i=0; i < n_families; i++) {
|
||||
const char* family_name = pango_font_family_get_name(families[i]);
|
||||
|
||||
printf("pango ft2 fontmap[%d] = '%s'\n", i, family_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
claim_to_be_ready();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue