Added ripples magic.
Added (not finished) (new) sparkles magic. Fixed printf localization bug in postscript printing. Got Text tool working when Pango is used.
This commit is contained in:
parent
0ed6e2fd30
commit
c4b3e49215
7 changed files with 525 additions and 65 deletions
|
|
@ -44,8 +44,6 @@ $Id$
|
|||
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
|
||||
-----------
|
||||
* Sparkles (based on old Magic Tool)
|
||||
|
|
@ -65,9 +63,10 @@ $Id$
|
|||
* Emboss
|
||||
* Metal Paint
|
||||
* Waves
|
||||
* Foam
|
||||
* Ripples
|
||||
* Flower
|
||||
(utilizes Bezier curve example code from Wikipedia.org)
|
||||
* Foam
|
||||
|
||||
* New Localizations:
|
||||
------------------
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ all: negative.$(SO_TYPE) \
|
|||
metalpaint.$(SO_TYPE) \
|
||||
waves.$(SO_TYPE) \
|
||||
flower.$(SO_TYPE) \
|
||||
foam.$(SO_TYPE)
|
||||
foam.$(SO_TYPE) \
|
||||
ripples.$(SO_TYPE) \
|
||||
sparkles.$(SO_TYPE)
|
||||
|
||||
install:
|
||||
cd .. ; make install-magic-plugins
|
||||
|
|
@ -122,3 +124,11 @@ foam.$(SO_TYPE): src/foam.c
|
|||
@echo "Building Foam magic tool"
|
||||
@$(CC) $(CFLAGS) -shared -o $@ $<
|
||||
|
||||
ripples.$(SO_TYPE): src/ripples.c
|
||||
@echo "Building Ripples magic tool"
|
||||
@$(CC) $(CFLAGS) -shared -o $@ $<
|
||||
|
||||
sparkles.$(SO_TYPE): src/sparkles.c
|
||||
@echo "Building Sparkles magic tool"
|
||||
@$(CC) $(CFLAGS) -shared -o $@ $<
|
||||
|
||||
|
|
|
|||
149
magic/src/ripples.c
Normal file
149
magic/src/ripples.c
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
#include "tp_magic_api.h"
|
||||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* Our globals: */
|
||||
|
||||
Mix_Chunk * ripples_snd;
|
||||
|
||||
int ripples_z, ripples_brite;
|
||||
|
||||
Uint32 ripples_api_version(void) { return(TP_MAGIC_API_VERSION); }
|
||||
|
||||
#define deg_cos(x) cos((x) * M_PI / 180.0)
|
||||
#define deg_sin(x) sin((x) * M_PI / 180.0)
|
||||
|
||||
// No setup required:
|
||||
int ripples_init(magic_api * api)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/ripples.wav",
|
||||
api->data_directory);
|
||||
ripples_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
// We have multiple tools:
|
||||
int ripples_get_tool_count(magic_api * api)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
// Load our icons:
|
||||
SDL_Surface * ripples_get_icon(magic_api * api, int which)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/ripples.png",
|
||||
api->data_directory);
|
||||
|
||||
return(IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char * ripples_get_name(magic_api * api, int which)
|
||||
{
|
||||
return(strdup(gettext("Ripples")));
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char * ripples_get_description(magic_api * api, int which)
|
||||
{
|
||||
return(strdup(gettext("Click to make ripples appear over your picture.")));
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void ripples_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
}
|
||||
|
||||
void ripples_linecb(void * ptr, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y)
|
||||
{
|
||||
magic_api * api = (magic_api *) ptr;
|
||||
Uint8 r, g, b;
|
||||
Uint32 pix;
|
||||
|
||||
pix = api->getpixel(last, x + ripples_z, y + ripples_z);
|
||||
SDL_GetRGB(pix, last->format, &r, &g, &b);
|
||||
|
||||
r = max(0, min(255, r + ripples_brite));
|
||||
g = max(0, min(255, g + ripples_brite));
|
||||
b = max(0, min(255, b + ripples_brite));
|
||||
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
|
||||
// Affect the canvas on click:
|
||||
void ripples_click(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
float radius;
|
||||
float fli;
|
||||
int ox, oy, nx, ny, d;
|
||||
|
||||
radius = 100;
|
||||
|
||||
for (fli = 0; fli < radius; fli = fli + .25)
|
||||
{
|
||||
ripples_z = (10 * deg_sin(((50 * 50) / (fli + 4)) * 10));
|
||||
|
||||
ox = fli * deg_cos(0) + x;
|
||||
oy = -fli * deg_sin(0) + y;
|
||||
|
||||
for (d = 0; d <= 360 + (360 / (fli + 1)); d = d + 360 / (fli + 1))
|
||||
{
|
||||
nx = fli * deg_cos(d) + x;
|
||||
ny = -fli * deg_sin(d) + y;
|
||||
|
||||
ripples_brite = (ripples_z * 20 * deg_sin(d + 45)) / ((fli / 4) + 1);
|
||||
|
||||
api->line(which, canvas, last, ox, oy, nx, ny, 1, ripples_linecb);
|
||||
|
||||
ox = nx;
|
||||
oy = ny;
|
||||
}
|
||||
}
|
||||
|
||||
update_rect->x = x - 100;
|
||||
update_rect->y = y - 100;
|
||||
update_rect->w = 200;
|
||||
update_rect->h = 200;
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
void ripples_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
}
|
||||
|
||||
// No setup happened:
|
||||
void ripples_shutdown(magic_api * api)
|
||||
{
|
||||
if (ripples_snd != NULL)
|
||||
Mix_FreeChunk(ripples_snd);
|
||||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void ripples_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int ripples_requires_colors(magic_api * api, int which)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
148
magic/src/sparkles.c
Normal file
148
magic/src/sparkles.c
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libintl.h>
|
||||
#include "tp_magic_api.h"
|
||||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
|
||||
/* Our globals: */
|
||||
|
||||
Mix_Chunk * sparkles_snd;
|
||||
Uint8 sparkles_r, sparkles_g, sparkles_b;
|
||||
|
||||
|
||||
Uint32 sparkles_api_version(void) { return(TP_MAGIC_API_VERSION); }
|
||||
|
||||
|
||||
// No setup required:
|
||||
int sparkles_init(magic_api * api)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/sparkles.wav",
|
||||
api->data_directory);
|
||||
sparkles_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
// We have multiple tools:
|
||||
int sparkles_get_tool_count(magic_api * api)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
// Load our icons:
|
||||
SDL_Surface * sparkles_get_icon(magic_api * api, int which)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/images/magic/sparkles.png",
|
||||
api->data_directory);
|
||||
|
||||
return(IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char * sparkles_get_name(magic_api * api, int which)
|
||||
{
|
||||
return(strdup(gettext("Sparkles")));
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char * sparkles_get_description(magic_api * api, int which)
|
||||
{
|
||||
return(strdup(gettext("Click and drag to draw glowing sparkles on your picture.")));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
|
||||
void do_sparkles(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y)
|
||||
{
|
||||
magic_api * api = (magic_api *) ptr;
|
||||
int xx, yy;
|
||||
Uint32 pix;
|
||||
Uint8 r, g, b;
|
||||
int div;
|
||||
|
||||
for (yy = -8; yy < 8; yy++)
|
||||
{
|
||||
for (xx = -8; xx < 8; xx++)
|
||||
{
|
||||
if (api->in_circle(xx, yy, 8))
|
||||
{
|
||||
pix = api->getpixel(canvas, x + xx, y + yy);
|
||||
|
||||
SDL_GetRGB(pix, canvas->format, &r, &g, &b);
|
||||
|
||||
div = abs(xx * yy);
|
||||
if (div == 0)
|
||||
div = 1;
|
||||
|
||||
r = min(255, r + (sparkles_r / div));
|
||||
g = min(255, g + (sparkles_g / div));
|
||||
b = min(255, b + (sparkles_b / div));
|
||||
|
||||
api->putpixel(canvas, x + xx, y + yy,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void sparkles_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_sparkles);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
||||
update_rect->x = ox - 8;
|
||||
update_rect->y = oy - 8;
|
||||
update_rect->w = (x + 8) - update_rect->x;
|
||||
update_rect->h = (y + 8) - update_rect->h;
|
||||
|
||||
api->playsound(sparkles_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
// Affect the canvas on click:
|
||||
void sparkles_click(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
sparkles_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
void sparkles_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
}
|
||||
|
||||
// No setup happened:
|
||||
void sparkles_shutdown(magic_api * api)
|
||||
{
|
||||
if (sparkles_snd != NULL)
|
||||
Mix_FreeChunk(sparkles_snd);
|
||||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void sparkles_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
sparkles_r = r + 10;
|
||||
sparkles_g = g + 10;
|
||||
sparkles_b = b + 10;
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int sparkles_requires_colors(magic_api * api, int which)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
240
src/fonts.c
240
src/fonts.c
|
|
@ -90,7 +90,7 @@ style_info **user_font_styles;
|
|||
int num_font_styles = 0;
|
||||
int num_font_styles_max = 0;
|
||||
|
||||
int text_state;
|
||||
int text_state = 0;
|
||||
unsigned text_size = 4; // initial text size
|
||||
|
||||
|
||||
|
|
@ -246,7 +246,9 @@ TuxPaint_Font * TuxPaint_Font_OpenFont(const char * pangodesc, const char * ttff
|
|||
char desc[1024];
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("OpenFont(pango:\"%s\", ttf:\"%s\")\n", pangodesc, ttffilename);
|
||||
#endif
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
|
||||
|
|
@ -256,42 +258,60 @@ TuxPaint_Font * TuxPaint_Font_OpenFont(const char * pangodesc, const char * ttff
|
|||
tpf->typ = FONT_TYPE_PANGO;
|
||||
snprintf(desc, sizeof(desc), "%s %d", pangodesc, (size * 3) / 4);
|
||||
|
||||
printf("Creating context: \"%s\"\n", desc);
|
||||
#ifdef DEBUG
|
||||
printf("Creating context: \"%s\"\n", desc);
|
||||
#endif
|
||||
|
||||
tpf->pango_context = SDLPango_CreateContext_GivenFontDesc(desc);
|
||||
if (tpf->pango_context == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Failed to load %s\n", desc);
|
||||
#endif
|
||||
free(tpf);
|
||||
tpf = NULL;
|
||||
}
|
||||
else
|
||||
tpf->height = size; /* FIXME: Is this accurate!? -bjk 2007.07.12 */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_OpenFont() done\n"); fflush(stdout);
|
||||
#endif
|
||||
|
||||
return(tpf);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ttffilename != NULL && ttffilename[0] != '\0')
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Opening TTF\n"); fflush(stdout);
|
||||
#endif
|
||||
|
||||
tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font));
|
||||
tpf->typ = FONT_TYPE_TTF;
|
||||
tpf->ttf_font = TTF_OpenFont(ttffilename, size);
|
||||
if (tpf->ttf_font == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Failed to load %s: %s\n", ttffilename, SDL_GetError());
|
||||
#endif
|
||||
free(tpf);
|
||||
tpf = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Succeeded loading %s\n", ttffilename);
|
||||
#endif
|
||||
tpf->height = TTF_FontHeight(tpf->ttf_font);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_OpenFont() done\n"); fflush(stdout);
|
||||
#endif
|
||||
|
||||
return(tpf);
|
||||
}
|
||||
|
||||
|
|
@ -510,7 +530,7 @@ void receive_some_font_info(SDL_Surface * screen)
|
|||
rc = read(font_socket_fd, buf + buf_fill, buf_size - buf_fill);
|
||||
#ifdef DEBUG
|
||||
printf("read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", font_socket_fd,
|
||||
buf_fill, buf_size, rc);
|
||||
buf_fill, buf_size, (long int) rc);
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
|
|
@ -1160,70 +1180,144 @@ TuxPaint_Font *getfonthandle(int desire)
|
|||
{
|
||||
int missing = 0;
|
||||
family_info *fi = user_font_families[desire];
|
||||
char *name = fi->filename[text_state];
|
||||
char *name;
|
||||
char *pathname;
|
||||
char description[1024];
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\ngetfonthandle(%d)...\n", desire); fflush(stdout);
|
||||
#endif
|
||||
|
||||
if (fi == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("getfonthandle(%d) points to a NULL family\n", desire);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fi->filename != NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Setting 'name' to fi->filename[%d (0x%x)]\n",
|
||||
(int) text_state,
|
||||
(int) text_state);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
name = fi->filename[text_state];
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Which is: %s\n", name); fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DBEUG
|
||||
printf("fi->filename is NULL\n"); fflush(stdout);
|
||||
#endif
|
||||
|
||||
name = NULL;
|
||||
}
|
||||
|
||||
if (fi->handle)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("fi->handle was set (0x%x)\n", (int) fi->handle); fflush(stdout);
|
||||
#endif
|
||||
return fi->handle;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("fi->handle was not yet set\n"); fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
||||
/* FIXME: Doesn't make sense; fi->handle is NULL! -bjk 2007.07.17
|
||||
|
||||
/*
|
||||
#ifndef NO_SDLPANGO
|
||||
snprintf(description, sizeof(description), "%s%s%s", fi->family,
|
||||
(text_state ^ TTF_STYLE_ITALIC ? " italic" : ""),
|
||||
(text_state ^ TTF_STYLE_BOLD ? " bold" : ""));
|
||||
|
||||
pathname = (char *) "";
|
||||
if (fi->handle->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
snprintf(description, sizeof(description), "%s%s%s", fi->family,
|
||||
(text_state ^ TTF_STYLE_ITALIC ? " italic" : ""),
|
||||
(text_state ^ TTF_STYLE_BOLD ? " bold" : ""));
|
||||
|
||||
(void)(name);
|
||||
(void)(missing);
|
||||
pathname = (char *) "";
|
||||
|
||||
printf("getfonthandle(%d) asking SDL_Pango for %s\n", desire, description);
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
printf("getfonthandle(%d) asking SDL_Pango for %s\n", desire, description);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
if (!name)
|
||||
/* FIXME: Doesn't make sense; fi->handle is NULL! -bjk 2007.07.17
|
||||
if (fi->handle->typ == FONT_TYPE_TTF)
|
||||
*/
|
||||
{
|
||||
name = fi->filename[text_state ^ TTF_STYLE_ITALIC];
|
||||
missing = text_state & TTF_STYLE_ITALIC;
|
||||
}
|
||||
if (!name)
|
||||
{
|
||||
name = fi->filename[text_state ^ TTF_STYLE_BOLD];
|
||||
missing = text_state & TTF_STYLE_BOLD;
|
||||
}
|
||||
if (!name)
|
||||
{
|
||||
name = fi->filename[text_state ^ (TTF_STYLE_ITALIC | TTF_STYLE_BOLD)];
|
||||
missing = text_state & (TTF_STYLE_ITALIC | TTF_STYLE_BOLD);
|
||||
}
|
||||
pathname = alloca(strlen(fi->directory) + 1 + strlen(name) + 1);
|
||||
sprintf(pathname, "%s/%s", fi->directory, name);
|
||||
if (!name)
|
||||
{
|
||||
name = fi->filename[text_state ^ TTF_STYLE_ITALIC];
|
||||
missing = text_state & TTF_STYLE_ITALIC;
|
||||
}
|
||||
if (!name)
|
||||
{
|
||||
name = fi->filename[text_state ^ TTF_STYLE_BOLD];
|
||||
missing = text_state & TTF_STYLE_BOLD;
|
||||
}
|
||||
if (!name)
|
||||
{
|
||||
name = fi->filename[text_state ^ (TTF_STYLE_ITALIC | TTF_STYLE_BOLD)];
|
||||
missing = text_state & (TTF_STYLE_ITALIC | TTF_STYLE_BOLD);
|
||||
}
|
||||
if (!name)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("name is still NULL\n"); fflush(stdout);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
strcpy(description, "");
|
||||
pathname = alloca(strlen(fi->directory) + 1 + strlen(name) + 1);
|
||||
sprintf(pathname, "%s/%s", fi->directory, name);
|
||||
|
||||
/* #endif */
|
||||
strcpy(description, "");
|
||||
}
|
||||
|
||||
fi->handle = TuxPaint_Font_OpenFont(description, pathname, text_sizes[text_size]);
|
||||
// if the font doesn't load, we die -- it did load OK before though
|
||||
|
||||
/* #ifdef NO_SDLPANGO */
|
||||
if (fi->handle->ttf_font == NULL)
|
||||
if (fi->handle == NULL)
|
||||
{
|
||||
printf("fi->handle->ttf_font is NULL!\n");
|
||||
fflush(stdout);
|
||||
#ifdef DEBUG
|
||||
printf("fi->handle is NULL!\n"); fflush(stdout);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
TTF_SetFontStyle(fi->handle->ttf_font, missing);
|
||||
/* #endif */
|
||||
if (fi->handle->typ == FONT_TYPE_TTF)
|
||||
{
|
||||
if (fi->handle->ttf_font == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("fi->handle->ttf_font is NULL!\n"); fflush(stdout);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("calling TTF_SetFontStyle(0x%x)\n", missing); fflush(stdout);
|
||||
#endif
|
||||
|
||||
TTF_SetFontStyle(fi->handle->ttf_font, missing);
|
||||
}
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
if (fi->handle->typ == FONT_TYPE_PANGO)
|
||||
printf("It's a Pango context...\n");
|
||||
#endif
|
||||
|
||||
return fi->handle;
|
||||
}
|
||||
|
|
@ -1370,29 +1464,75 @@ out:
|
|||
|
||||
int TuxPaint_Font_FontHeight(TuxPaint_Font * tpf)
|
||||
{
|
||||
if (tpf == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_FontHeight() received NULL\n"); fflush(stdout);
|
||||
#endif
|
||||
return(1);
|
||||
}
|
||||
|
||||
return(tpf->height);
|
||||
}
|
||||
|
||||
const char * TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf)
|
||||
{
|
||||
#ifndef NO_SDLPANGO
|
||||
/* FIXME */
|
||||
(void)(tpf);
|
||||
return("");
|
||||
#else
|
||||
return (TTF_FontFaceFamilyName(tpf->ttf_font));
|
||||
if (tpf == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_FontFaceFamilyName() received NULL\n"); fflush(stdout);
|
||||
#endif
|
||||
return("");
|
||||
}
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
(void)(tpf);
|
||||
/* FIXME */
|
||||
|
||||
return("");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tpf->typ == FONT_TYPE_TTF)
|
||||
return (TTF_FontFaceFamilyName(tpf->ttf_font));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_FontFaceFamilyName() is confused\n");
|
||||
#endif
|
||||
|
||||
return("");
|
||||
}
|
||||
|
||||
const char * TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf)
|
||||
{
|
||||
#ifndef NO_SDLPANGO
|
||||
/* FIXME */
|
||||
(void)(tpf);
|
||||
return("");
|
||||
#else
|
||||
return (TTF_FontFaceStyleName(tpf->ttf_font));
|
||||
if (tpf == NULL)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_FontFaceStyleName() received NULL\n"); fflush(stdout);
|
||||
#endif
|
||||
return("");
|
||||
}
|
||||
|
||||
#ifndef NO_SDLPANGO
|
||||
if (tpf->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
(void)(tpf);
|
||||
/* FIXME */
|
||||
|
||||
return("");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (tpf->typ == FONT_TYPE_TTF)
|
||||
return (TTF_FontFaceStyleName(tpf->ttf_font));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("TuxPaint_Font_FontFaceStyleName() is confused\n");
|
||||
#endif
|
||||
|
||||
return("");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ int f2int(float f)
|
|||
|
||||
int f2dec(float f)
|
||||
{
|
||||
return (int)(f - (((int)f) * 100));
|
||||
return (int)((f - f2int(f)) * 100);
|
||||
}
|
||||
|
||||
/* Actually save the PostScript data to the file stream: */
|
||||
|
|
|
|||
|
|
@ -956,7 +956,7 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_x, int new_y);
|
|||
static SDL_Surface *render_text(TuxPaint_Font * restrict font,
|
||||
const char *restrict str, SDL_Color color)
|
||||
{
|
||||
SDL_Surface *ret;
|
||||
SDL_Surface *ret = NULL;
|
||||
int height;
|
||||
#ifndef NO_SDLPANGO
|
||||
SDLPango_Matrix pango_color;
|
||||
|
|
@ -969,16 +969,32 @@ static SDL_Surface *render_text(TuxPaint_Font * restrict font,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef NO_SDLPANGO
|
||||
ret = TTF_RenderUTF8_Blended(font->ttf_font, str, color);
|
||||
#else
|
||||
sdl_color_to_pango_color(color, &pango_color);
|
||||
#ifndef NO_SDLPANGO
|
||||
if (font->typ == FONT_TYPE_PANGO)
|
||||
{
|
||||
sdl_color_to_pango_color(color, &pango_color);
|
||||
|
||||
SDLPango_SetDefaultColor(font->pango_context, &pango_color);
|
||||
SDLPango_SetText(font->pango_context, str, -1);
|
||||
ret = SDLPango_CreateSurfaceDraw(font->pango_context);
|
||||
#ifdef DEBUG
|
||||
printf("Calling SDLPango_SetText(\"%s\")\n", str);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
SDLPango_SetDefaultColor(font->pango_context, &pango_color);
|
||||
SDLPango_SetText(font->pango_context, str, -1);
|
||||
ret = SDLPango_CreateSurfaceDraw(font->pango_context);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (font->typ == FONT_TYPE_TTF)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Calling TTF_RenderUTF8_Blended(\"%s\")\n", str);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
ret = TTF_RenderUTF8_Blended(font->ttf_font, str, color);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
@ -2817,7 +2833,6 @@ static void mainloop(void)
|
|||
{
|
||||
// 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++)
|
||||
{
|
||||
|
|
@ -2828,7 +2843,6 @@ static void mainloop(void)
|
|||
user_font_families[i]->handle = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
draw_fonts();
|
||||
update_screen_rect(&r_toolopt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue