Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - constant cvs_version="$Id: graphic_text.pike,v 1.60 1997/09/01 01:44:21 per Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.61 1997/09/01 14:20:48 per Exp $";   constant thread_safe=1;      #include <module.h>   inherit "module";   inherit "roxenlib";      #if efun(_static_modules)   # define map_array Array.map   import Image;   # define Image image
Roxen.git/server/modules/graphics/graphic_text.pike:595:   }   #endif      int number=0;      mapping find_cached_args(int num);      array(int)|string write_text(int _args, string text, int size,    object id)   { +  string key = base_key+_args; +  array err; +  text = replace(text, ({ "&lt;", "&gt;", "&amp;" }), ({ "<", ">", "&" })); +  +  err = catch +  {    object img;    mapping args = find_cached_args(_args); -  if(!args) { +  if(!args) +  {    args=(["fg":"black","bg":"white"]);    text="Please reload this page";    } -  -  string key = base_key+_args; -  -  text = replace(text, ({ "&lt;", "&gt;", "&amp;" }), ({ "<", ">", "&" })); -  +     // Check the cache first.. -  if(mixed data = cache_lookup(key, text)) +  while(mixed data = cache_lookup(key, text))    { -  +  if(data == "rendering") { sleep(0.1); continue; }    if(args->nocache) // Remove from cache. Very usable for access counters    cache_remove(key, text);    if(size) return data[1];    return data[0];    }    // Nothing found in the cache. Generate a new image. -  +  cache_set(key, text, "rendering");    -  +    #if efun(get_font)    if(args->nfont)    {    int bold, italic;    if(args->bold) bold=1;    if(args->light) bold=-1;    if(args->italic) italic=1;    if(args->black) bold=2;    data = get_font(args->nfont,(int)args->font_size||32,bold,italic,    lower_case(args->talign||"left"),
Roxen.git/server/modules/graphics/graphic_text.pike:691:    int xp = i*ox/steps;    res += img->copy(xp, 0, xp+len, img->ysize(),    @parse_color(args->bg))->gif_add(0,0,delay);    }    res += img->gif_end();    data = ({ res, ({ len, img->ysize() }) });    }    cache_set(key, text, data);    if(size) return data[1];    return data[0]; +  }; +  cache_set(key, text, 0); +  throw(err);   }         mapping find_file(string f, object rid)   {    int id;    sscanf(f,"%d/%s", id, f);    return http_string_answer(write_text(id,f,0,rid), "image/gif");   }