From 0c31fe003fb9222706aede8d1d10506e341b075e Mon Sep 17 00:00:00 2001 From: div0 Date: Tue, 16 Dec 2008 09:28:08 +0000 Subject: [PATCH] new parameter use git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5232 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- misc/ttf2conchars/foo.sh | 4 ++-- misc/ttf2conchars/ttf2conchars.c | 34 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/misc/ttf2conchars/foo.sh b/misc/ttf2conchars/foo.sh index d81b46cf2..2427be0da 100644 --- a/misc/ttf2conchars/foo.sh +++ b/misc/ttf2conchars/foo.sh @@ -9,6 +9,6 @@ fi set -ex gcc -Wall -Wextra ttf2conchars.c `sdl-config --cflags --libs` -lSDL_ttf -lSDL_image -ggdb3 -./a.out gfx/conchars.tga 0 56 64 gfx/vera-sans.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 0.05 0.004 0.000000000000001 -./a.out gfx/conchars.tga 0 56 64 gfx/vera-sans-big.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 0.18 0.05 0.000000000000001 +./a.out gfx/conchars.tga 0 56 64 gfx/vera-sans.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 1 0.08 0.000000000000001 +./a.out gfx/conchars.tga 0 56 64 gfx/vera-sans-big.tga /usr/share/fonts/truetype/ttf-bitstream-vera/VeraBd.ttf "" "" 1 0.28 0.000000000000001 display gfx/vera-sans-big.tga diff --git a/misc/ttf2conchars/ttf2conchars.c b/misc/ttf2conchars/ttf2conchars.c index 1518187aa..0f672b2fb 100644 --- a/misc/ttf2conchars/ttf2conchars.c +++ b/misc/ttf2conchars/ttf2conchars.c @@ -246,8 +246,8 @@ void blitfilter(SDL_Surface *src, SDL_Surface *dest, int x0, int y0, double A, d { // note: x0, y0 is the origin of the UNFILTERED image; it is "transparently" expanded by a BLURFUNCIMAX. int x, y, d, xa, ya, xb, yb; + d = (int) BLURFUNCIMAX(1, B); - d = (int) BLURFUNCIMAX(A,B); SDL_LockSurface(src); SDL_LockSurface(dest); @@ -572,7 +572,7 @@ int main(int argc, char **argv) SDL_Color white = {255, 255, 255, 255}; Uint32 transparent; int maxAscent, maxDescent, maxWidth; - int i; + int i, j; int currentSize; int isfixed; @@ -591,14 +591,40 @@ int main(int argc, char **argv) double B = atof(argv[10]); double C = atof(argv[11]); int differentFonts; + int d; + + double f = 0, a = 0; + + d = (int) BLURFUNCIMAX(1, B); + fprintf(stderr, "Translating parameters:\nA=%f B=%f (using %d pixels)\n", A, B, (int) BLURFUNCIMAX(A, B)); + if(C == 0) + { + B = A * B; + A = A * 1; + } + else + { + for(i=-d; i<=d; ++i) + for(j=-d; j<=d; ++j) + { + f = BLURFUNC(i*i+j*j, 1, B); + f = MAX(0, f); + + if(C == 0) + a = MAX(a, f); + else + a = a + f; + } + B = A/a * B; + A = A/a * 1; + } + fprintf(stderr, "A=%f B=%f (using %d pixels)\n", A, B, (int) BLURFUNCIMAX(A, B)); char widthfilename[512]; snprintf(widthfilename, sizeof(widthfilename), "%.*s.width", (int)strlen(outfilename) - 4, outfilename); int border=(int) BLURFUNCIMAX(A, B); - fprintf(stderr, "Using %d border pixels\n", border); - if(SDL_Init(0) < 0) errx(1, "SDL_Init failed"); -- 2.39.2