Roxen.git / server / font_handlers / imagedir.pike

version» Context lines:

Roxen.git/server/font_handlers/imagedir.pike:1:   #include <config.h>   #include <stat.h> - constant cvs_version = "$Id: imagedir.pike,v 1.6 2000/09/16 21:07:38 per Exp $"; + constant cvs_version = "$Id: imagedir.pike,v 1.7 2000/12/31 23:54:53 nilsson Exp $";      constant name = "Image directory fonts";   constant doc = ("Handles a directory with images (in almost any format), each "    "named after the character they will represent. Characters "    "with codes larger than 127 or less than 48 are encoded like "    "0xHEX where HEX is the code in hexadecimal. There must be a "    "file named 'fontname' in the directory, the first line of "    "that file is used as the name of the font");      inherit FontHandler;
Roxen.git/server/font_handlers/imagedir.pike:63:    static mapping(string:Image.Image) write_char( string c )    {    if( char_cache[ c ] ) return char_cache[ c ];    return char_cache[ c ] = load_char( c );    }       static Image.Image write_row( string text )    {    array(mapping(string:Image.Image)) res = map( text/"", write_char );    -  Image.Image rr=Image.Image((int)abs(`+(0,@res->image->xsize())*x_spacing), +  Image.Image rr; +  if(floatp(x_spacing)) +  rr=Image.Image((int)abs(`+(0,@res->image->xsize())*x_spacing),    max(0,@res->image->ysize())); -  +  else +  rr=Image.Image(abs(`+(0,@res->image->xsize())+(sizeof(res)*x_spacing)), +  max(0,@res->image->ysize()));    -  +     float start;    if( x_spacing < 0 ) start = (float)rr->xsize()-res[0]->image->xsize();       foreach( res, mapping(string:Image.Image) r )    {    if( !r->image ) continue;    if( r->alpha )    rr->paste_mask(r->image,r->alpha,    (int)start,rr->ysize()-r->image->ysize() );    else    rr->paste(r->image,(int)start,rr->ysize()-r->image->ysize()); -  +  if(floatp(x_spacing))    start += r->image->xsize()*x_spacing; -  +  else +  start += r->image->xsize()+x_spacing;    }    return rr;    }       int height()    {    return rsize ? rsize : (rsize = text_extents("0WjI|9")[1] );    }       Image.Image write( string ... what )    {    array(Image.Image) res = map( what, write_row ); -  Image.Image rr = Image.Image( max(0,@res->xsize()), +  Image.Image rr; +  if(floatp(y_spacing)) +  rr = Image.Image( max(0,@res->xsize()),    (int)abs(`+(0,@res->ysize())*y_spacing) ); -  +  else +  rr = Image.Image( max(0,@res->xsize()), +  abs(`+(0,@res->ysize())+(sizeof(res)+y_spacing)) );       float start;    if( y_spacing < 0 ) start = (float)rr->ysize()-res[0]->ysize();       foreach( res, object r )    {    if( j_right ) rr->paste(r,rr->xsize()-r->xsize(),(int)start);    else if( j_center ) rr->paste(r,(rr->xsize()-r->xsize())/2,(int)start);    else rr->paste( r, 0, (int)start ); -  +  if(floatp(y_spacing))    start += r->ysize()*y_spacing; -  +  else +  start += r->ysize()+y_spacing;    }    return rr;    }       array text_extents( string what )    {    Image.Image o = write( what );    return ({ o->xsize(), o->ysize() });    }