Roxen.git / server / font_handlers / ttf.pike

version» Context lines:

Roxen.git/server/font_handlers/ttf.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2000, Roxen IS.      #if constant(has_Image_TTF)   #include <config.h> - constant cvs_version = "$Id: ttf.pike,v 1.2 2000/09/03 16:46:26 nilsson Exp $"; + constant cvs_version = "$Id: ttf.pike,v 1.3 2000/09/04 05:09:44 per Exp $";      constant name = "TTF fonts";   constant doc = "True Type font loader.";   constant scalable = 1;      inherit FontHandler;      static mapping ttf_font_names_cache;      static string trimttfname( string n )
Roxen.git/server/font_handlers/ttf.pike:44:    ttf_font_names_cache=([]);    void traverse_font_dir( string dir )    {    foreach(r_get_dir( dir )||({}), string fname)    {    string path=combine_path(dir+"/",fname);    if(!ttf_done[path]++)    {    Stat a=file_stat(path);    if(a && a[1]==-2) { +  if( !file_stat( path+"/fontname" ) ) +  // no, we do not want to try this dir. :-)    traverse_font_dir( path );    continue;    }    // Here is a good place to impose the artificial restraint that    // the file must match *.ttf    Image.TTF ttf;    if(catch(ttf = Image.TTF( combine_path(dir+"/",fname) )))    continue;    if(ttf)    {
Roxen.git/server/font_handlers/ttf.pike:132:    rr->paste( r, (rr->xsize()-r->xsize())/2, (int)start );    else    rr->paste( r, 0, (int)start );    start += r->ysize()*y_spacing;    }    return rr->scale(0.5);    }       array text_extents( string what )    { -  Image.Image o = real_write( what ); -  return ({ o->xsize()/2, o->ysize()/2 }); +  Image.Image o = write( what ); +  return ({ o->xsize(), o->ysize() });    }    -  static void create(object r, int s, string fn) +  void create(object r, int s, string fn)    {    string encoding;    real = r;    size = s;    real->set_height( (int)(size*64/34.5) ); // aproximate to pixels       if(r_file_stat(fn+".properties"))    parse_html(lopen(fn+".properties","r")->read(), ([]),    (["encoding":lambda(string tag, mapping m, string enc) {    encoding = enc;    }]));       if(encoding)    encoder = Locale.Charset.encoder(encoding, "");       real_write = (encoder? write_encoded : real->write);    }   }    -  +    array available_fonts()   {    if( !ttf_font_names_cache ) build_font_names_cache( );    return indices( ttf_font_names_cache );   }      array(mapping) font_information( string font )   {    if( !has_font( font, 0 ) )    return ({});
Roxen.git/server/font_handlers/ttf.pike:191:   }      array(string) has_font( string name, int size )   {    if( !ttf_font_names_cache )    build_font_names_cache( );    if( ttf_font_names_cache[ name ] )    return indices(ttf_font_names_cache[ name ]);   }    - void create() - { -  roxen.getvar( "font_dirs" ) -  ->add_changed_callback( lambda(Variable.Variable v){ -  ttf_font_names_cache=0; -  } ); - } -  +    Font open(string f, int size, int bold, int italic )   {    string tmp;    int|string style = font_style( f, size, bold, italic );    object fo;       if( style == -1 ) // exact file    {    if( fo = Image.TTF( name ) )    return TTFWrapper( fo, size, f );
Roxen.git/server/font_handlers/ttf.pike:225:    if( tmp = ttf_font_names_cache[ f ][ style ] )    {    fo = Image.TTF( tmp );    if( fo ) return TTFWrapper( fo(), size, tmp );    }    if( fo = Image.TTF( roxen_path(f = values(ttf_font_names_cache[ f ])[0])))    return TTFWrapper( fo(), size, f );    }    return 0;   } +  +  +  +  + void create() + { +  roxen.getvar( "font_dirs" ) +  ->add_changed_callback( lambda(Variable.Variable v){ +  ttf_font_names_cache=0; +  } ); + }   #endif