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

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - string cvs_version="$Id: graphic_text.pike,v 1.40 1997/04/05 01:26:10 per Exp $"; + string cvs_version="$Id: graphic_text.pike,v 1.41 1997/04/09 01:09:33 per Exp $";      #include <module.h>   inherit "module";   inherit "roxenlib";      #if efun(_static_modules)   # define map_array Array.map   import Image;   #else   # define image Image
Roxen.git/server/modules/graphics/graphic_text.pike:152:    if ((!name)||(name == "")) {    name = QUERY(default_size)+"/"+QUERY(default_font);    } else if(sscanf(name, "%*s/%*s") != 2) {    name=QUERY(default_size)+"/"+name;    }       name = "fonts/" + name;       if(!fnt->load( name ))    { -  perror("Failed to load the font "+name+", using the default font.\n"); +  report_error("Failed to load the font "+name+", using the default font.\n");    if(!fnt->load("fonts/"+QUERY(default_size) +"/"+ QUERY(default_font)))    error("Failed to load the default font\n");    }    catch {    if(justification=="right") fnt->right();    if(justification=="center") fnt->center();    if(xs)fnt->set_x_spacing((100.0+(float)xs)/100.0);    if(ys)fnt->set_y_spacing((100.0+(float)ys)/100.0);    };    return fnt;
Roxen.git/server/modules/graphics/graphic_text.pike:196:      string fix_relative(string file, object id)   {    if(file != "" && file[0] == '/') return file;    file = combine_path(dirname(id->not_query) + "/", file);    return file;   }      object last_image; // Cache the last image for a while.   string last_image_name; - object (image) load_image(string f,object id) + object load_image(string f,object id)   {    if(last_image_name==f) return last_image;    string data;    object file;    object img = image();       if(!(data=roxen->try_get_file(fix_relative(f, id),id)))    if(!(file=open(f,"r")) || (!(data=file->read(0x7fffffff))))    return 0;       if(!img->frompnm(data) && !img->fromgif(data)) return 0;       last_image_name=f;    last_image=img;    call_out(lambda(){last_image=0;last_image_name=0;}, 0);    return img->copy();   }    - object (image) blur(object (image) img, int amnt) + object (image) blur(object img, int amnt)   {    img->setcolor(0,0,0);    img = img->autocrop(amnt, 0,0,0,0, 0,0,0);       for(int i=0; i<amnt; i++)    img = img->apply_matrix( make_matrix((int)sqrt(img->ysize()+20)));    return img;   }      object (image) outline(object (image) on, object (image) with,
Roxen.git/server/modules/graphics/graphic_text.pike:288:    corner=0;    in->paste_mask(corner2, corner2->color(70,70,70), -1, -1);       corner2 = pix = 0;    return in;   }         object (image) make_text_image(mapping args, object font, string text,object id)   { -  object (image) text_alpha=font->write(@(text/"\n")); +  object text_alpha=font->write(@(text/"\n"));    int xoffset=0, yoffset=0;       if(!text_alpha->xsize() || !text_alpha->ysize())    text_alpha = image(10,10, 0,0,0);      // perror("Making image of '%s', args=%O\n", text, args);       if(int op=((((int)args->opaque)*255)/100)) // Transparent text...    text_alpha=text_alpha->color(op,op,op);   
Roxen.git/server/modules/graphics/graphic_text.pike:503:       if(args->glow)    {    int amnt = (int)(args->glow/",")[-1]+2;    array (int) blurc = parse_color((args->glow/",")[0]);    background->paste_alpha_color(blur(text_alpha, amnt),@blurc,    xoffset-amnt, yoffset-amnt);    }       if(args->chisel) -  foreground=text_alpha->apply_matrix( ({ ({8,1,0}), +  foreground=text_alpha->apply_matrix(({ ({8,1,0}),    ({1,0,-1}), -  ({0,-1,-8}) }), 128,128,128, 15 ) +  ({0,-1,-8}) }), +  128,128,128, 15 )    ->color(@fgcolor);          if(!foreground) foreground=image(txsize, tysize, @fgcolor);    if(args->textscale)    {    string c1="black",c2="black",c3="black",c4="black";    sscanf(args->textscale, "%s,%s,%s,%s", c1, c2, c3, c4);    foreground->tuned_box(0,0, txsize,tysize,    ({parse_color(c1),parse_color(c2),parse_color(c3),
Roxen.git/server/modules/graphics/graphic_text.pike:548:    background = background->rotate((float)args->rotate);    }       if(args->crop) background = background->autocrop();       return background;   }      string base_key = "gtext:"+roxen->current_configuration->name;    - //void print_colors(array from) - //{ - // for(int i=0; i<sizeof(from); i++) - // perror("%d: %s\n", i, color_name(from[i])); - //} + #ifdef QUANT_DEBUG + void print_colors(array from) + { + #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=(time(1)/10) % 1000, _start=time(1)/10 % 1000;      array(int)|string write_text(int _args, string text, int size,    object id)   {    object img;    mapping args = cached_args[_args];    if(!args) {    args=(["fg":"black","bg":"white"]);
Roxen.git/server/modules/graphics/graphic_text.pike:607:    data = cache_lookup("fonts", fkey);    if(!data)    {    data = load_font(args->font, lower_case(args->talign||"left"),    (int)args->xpad,(int)args->ypad);    cache_set("fonts", fkey, data);    }    }       // Fonts and such are now initialized. -  +     img = make_text_image(args,data,text,id);       // Now we have the image in 'img', or nothing. -  +     if(!img) return 0;       int q = (int)args->quant||(args->background||args->texture?250:QUERY(cols));       if(q>255) q=255;    if(q<3) q=3;      // Quantify    if(!args->fs)    { - // print_colors(img->select_colors(q-1)+({parse_color(args->bg)})); + #ifdef QUANT_DEBUG +  print_colors(img->select_colors(q-1)+({parse_color(args->bg)})); + #endif    img = img->map_closest(img->select_colors(q-1)+({parse_color(args->bg)}));    } -  // place in cache. +  + // place in cache, as a gif image.    if(args->fs)    data=({ img->togif_fs(@(args->notrans?({}):parse_color(args->bg))),    ({img->xsize(),img->ysize()})});    else    data=({ img->togif(@(args->notrans?({}):parse_color(args->bg))),    ({img->xsize(),img->ysize()})});    img=0;       cache_set(key, text, data);    if(size) return data[1];
Roxen.git/server/modules/graphics/graphic_text.pike:834:    if(arg->href)    {    url = arg->href;    lp = "<a href=\""+arg->href+"\" "+ea+">";    if(!arg->fg) arg->fg=defines->link||"#0000ff";    m_delete(arg, "href");    }       if(defines->fg && !arg->fg) arg->fg=defines->fg;    if(defines->bg && !arg->bg) arg->bg=defines->bg; - // if(!arg->font) arg->font=defines->font||QUERY(default_font); +    #if efun(get_font)    if(!arg->nfont) arg->nfont=defines->nfont;   #endif    if(!arg->bold) arg->bold=defines->bold;    if(!arg->italic) arg->italic=defines->italic;    if(!arg->black) arg->black=defines->black;    if(!arg->narrow) arg->narrow=defines->narrow;    if(!arg->font) arg->font=defines->font||QUERY(default_font);       if(arg->split)