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

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1:   // This is a roxen module. Copyright © 1996 - 2000, Roxen IS.   //    - constant cvs_version="$Id: graphic_text.pike,v 1.274 2001/08/23 01:49:13 nilsson Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.275 2001/08/23 21:20:59 nilsson Exp $";      #include <module.h>   inherit "module";         // ------------------- Module registration ---------------------      constant module_type = MODULE_TAG;   constant module_name = "Graphics: Graphic text";   constant module_doc =
Roxen.git/server/modules/graphics/graphic_text.pike:35:       defvar("ext", 0, "Append format to generated images",    TYPE_FLAG|VAR_MORE|VAR_NOT_CFIF,    "Append the image format (.gif, .png, .jpg, etc) to the generated "    "images. This is not necessary, but might seem nicer.");   }      TAGDOCUMENTATION;   #ifdef manual   constant gtextargs=#" + <attr name='verbatim'><p> +  By default the gtext tag will try to make typographical enhancements to the +  text to make the resulting image as eye pleasing as possible. If you want to +  turn this feature off, add this attribute to the tag.</p> + </attr> +    <attr name='alpha' value='path'><p>    Use the specified image as an alpha channel, together with the    background attribute.</p>   </attr>      <attr name='background' value='path'><p>    Specifies the image to use as background.</p>   </attr>      <attr name='tile'><p>
Roxen.git/server/modules/graphics/graphic_text.pike:575:      void start(int num, Configuration conf)   {    image_cache = roxen.ImageCache( "gtext", draw_callback );    roxen.dump( "etc/modules/GText.pmod" );    if(query("colorparse")) module_dependencies(conf, ({ "wiretap" }) );    compat_level = conf->query("compat_level");   }      private constant nbsp = Roxen.iso88591["&nbsp;"]; - private constant replace_from = indices( Roxen.iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",}); - private constant replace_to = values( Roxen.iso88591 ) + ({ nbsp, "<", ">", "&", }); +     - #define simplify_text( from ) replace(from,replace_from,replace_to) -  +    private Image.Image|mapping draw_callback(mapping args, string text, RequestID id)   {    array data;    Image.Font font;    Image.Image 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( !mappingp( args ) || !stringp( text ))    // errors in the argument cache. Not all that unsusual when using the    // relay module.    return 0; -  +     if(!args->verbatim) // typographically correct...    { -  text = replace(text, nbsp, " "); -  text = simplify_text( text ); +  text = replace(text, ([ nbsp:" ", "&ss;":nbsp, +  "\000":"", "\001":"" ])); +  text = Parser.parse_html_entities(text); +     string res="",nspace="",cspace="";    foreach(text/"\n", string line)    {    cspace="";    nspace="";    foreach(line/" ", string word)    {    string nonum;    if(strlen(word) &&    (nonum = replace(word,
Roxen.git/server/modules/graphics/graphic_text.pike:631:       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), +  text=replace(replace( replace(text,({". ",". "+nbsp}),({"\000","\001"})), +  ".", "."+nbsp+nbsp),    ({"\000","\001"}),({". ","."+nbsp}));    }       if( args->afont )    font = resolve_font(args->afont+" "+args->fontsize);    else    {    int bold=0, italic=0;    if(args->bold) bold=1;    if(args->light) bold=-1;