b824672000-09-03Martin Nilsson // This file is part of Roxen WebServer. // Copyright © 1996 - 2000, Roxen IS. #include <config.h>
e514522000-09-04Per Hedbor constant cvs_version = "$Id: old.pike,v 1.4 2000/09/04 05:09:24 per Exp $";
c6fd2e2000-09-03Per Hedbor  constant name = "Compatibility bitmap fonts"; constant doc = "Compatibility (bitmapped) fonts for Roxen 1.3 and earlier."; inherit FontHandler; array available_fonts() { array res = ({}); foreach(roxen->query("font_dirs"), string dir) { dir+="32/"; if(array d = r_get_dir(dir)) { foreach(d,string f) { if(f=="CVS") continue; Stat a; if((a=r_file_stat(dir+f)) && (a[1]==-2)) { array d=r_get_dir(dir+f); foreach( ({ "nn", "ni", "li", "ln", "Bi", "Bn", "bi", "bn" }), string style) if(has_value(d, style)) { res |= ({ replace(f,"_", " ") }); break; } } } } } return res; }
b824672000-09-03Martin Nilsson array(mapping) font_information( string fnt )
c6fd2e2000-09-03Per Hedbor {
b824672000-09-03Martin Nilsson  array font_infos=({});
c6fd2e2000-09-03Per Hedbor  foreach(roxen->query("font_dirs"), string dir) { dir+="32/"; if( r_file_stat( dir+fnt ) )
d3a6822000-09-03Martin Nilsson  // the font file exists in this dir..
c6fd2e2000-09-03Per Hedbor  { array d = r_get_dir(dir+fnt); foreach( ({ "nn", "ni", "li", "ln", "Bi", "Bn", "bi", "bn" }), string style) if(has_value(d, style)) {
b824672000-09-03Martin Nilsson  mapping font_info = ([ "name":fnt,
d3a6822000-09-03Martin Nilsson  "family":fnt,
b824672000-09-03Martin Nilsson  "path":dir+fnt, "format":"bitmap dump" ]); switch(style[0]) { case 'l': font_info->name+="light"; break; case 'b': font_info->name+="bold"; break; case 'B': font_info->name+="black"; break; } if(style[1]=='i') font_info->name+="italic"; font_infos+=({ font_info });
c6fd2e2000-09-03Per Hedbor  } } }
b824672000-09-03Martin Nilsson  return font_infos;
c6fd2e2000-09-03Per Hedbor } string fix_name( string what ) { return replace( lower_case(what), " ", "_" ); } array has_font( string name, int size ) { string base_dir; array available; foreach(roxen->query("font_dirs"), string dir) { base_dir = dir+size+"/"+fix_name(name); if((available = r_get_dir(base_dir))) break; base_dir=dir+"/32/"+fix_name(name); available = r_get_dir(base_dir); } if(!available) return 0; return available - ({ "CVS" }); } Font open( string name, int size, int bold, int italic ) { string f = make_font_name( name, size, bold, italic ); Image.Font fn = Image.Font(); foreach( roxen->query( "font_dirs"), string dir ) foreach( ({ size, 32 }), int sz ) { if( r_file_stat( dir+"/"+sz+"/"+f ) ) { if( fn->load( roxen_path( dir+"/"+sz+"/"+f ) ) ) return fn; } } }