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.193 1999/12/06 05:41:43 peter Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.194 1999/12/07 13:58:08 nilsson Exp $";   constant thread_safe=1;      #include <config.h>   #include <module.h>   #include <stat.h>   inherit "module";   inherit "roxenlib";         // ------------------- Module registration ---------------------
Roxen.git/server/modules/graphics/graphic_text.pike:517:       if(args->crop) background = background->autocrop();    return background;   }         // -------------------- Image cache functions --------------------      roxen.ImageCache image_cache;    - void start(int|void val, object|void conf) + void start()   {    image_cache = roxen.ImageCache( "gtext", draw_callback );   }      constant nbsp = iso88591["&nbsp;"];   constant replace_from = indices( iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",});   constant replace_to = values( iso88591 ) + ({ nbsp, "<", ">", "&", });      #define simplify_text( from ) replace(from,replace_from,replace_to)      mixed draw_callback(mapping args, string text, RequestID id)   { -  array err; -  mixed data; +  object|array data; +  Image.Image img;    int elapsed; -  string orig_text = text; -  object img; +        if( objectp( text ) )    {    if( !args->text )    error("Failed miserably to find a text to draw. That's not"    " good.\n");    id = (object)text;    text = args->text;    }       if(!args->verbatim) // typographically correct...    {    text = replace(text, nbsp, " ");    text = simplify_text( text );    string res="",nspace="",cspace="";    foreach(text/"\n", string line)    { -  cspace="";nspace=""; +  cspace=""; +  nspace="";    foreach(line/" ", string word)    {    string nonum;    if(strlen(word) &&    (nonum = replace(word,    ({"1","2","3","4","5","6","7","8","9","0","."}),    ({"","","","","","","","","","",""}))) == "") {    cspace=nbsp+nbsp;    if((strlen(word)-strlen(nonum)<strlen(word)/2) && -  (upper_case(word) == word)) { +  (upper_case(word) == word))    word=((word/"")*nbsp);    } -  } else if(cspace!="") { +  else if(cspace!="")    cspace=" "; -  } +     res+=(nspace==cspace?nspace:" ")+word;    -  if(cspace!="") nspace=cspace; -  else nspace=" "; +  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}));    }       if( args->afont )    data = resolve_font(args->afont+" "+(args->font_size||32));    else    {    if(!args->nfont) args->nfont = args->font; -  int bold, italic; +  int bold=0, italic=0;    if(args->bold) bold=1;    if(args->light) bold=-1;    if(args->black) bold=2;    if(args->italic) italic=1;    data = get_font(args->nfont||"default",    (int)args->font_size||32,bold,italic,    lower_case(args->talign||"left"),    (float)(int)args->xpad, (float)(int)args->ypad);    }   
Roxen.git/server/modules/graphics/graphic_text.pike:967:      // ------------ Wiretap code to find HTML-colours ---------------------      inline string ns_color(array (int) col)   {    if(!arrayp(col)||sizeof(col)!=3)    return "#000000";    return sprintf("#%02x%02x%02x", col[0],col[1],col[2]);   }    - string|array (string) tag_body(string t, mapping args, RequestID id, object file, + int|array (string) tag_body(string t, mapping args, RequestID id, object file,    mapping defines)   { -  int cols,changed; -  if(args->bgcolor||args->text||args->link||args->alink -  ||args->background||args->vlink) -  cols=1; +  int changed=0; +  int cols=(args->bgcolor||args->text||args->link||args->alink||args->vlink);    - #define FIX(Y,Z,X) do{if(!args->Y || args->Y==""){if(cols){defines->X=Z;args->Y=Z;changed=1;}}else{defines->X=args->Y;if(QUERY(colormode)&&args->Y[0]!='#'){args->Y=ns_color(parse_color(args->Y));changed=1;}}}while(0) + #define FIX(Y,Z,X) do{if(!args->Y || args->Y==""){defines->X=Z;if(cols){args->Y=Z;changed=1;}}else{defines->X=args->Y;if(QUERY(colormode)&&args->Y[0]!='#'){args->Y=ns_color(parse_color(args->Y));changed=1;}}}while(0)       if(!search((id->client||({}))*"","Mosaic"))    {    FIX(bgcolor,"#bfbfbf",bgcolor);    FIX(text, "#000000",fgcolor);    FIX(link, "#0000b0",link);    FIX(alink, "#3f0f7b",alink);    FIX(vlink, "#ff0000",vlink);    } else {    FIX(bgcolor,"#c0c0c0",bgcolor);    FIX(text, "#000000",fgcolor);    FIX(link, "#0000ee",link);    FIX(alink, "#ff0000",alink);    FIX(vlink, "#551a8b",vlink);    }    if(changed && QUERY(colormode))    return ({make_tag("body", args) }); -  +  return 0;   }      string|array(string) tag_fix_color(string tagname, mapping args, RequestID id,    object file, mapping defines)   {    int changed;       if(!id->misc->colors)    id->misc->colors = ({ ({ defines->fgcolor, defines->bgcolor, tagname }) });    else