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.63 1997/09/03 05:16:34 per Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.64 1997/09/03 12:11:12 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:597: Inside #if defined(QUANT_DEBUG) and #if efun(color_name)
   for(int i=0; i<sizeof(from); i++)    perror("%d: %s\n", i, color_name(from[i]));   #endif   }   #endif      int number=0;      mapping find_cached_args(int num);    + constant nbsp = sprintf("%c",160); +  + array gif_size(string d) + { +  int x,y; +  d=d[6..12]; +  x = (d[1]<<8) + d[0]; y = (d[3]<<8) + d[2]; +  return ({x,y}); + } +    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;" }), ({ "<", ">", "&" })); +  text = replace(text, ({ "\0","&ss;","&lt;","&gt;","&amp;"}),({"/",nbsp,"<", ">", "&" }));    -  +     err = catch    {    object img;    mapping args = find_cached_args(_args);    if(!args)    {    args=(["fg":"black","bg":"white"]);    text="Please reload this page";    } -  +  if(!args->verbatim) +  { +  string res="",nspace="",cspace="", nonum; +  foreach(text/"\n", string line) +  { +  cspace="";nspace=""; +  foreach(line/" ", string word) +  { +  if(strlen(word) && +  (nonum=replace(word,({"1","2","3","4","5","6","7","8","9","0","."}), +  ({"","","","","","","","","","",""}))) +  =="") +  cspace=nbsp+nbsp; +  else if(cspace!="") +  cspace=" "; +  if((strlen(word)-strlen(nonum)<strlen(word)/2) && (upper_case(word) == word)) +  word=((word/"")*nbsp); +  res+=(nspace==cspace?nspace:" ")+word; +  +  if(cspace!="") nspace=cspace; +  else nspace=" "; +  } +  res+="\n"; +  } +  text = replace(res[..strlen(res)-2], ({ "!","?",": " }), ({ nbsp+"!",nbsp+"?",nbsp+": " })); +  text = replace(replace(replace(text,({". ",". "+nbsp}), ({"\000","\001"})),".","."+nbsp+nbsp),({"\000","\001"}),({". ","."+nbsp})); +  }    // Check the cache first..    while(mixed data = cache_lookup(key, text))    { -  if(data == "rendering") { sleep(0.1); continue; } +  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)
Roxen.git/server/modules/graphics/graphic_text.pike:732:      string quote(string in)   {    string res="";    for(int i=0; i<strlen(in); i++)    switch(in[i])    {    case 'a'..'z':    case 'A'..'Z':    case '0'..'9': -  case '.': -  case ',': -  case '!': +  case '.': case ',': case '!': +  case ':':    res += in[i..i];    break;    default:    res += sprintf("%%%02x", in[i]);    }    return res;   }      int args_restored = 0;   void restore_cached_args()
Roxen.git/server/modules/graphics/graphic_text.pike:760:    string data = o->read();    catch {    object q;    if(sizeof(indices(q=Gz)))    data=q->inflate()->inflate(data);    };    catch {    cached_args |= decode_value(data);    };    } +  if(cached_args && sizeof(cached_args))    number = sort(indices(cached_args))[-1]+1;   }      void save_cached_args()   {    restore_cached_args();    object o = open(".gtext_args_"+hash(mc->name), "wct");    string data=encode_value(cached_args);    catch {    object q;