b824672000-09-03Martin Nilsson // This file is part of Roxen WebServer. // Copyright © 1996 - 2000, Roxen IS. #include <config.h>
0bd4d92000-09-04Per Hedbor constant cvs_version = "$Id: old.pike,v 1.6 2000/09/04 07:40:51 per Exp $";
c6fd2e2000-09-03Per Hedbor  constant name = "Compatibility bitmap fonts";
0bd4d92000-09-04Per Hedbor constant doc = "Compatibility (bitmapped) fonts for Roxen 1.3 and earlier." " Image tar-file fonts are preferable to this format, since they are " "usually smaller, and easier to create.";
c6fd2e2000-09-03Per Hedbor  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 {
a6bf1d2000-09-04Per Hedbor  string ofnt = fnt; fnt = replace(lower_case( fnt ), " ", "_");
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,
a6bf1d2000-09-04Per Hedbor  "family":ofnt,
b824672000-09-03Martin Nilsson  "path":dir+fnt,
a6bf1d2000-09-04Per Hedbor  "style":"",
b824672000-09-03Martin Nilsson  "format":"bitmap dump" ]); switch(style[0]) {
a6bf1d2000-09-04Per Hedbor  case 'l': font_info->style+="light"; break; case 'b': font_info->style+="bold"; break; case 'B': font_info->style+="black"; break;
b824672000-09-03Martin Nilsson  }
a6bf1d2000-09-04Per Hedbor  if(style[1]=='i') font_info->style+="italic"; if(style[1]=='I') font_info->style+="oblique";
b824672000-09-03Martin Nilsson  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; } } }