Magic compiles silenced.

Attempted Text tool font load under pango.
Made pango optional.
TuxPaint_Font is aware of both panfgo contexts & sdl_ttf ttf fonts.
This commit is contained in:
William Kendrick 2007-07-13 18:18:20 +00:00
parent 3d1718a2b7
commit 0eecea9581
8 changed files with 261 additions and 103 deletions

View file

@ -87,6 +87,11 @@ NOSOUNDFLAG=__SOUND
NOSVGFLAG=__SVG
# Built with SDL Pango support by default (override with "make nopango")
NOPANGOFLAG=___SDLPANGO
# Built with libcairo2 support by default (use libcairo1 with "make oldsvg")
OLDSVGFLAG=__SVG
@ -137,6 +142,7 @@ CFLAGS=$(OPTFLAGS) -W -Wall -fno-common -ffloat-store \
DEFS=-DDATA_PREFIX=\"$(DATA_PREFIX)/\" \
-D$(NOSOUNDFLAG) -D$(NOSVGFLAG) -D$(OLDSVGFLAG) \
-D$(NOPANGOFLAG) \
-DDOC_PREFIX=\"$(DOC_PREFIX)/\" \
-DLOCALEDIR=\"$(LOCALE_PREFIX)/\" -DIMDIR=\"$(IM_PREFIX)/\" \
-DCONFDIR=\"$(CONFDIR)/\" \
@ -212,6 +218,15 @@ nosvg:
make SVG_LIB= SVG_CFLAGS= NOSVGFLAG=NOSVG
# "make nopango" builds the program with Pango support disabled:
nopango:
@echo
@echo "Building with Pango DISABLED"
@echo
make NOPANGOFLAG=NO_SDLPANGO SDL_PANGO_LIB=
# "make oldsvg" builds the program using older SVG (Cairo1) libraries:
oldsvg:
@ -803,7 +818,8 @@ obj/tuxpaint.o: src/tuxpaint.c \
src/$(MOUSEDIR)/watch.xbm src/$(MOUSEDIR)/watch-mask.xbm \
src/$(MOUSEDIR)/up.xbm src/$(MOUSEDIR)/up-mask.xbm \
src/$(MOUSEDIR)/down.xbm src/$(MOUSEDIR)/down-mask.xbm \
$(ARCH_HEADERS)
$(ARCH_HEADERS) \
Makefile
@echo
@echo "...Compiling Tux Paint from source..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(MOUSE_CFLAGS) $(DEFS) \
@ -887,7 +903,7 @@ obj/win32_print.o: src/win32_print.c obj src/win32_print.h src/debug.h
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/win32_print.c -o obj/win32_print.o
obj/postscript_print.o: src/postscript_print.c obj \
obj/postscript_print.o: src/postscript_print.c Makefile obj \
src/postscript_print.h src/debug.h
@echo
@echo "...Compiling PostScript print support..."

View file

@ -38,9 +38,13 @@ $Id$
TTF_Font structs and some functions were replaced by a new
TuxPaint_Font struct and function, which wraps around either TTF_Font
or SDLPango_Context, depending on whether SDL_Pango is being used.
or both a TTF_Font and a SDLPango_Context, depending on whether
SDL_Pango is being used, and how the font was loaded.
Note: STILL NEEDS WORK!
Can be disabled (will use older SDL_ttf-based code) by building with
"make nopango".
Note: Text tool doesn't show appropriate fonts, but getting closer.
* New Brushes
-----------

View file

@ -6,7 +6,7 @@ Copyright 2002-2007 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.tuxpaint.org/
June 27, 2002 - June 21, 2007
June 27, 2002 - July 12, 2007
$Id$
@ -25,8 +25,9 @@ Requirements:
GNU Lesser General Public License (LGPL).
Along with libSDL, Tux Paint depends on a number of other SDL 'helper'
libraries: SDL_Image (for graphics files), SDL_TTF (for True Type Font
support) and, optionally, SDL_Mixer (for sound effects).
libraries: SDL_Image (for graphics files), SDL_TTF and (optionally)
SDL_Pango (for True Type Font support) and, optionally,
SDL_Mixer (for sound effects).
Linux/Unix Users:
-----------------
@ -37,6 +38,7 @@ Requirements:
libSDL: http://www.libsdl.org/
SDL_Image: http://www.libsdl.org/projects/SDL_image/
SDL_TTF: http://www.libsdl.org/projects/SDL_ttf/
SDL_Pango: http://sourceforge.net/projects/sdlpango/ [OPTIONAL]
SDL_Mixer: http://www.libsdl.org/projects/SDL_mixer/ [OPTIONAL]
They are also typically available along with your Linux distribution
@ -61,13 +63,6 @@ Requirements:
http://www.libpng.org/pub/png/libpng.html
FreeType2
---------
Tux Paint uses TTF (True Type Font) fonts for drawing text.
SDL_ttf will require the FreeType2 library.
http://www.freetype.org/
gettext
-------
Tux Paint uses your system's locale settings along with the
@ -76,6 +71,14 @@ Requirements:
http://www.gnu.org/software/gettext/
libpaper (Linux/Unix only)
--------------------------
As of Tux Paint 0.9.17, Tux Paint can determine your system's
default paper size (e.g., A4 or Letter), or can be told to use a
particular paper size, thanks to libpaper.
http://www.debian.org/
SVG graphics support
--------------------
As of Tux Paint 0.9.17, Tux Paint can load SVG
@ -233,20 +236,34 @@ Compiling and Installation:
---------------------------------------------------------------------------
To disable SVG support (e.g., if your system is not currently supported
by the Cairo library or other SVG-related dependencies), you can
run "make" with "nosvg" as the 'target', instead:
run "make" with "nosvg" as the 'target:
$ make nosvg
Disabling Pango support (and hence Pango, Cairo, etc. dependencies):
--------------------------------------------------------------------
Prior to version 0.9.18, Tux Paint used the libSDL_ttf library for
rendering text using TrueType Fonts. Since 0.9.18, libSDL_Pango is
used, as it has much greater support for internationalization.
However, if you wish to disable the use of SDL_Pango, you may do so
running "make" with "nopango" as the 'target':
$ make nopango
Disabling Sound at Compile-time:
--------------------------------
Alternatively, if you don't have a sound card, or would prefer to build
the program with no sound support (therefore, SDL_mixer not having to be
installed), you can run "make" with "nosound" as the 'target', instead:
If you don't have a sound card, or would prefer to build the program
with no sound support (and therefore without a the SDL_mixer dependency),
you can run "make" with "nosound" as the 'target':
$ make nosound
NOTE: At the moment, the above options cannot be mixed and matched.
In the future, we may switch to using autoconf and autotools to make
these options more flexible.
If you get errors:
------------------
If you receive any errors during compile-time, make sure you have
@ -278,6 +295,12 @@ Compiling and Installation:
# exit
Alternatively, you may be able to simply use the "sudo" command
(e.g., on Ubuntu Linux):
$ sudo make install
NOTE: By default, "tuxpaint", the executable program, is
placed in "/usr/local/bin/". The data files (images, sounds, etc.)
are placed in "/usr/local/share/tuxpaint/".
@ -320,6 +343,9 @@ Compiling and Installation:
(Final location of a translation file will be
under the locale's directory (e.g., "es" for Spanish),
within the "LC_MESSAGES" subdirectory.)
FIXME: This list is out of date. See Makefile and Makefile-i18n for
a complete list.
Uninstalling Tux Paint:
@ -364,3 +390,4 @@ Uninstalling Tux Paint:
superuser mode:
# exit

View file

@ -48,78 +48,77 @@ clean:
negative.$(SO_TYPE): src/negative.c
@echo "Building Negative magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
fade_darken.$(SO_TYPE): src/fade_darken.c
@echo "Building Fade and Darken magic tools"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
mirror_flip.$(SO_TYPE): src/mirror_flip.c
@echo "Building Mirror and Flip magic tools"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
rainbow.$(SO_TYPE): src/rainbow.c
@echo "Building Rainbow magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
blocks_chalk_drip.$(SO_TYPE): src/blocks_chalk_drip.c
@echo "Building Blocks, Chalk and Drip magic tools"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
fill.$(SO_TYPE): src/fill.c
@echo "Building Fill magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
blur.$(SO_TYPE): src/blur.c
@echo "Building Blur magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
grass.$(SO_TYPE): src/grass.c
@echo "Building Grass magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
tint.$(SO_TYPE): src/tint.c
@echo "Building Tint magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
smudge.$(SO_TYPE): src/smudge.c
@echo "Building Smudge magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
cartoon.$(SO_TYPE): src/cartoon.c
@echo "Building Smudge magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
bricks.$(SO_TYPE): src/bricks.c
@echo "Building Large Bricks and Small Bricks magic tools"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
kalidescope.$(SO_TYPE): src/kalidescope.c
@echo "Building Kalidescope magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
glasstile.$(SO_TYPE): src/glasstile.c
@echo "Building Glass Tile magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
emboss.$(SO_TYPE): src/emboss.c
@echo "Building Emboss magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
metalpaint.$(SO_TYPE): src/metalpaint.c
@echo "Building Metal Paint magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
waves.$(SO_TYPE): src/waves.c
@echo "Building Waves magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
flower.$(SO_TYPE): src/flower.c
@echo "Building Flower magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<
foam.$(SO_TYPE): src/foam.c
@echo "Building Foam magic tool"
$(CC) $(CFLAGS) -shared -o $@ $<
@$(CC) $(CFLAGS) -shared -o $@ $<

View file

@ -30,10 +30,6 @@
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
unsigned dirlen, tp_ftw_str * files, unsigned i)
{
/* FIXME */
#ifdef NO_SDLPANGO
dirlen = dirlen;
while (i--)
@ -78,13 +74,14 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
const char *restrict const family = TuxPaint_Font_FontFaceFamilyName(font);
const char *restrict const style = TuxPaint_Font_FontFaceStyleName(font);
printf("success: 0x%x -> 0x%x\n", font, font->ttf_font);
#ifdef DEBUG
int numfaces = TTF_FontFaces(font);
//#ifdef DEBUG
int numfaces = TTF_FontFaces(font->ttf_font);
if (numfaces != 1)
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str,
family, style);
#endif
//#endif
// First, the blacklist. We list font families that can crash Tux Paint
// via bugs in the SDL_ttf library. We also test fonts to be sure that
@ -140,7 +137,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
style);
#endif
}
TTF_CloseFont(font);
TuxPaint_Font_CloseFont(font);
}
else
{
@ -153,9 +150,6 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
free(files[i].str);
}
free(files);
#endif
}

View file

@ -144,7 +144,7 @@ TuxPaint_Font *try_alternate_font(int size)
*p = 0;
snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, prefix);
return TTF_OpenFont(str, size);
return TuxPaint_Font_OpenFont("", str, size);
}
#endif
@ -169,25 +169,25 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf",
DATA_PREFIX, lang_prefix);
ret = TuxPaint_OpenFont(str, size);
ret = TuxPaint_Font_OpenFont("", str, size);
#ifdef __APPLE__
if (ret == NULL)
{
snprintf(str, sizeof(str), "%sfonts/%s.ttf", DATA_PREFIX, lang_prefix);
ret = TuxPaint_Font_OpenFont(str, size);
ret = TuxPaint_Font_OpenFont("", str, size);
}
if (ret == NULL)
{
snprintf(str, sizeof(str), "/Library/Fonts/%s.ttf", lang_prefix);
ret = TuxPaint_Font_OpenFont(str, size);
ret = TuxPaint_Font_OpenFont("", str, size);
}
if (ret == NULL)
{
snprintf(str, sizeof(str), "%s/%s.ttf", macosx.fontsPath, lang_prefix);
ret = TuxPaint_Font_OpenFont(str, size);
ret = TuxPaint_Font_OpenFont("", str, size);
}
#endif
@ -224,38 +224,66 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
{
#ifndef NO_SDLPANGO
SDLPango_FreeContext(tpf->pango_context);
tpf->pango_context = NULL;
free(tpf);
#else
TTF_CloseFont(tpf->ttf_font);
tpf->ttf_font = NULL;
free(tpf);
if (tpf->typ == FONT_TYPE_PANGO)
{
SDLPango_FreeContext(tpf->pango_context);
tpf->pango_context = NULL;
}
#endif
if (tpf->typ == FONT_TYPE_TTF)
{
TTF_CloseFont(tpf->ttf_font);
tpf->ttf_font = NULL;
}
free(tpf);
}
TuxPaint_Font * TuxPaint_Font_OpenFont(const char * pangodesc, const char * ttffilename, int size)
{
TuxPaint_Font * tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font));
TuxPaint_Font * tpf = NULL;
printf("OpenFont(%s, %s)\n", pangodesc, ttffilename);
#ifndef NO_SDLPANGO
char desc[1024];
snprintf(desc, sizeof(desc), "%s %d", pangodesc, size - 2);
if (pangodesc != NULL && pangodesc[0] != '\0')
{
tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font));
tpf->typ = FONT_TYPE_PANGO;
snprintf(desc, sizeof(desc), "%s %d", pangodesc, (size * 3) / 4);
tpf->pango_context = SDLPango_CreateContext_GivenFontDesc(desc);
tpf->height = size - 2; /* FIXME: Is this accurate!? -bjk 2007.07.12 */
(void)(ttffilename);
#else
tpf->ttf_font = TTF_OpenFont(ttffilename, size);
tpf->height = TTF_FontHeight(getfonthandle(tpf->font)));
(void)(pangodesc);
tpf->pango_context = SDLPango_CreateContext_GivenFontDesc(desc);
if (tpf->pango_context == NULL)
{
printf("Failed to load %s\n", desc);
free(tpf);
tpf = NULL;
}
else
tpf->height = size; /* FIXME: Is this accurate!? -bjk 2007.07.12 */
return(tpf);
}
#endif
if (ttffilename != NULL && ttffilename[0] != '\0')
{
tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font));
tpf->typ = FONT_TYPE_TTF;
tpf->ttf_font = TTF_OpenFont(ttffilename, size);
if (tpf->ttf_font == NULL)
{
printf("Failed to load %s: %s\n", ttffilename, SDL_GetError());
free(tpf);
tpf = NULL;
}
else
tpf->height = TTF_FontHeight(tpf->ttf_font);
}
return(tpf);
}
@ -1138,6 +1166,9 @@ TuxPaint_Font *getfonthandle(int desire)
pathname = (char *) "";
(void)(name);
(void)(missing);
printf("getfonthandle(%d) asking SDL_Pango for %s\n", desire, description);
#else
@ -1166,7 +1197,7 @@ TuxPaint_Font *getfonthandle(int desire)
// if the font doesn't load, we die -- it did load OK before though
#ifdef NO_SDLPANGO
TTF_SetFontStyle(fi->handle, missing);
TTF_SetFontStyle(fi->handle->ttf_font, missing);
#endif
return fi->handle;
@ -1252,7 +1283,7 @@ int surfcmp(const void *s1, const void *s2)
int charset_works(TuxPaint_Font * font, const char *s)
{
SDL_Color black = { 0, 0, 0, 0 };
#ifndef SDL_NOPANGO
#ifndef NO_SDLPANGO
SDLPango_Matrix pango_color;
#endif
SDL_Surface **surfs = malloc(strlen(s) * sizeof surfs[0]);
@ -1262,21 +1293,28 @@ int charset_works(TuxPaint_Font * font, const char *s)
{
char c[8];
unsigned offset = 0;
SDL_Surface *tmp_surf;
SDL_Surface *tmp_surf = NULL;
do
c[offset++] = *s++;
while ((*s & 0xc0u) == 0x80u); // assume safe input
c[offset++] = '\0';
#ifndef NO_SDLPANGO
sdl_color_to_pango_color(black, &pango_color);
SDLPango_SetDefaultColor(font->pango_context, &pango_color);
SDLPango_SetText(font->pango_context, c, -1);
tmp_surf = SDLPango_CreateSurfaceDraw(font->pango_context);
#else
tmp_surf = TTF_RenderUTF8_Blended(font, c, black);
if (font->typ == FONT_TYPE_PANGO)
{
sdl_color_to_pango_color(black, &pango_color);
SDLPango_SetDefaultColor(font->pango_context, &pango_color);
SDLPango_SetText(font->pango_context, c, -1);
tmp_surf = SDLPango_CreateSurfaceDraw(font->pango_context);
}
#endif
if (font->typ == FONT_TYPE_TTF)
{
tmp_surf = TTF_RenderUTF8_Blended(font->ttf_font, c, black);
}
if (!tmp_surf)
{
#if 0
@ -1314,6 +1352,7 @@ const char * TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf)
{
#ifndef NO_SDLPANGO
/* FIXME */
(void)(tpf);
return("");
#else
return (TTF_FontFaceFamilyName(tpf->ttf_font));
@ -1324,6 +1363,7 @@ const char * TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf)
{
#ifndef NO_SDLPANGO
/* FIXME */
(void)(tpf);
return("");
#else
return (TTF_FontFaceStyleName(tpf->ttf_font));

View file

@ -64,13 +64,19 @@ TTF_Font *BUGFIX_TTF_OpenFont206(const char *const file, int ptsize);
/* Stuff that wraps either SDL_Pango or SDL_TTF for font rendering: */
enum {
#ifndef NO_SDLPANGO
FONT_TYPE_PANGO,
#endif
FONT_TYPE_TTF
};
typedef struct TuxPaint_Font_s {
#ifndef NO_SDLPANGO
SDLPango_Context * pango_context;
#else
TTF_Font * ttf_font;
#endif
int typ;
TTF_Font * ttf_font;
int height;
} TuxPaint_Font;

View file

@ -978,10 +978,6 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font,
// will substitute a rectangle without telling us. Sometimes it returns NULL.
// Probably we should use FreeType directly. For now though...
/*
height = TuxPaint_Font_FontHeight(font);
if (height < 2)
*/
height = 2;
return thumbnail(img_title_large_off, height * strlen(str) / 2, height, 0);
@ -1015,35 +1011,107 @@ static SDL_Surface *render_text_w(TuxPaint_Font * restrict font,
const wchar_t * restrict str,
SDL_Color color)
{
SDL_Surface *ret;
SDL_Surface *ret = NULL;
int height;
Uint16 *ustr;
#ifndef NO_SDLPANGO
unsigned int i, j;
int utfstr_max;
char * utfstr;
SDLPango_Matrix pango_color;
#endif
ustr = wcstou16(str); // FIXME: For SDL_Pango, too? -bjk 2007.07.12
#ifndef NO_SDLPANGO
if (font->typ == FONT_TYPE_PANGO)
{
sdl_color_to_pango_color(color, &pango_color);
#ifdef NO_SDLPANGO
ret = TTF_RenderUNICODE_Blended(font, ustr, color);
#else
sdl_color_to_pango_color(color, &pango_color);
SDLPango_SetDefaultColor(font->pango_context, &pango_color);
SDLPango_SetDefaultColor(font->pango_context, &pango_color);
SDLPango_SetText(font->pango_context, (char *) ustr, -1); // char * cast ok for SDL_Pango? -bjk 2007.07.12
ret = SDLPango_CreateSurfaceDraw(font->pango_context);
/* Convert from 16-bit UNICODE to UTF-8 encoded for SDL_Pango: */
utfstr_max = (sizeof(char) * 4 * (wcslen(str) + 1));
utfstr = (char *) malloc(utfstr_max);
memset(utfstr, utfstr_max, 0);
j = 0;
for (i = 0; i < wcslen(str); i++)
{
if (str[i] <= 0x0000007F)
{
/* 0x00000000 - 0x0000007F:
0xxxxxxx */
utfstr[j++] = (str[i] & 0x7F);
}
else if (str[i] <= 0x000007FF)
{
/* 0x00000080 - 0x000007FF:
00000abc defghijk
110abcde 10fghijk */
utfstr[j++] = (((str[i] & 0x0700) >> 6) | /* -----abc -------- to ---abc-- */
((str[i] & 0x00C0) >> 6) | /* -------- de------ to ------de */
(0xC0)); /* add 110----- */
utfstr[j++] = (((str[i] & 0x003F)) | /* -------- --fghijk to --fghijk */
(0x80)); /* add 10------ */
}
else if (str[i] <= 0x0000FFFF)
{
/* 0x00000800 - 0x0000FFFF:
abcdefgh ijklmnop
1110abcd 10efghij 10klmnop */
utfstr[j++] = (((str[i] & 0xF000) >> 12) | /* abcd---- -------- to ----abcd */
(0xE0)); /* add 1110---- */
utfstr[j++] = (((str[i] & 0x0FC0) >> 6) | /* ----efgh ij------ to --efghij */
(0x80)); /* add 10------ */
utfstr[j++] = (((str[i] & 0x003F)) | /* -------- --klmnop to --klmnop */
(0x80)); /* add 10------ */
}
else
{
/* 0x00010000 - 0x001FFFFF:
11110abc 10defghi 10jklmno 10pqrstu */
utfstr[j++] = (((str[i] & 0x1C0000) >> 18) | /* ---abc-- -------- -------- to -----abc */
(0xF0)); /* add 11110000 */
utfstr[j++] = (((str[i] & 0x030000) >> 12) | /* ------de -------- -------- to --de---- */
((str[i] & 0x00F000) >> 12) | /* -------- fghi---- -------- to ----fghi */
(0x80)); /* add 10------ */
utfstr[j++] = (((str[i] & 0x000F00) >> 6) | /* -------- ----jklm -------- to --jklm-- */
((str[i] & 0x0000C0) >> 6) | /* -------- -------- no------ to ------no */
(0x80)); /* add 10------ */
utfstr[j++] = ((str[i] & 0x00003F) | /* -------- -------- --pqrstu to --prqstu */
(0x80)); /* add 10------ */
}
}
utfstr[j] = '\0';
SDLPango_SetText(font->pango_context, utfstr, -1);
ret = SDLPango_CreateSurfaceDraw(font->pango_context);
}
#endif
free(ustr); // FIXME: For SDL_Pango, too? -bjk 2007.07.12
if (font->typ == FONT_TYPE_TTF)
{
ustr = wcstou16(str);
ret = TTF_RenderUNICODE_Blended(font->ttf_font, ustr, color);
free(ustr);
}
if (ret)
return ret;
// Sometimes a font will be missing a character we need. Sometimes the library
// will substitute a rectangle without telling us. Sometimes it returns NULL.
// Probably we should use FreeType directly. For now though...
height = TuxPaint_Font_FontHeight(font);
if (height < 2)
height = 2;
height = 2;
return thumbnail(img_title_large_off, height * wcslen(str) / 2, height, 0);
}
@ -2715,6 +2783,8 @@ static void mainloop(void)
if (cur_tool == TOOL_TEXT) // Huh? It had better be!
{
// need to invalidate all the cached user fonts, causing reload on demand
#ifdef NO_SDLPANGO
int i;
for (i = 0; i < num_font_families; i++)
{
@ -2725,7 +2795,7 @@ static void mainloop(void)
user_font_families[i]->handle = NULL;
}
}
// FIXME: is setting do_draw enough?
#endif
draw_fonts();
update_screen_rect(&r_toolopt);
}
@ -7337,7 +7407,7 @@ static void draw_toolbar(void)
dest.x = ((i % 2) * 48) + 4 + (40 - img_tool_names[i]->w) / 2;
dest.y = ((i / 2) * 48) + 40 + 2 + (48 - img_tool_names[i]->h);
dest.y = ((i / 2) * 48) + 40 + 2 + (44 - img_tool_names[i]->h);
SDL_BlitSurface(img_tool_names[i], NULL, screen, &dest);
}
@ -7630,6 +7700,8 @@ static void draw_fonts(void)
if (disable_stamp_controls)
most = 14;
printf("there are %d font families\n", num_font_families);
/* Do we need scrollbars? */
if (num_font_families > most + TOOLOFFSET)