Roxen.git / server / font_handlers / imagedir.pike

version» Context lines:

Roxen.git/server/font_handlers/imagedir.pike:1:   #include <config.h>   #include <stat.h> - constant cvs_version = "$Id: imagedir.pike,v 1.4 2000/09/04 07:40:50 per Exp $"; + constant cvs_version = "$Id: imagedir.pike,v 1.5 2000/09/16 20:43:31 nilsson Exp $";      constant name = "Image directory fonts";   constant doc = ("Handles a directory with images (in almost any format), each "    "named after the character they will represent. Characters "    "with codes larger than 127 or less than 48 are encoded like "    "0xHEX where HEX is the code in hexadecimal. There must be a "    "file named 'fontname' in the directory, the first line of "    "that file is used as the name of the font");      inherit FontHandler;
Roxen.git/server/font_handlers/imagedir.pike:118:    }       void create( string _path, int _size )    {    path = _path;    size = _size;    }   }      mapping font_list; + mapping meta_data;   static string font_name( string what )   { -  return (lower_case( replace(what," ","_") )/"\n")[0]-"\r"; +  if(!meta_data) meta_data=([]); +  mapping _meta_data=([]); +  Parser.HTML()-> +  add_containers( ([ "name":lambda(string t, mapping m, string c) { +  what=c; return ""; }, +  "meta":lambda(string t, mapping m, string c) { +  _meta_data[m->name]=c; }, +  ]) )->finish(what); +  +  what=(lower_case( replace(what," ","_") )/"\n")[0]-"\r"; +  if(sizeof(_meta_data)) meta_data[what]=_meta_data; +  return what;   }      void update_font_list()   {    font_list = ([]);    foreach(roxen->query("font_dirs"), string dir)    foreach( (get_dir( dir )||({})), string d )    if( file_stat( dir+d )[ ST_SIZE ] == -2 ) // isdir    if( file_stat( dir+d+"/fontname" ) )    font_list[font_name(Stdio.read_bytes(dir+d+"/fontname"))]=dir+d+"/";
Roxen.git/server/font_handlers/imagedir.pike:150:    return indices( font_list );   }      array(mapping) font_information( string fnt )   {   #ifdef THREADS    object key = lock->lock();   #endif    if( !font_list ) update_font_list();    if( font_list[ fnt ] ) -  return ({ ([ +  return ({ (meta_data[fnt] || ([])) | ([    "name":fnt,    "family":fnt,    "path":font_list[fnt],    "format":"imagedir",    ])    });    return ({});   }      array has_font( string name, int size )