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.266 2001/06/29 09:31:11 jonasw Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.267 2001/07/08 17:03:39 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:559: Inside #if defined(manual)
   Returns a relative path to the image, i.e. a shorter one.   </p>   </attr>   <noex>"+gtextargs+"</noex>",]);   #endif         // -------------------- Image cache functions --------------------      roxen.ImageCache image_cache; + string compat_level;      string status() {    array s=image_cache->status();    return sprintf("<b>Images in cache:</b> %d images<br />\n"    "<b>Cache size:</b> %s",    s[0], Roxen.sizetostring(s[1]));   }      mapping(string:function) query_action_buttons() {    return ([ "Clear cache":flush_cache ]);
Roxen.git/server/modules/graphics/graphic_text.pike:580:      void flush_cache() {    image_cache->flush();   }      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");   }      constant nbsp = Roxen.iso88591["&nbsp;"];   constant replace_from = indices( Roxen.iso88591 )+ ({"&ss;","&lt;","&gt;","&amp;",});   constant replace_to = values( Roxen.iso88591 ) + ({ nbsp, "<", ">", "&", });      #define simplify_text( from ) replace(from,replace_from,replace_to)      mixed draw_callback(mapping args, string text, RequestID id)   {
Roxen.git/server/modules/graphics/graphic_text.pike:646:    }    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 ) -  font = resolve_font(args->afont+" "+(args["fontsize"]||32)); +  font = resolve_font(args->afont+" "+args->fontsize);    else    {    int bold=0, italic=0; -  if(args->nfont) args->font = args->nfont; +     if(args->bold) bold=1;    if(args->light) bold=-1;    if(args->black) bold=2;    if(args->italic) italic=1; -  +     int|float xpad=0.0;    if(args->xpad)    if(args->xpad[-1]=='%')    xpad = (float)args->xpad;    else    xpad = (int)args->xpad; -  +     int|float ypad=0.0;    if(args->ypad)    if(args->ypad[-1]=='%')    ypad = (float)args->ypad;    else    ypad = (int)args->ypad; -  font = get_font(args->font||"default", -  (int)args["fontsize"]||32, +  +  font = get_font(args->font, +  (int)args->fontsize||32,    bold,    italic,    lower_case(args->talign||"left"),    xpad,    ypad);    } -  if(!font) -  font = resolve_font(0); +        if (!font)    error("gtext: No font (tried "+    (args->afont||args->font||args->nfont)+ ")!\n");       // Fonts and such are now initialized.    [img, Image.Image alpha] = GText.make_text_image(args, font, text, id);       // Now we have the image in 'img'.   
Roxen.git/server/modules/graphics/graphic_text.pike:787:    "fgcolor",    "font",    "fontsize",    "ghost",    "glow",    "italic",    "light",    "mirrortile",    "move",    "narrow", -  "nfont", +     "notrans",    "opaque",    "outline",    "pressed",    "rescale",    "rotate",    "scale",    "scolor",    "scroll",    "shadow",
Roxen.git/server/modules/graphics/graphic_text.pike:833:   });      constant theme=({"fgcolor","bgcolor","font"});      constant hreffilter=(["split":1,"magic":1,"noxml":1,"alt":1]);      mapping mk_gtext_arg(mapping arg, RequestID id)   {    mapping p=([]); //Picture rendering arguments.    + #if ROXEN_COMPAT < 2.2 +  if(compat_level < "2.2") { +  p->compat = compat_level; +  p->font = m_delete(arg, "nfont"); +  } + #endif +     m_delete(arg,"src");    m_delete(arg,"width");    m_delete(arg,"height");      #if !constant(Image.GIF) || !constant(Image.GIF.encode)    // fadein or scroll not supported without GIF    m_delete(arg, "fadein");    m_delete(arg, "scroll");   #endif   
Roxen.git/server/modules/graphics/graphic_text.pike:882:    }    }       foreach(theme, string tmp)    if( (id->misc->defines[tmp] || id->misc->defines["theme_"+tmp]) && !p[tmp])    p[tmp]=id->misc->defines["theme_"+tmp] || id->misc->defines[tmp];       if(!p->fgcolor) p->fgcolor="#000000";    if(!p->bgcolor) p->bgcolor="#ffffff";    -  if(id->misc->defines->nfont && !p->nfont) p->nfont=id->misc->gtext_nfont; -  if(id->misc->defines->afont && !p->afont) p->afont=id->misc->gtext_afont; + #if ROXEN_COMPAT < 2.2 +  if(id->misc->defines->nfont && !p->nfont && !p->font && !p->afont && compat_level<"2.2") +  p->font=id->misc->gtext_nfont; + #endif +  if(id->misc->defines->afont && !p->nfont && !p->font && !p->afont) +  p->afont=id->misc->gtext_afont;    if(id->misc->defines->bold && !p->bold) p->bold=id->misc->gtext_bold;    if(id->misc->defines->italic && !p->italic) p->italic=id->misc->gtext_italic;    if(id->misc->defines->black && !p->black) p->black=id->misc->gtext_black;    if(id->misc->defines->narrow && !p->narrow) p->narrow=id->misc->gtext_narrow;    -  +  if(p->afont) { +  p->font = roxen->fonts->verify_font( p->afont+" "+p->fontsize ); +  if(!p->font) RXML.parse_error("Font "+p->afont+" could not be loaded.\n"); +  } +  else { +  string font = p->font; +  p->font = roxen->fonts->verify_font(p->font, p->fontsize||32); +  if(!p->font) RXML.parse_error("Font "+font+" could not be loaded.\n"); +  } +     return p;   }      string fix_text(string c, mapping m, RequestID id) {       if(m->nowhitespace)    {    c=String.trim_all_whites(c);    m_delete(m, "nowhitespace");    }