Branch: Tag:

2001-08-23

2001-08-23 21:20:59 by Martin Nilsson <mani@lysator.liu.se>

Added verbatim documentation. Use parse_html_entities for text normalization.

Rev: server/modules/graphics/graphic_text.pike:1.275

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";
42: Inside #if defined(manual)
  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>
582:   }      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;
601:    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)    {
638:    }    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}));    }