2b165b2001-09-26Martin Nilsson // This file is part of Roxen WebServer.
b655bf2004-06-30Martin Stjernholm // Copyright © 2000 - 2004, Roxen IS.
2b165b2001-09-26Martin Nilsson 
6a78452000-09-04Per Hedbor #include <config.h>
2078852000-12-11Per Hedbor #if constant(Image.FreeType.Face) inherit "freetype"; #else
6d8c522000-09-19Per Hedbor inherit "ttf";
2078852000-12-11Per Hedbor #endif
0d98a72004-08-31Henrik Grubbström (Grubba) constant cvs_version = "$Id: builtin.pike,v 1.15 2004/08/31 09:14:34 grubba Exp $";
6a78452000-09-04Per Hedbor  constant name = "Builtin fonts"; constant doc = "Fonts included in pike (and roxen)"; inherit FontHandler; array available_fonts() { return ({ "pike builtin", "roxen builtin" }); } array(mapping) font_information( string fnt ) { switch( replace(lower_case(fnt)," ","_")-"_" ) {
6d8c522000-09-19Per Hedbor  case "roxenbuiltin":
de21522000-09-27Per Hedbor #if constant(__rbf) && constant(grbf)
6a78452000-09-04Per Hedbor  return ({ ([
6d8c522000-09-19Per Hedbor  "name":"roxen builtin", "family":"Roxen builtin font",
6a78452000-09-04Per Hedbor  "path":"-", "style":"normal",
6d8c522000-09-19Per Hedbor  "format":"scalable vector font",
6a78452000-09-04Per Hedbor  ]) });
6d8c522000-09-19Per Hedbor #endif case "pikebuiltin":
6a78452000-09-04Per Hedbor  return ({ ([
6d8c522000-09-19Per Hedbor  "name":"pike builtin", "family":"Pike builtin font",
6a78452000-09-04Per Hedbor  "path":"-", "style":"normal",
6d8c522000-09-19Per Hedbor  "format":"bitmap dump",
6a78452000-09-04Per Hedbor  ]) }); } } array has_font( string name, int size ) { switch( replace(lower_case(name)," ","_")-"_" ) { case "pikebuiltin": return ({ "nn" });
3f3ccd2001-08-21Per Hedbor  case "roxenbuiltin": return ({ "nn", "bn", "bi" });
6a78452000-09-04Per Hedbor  } return 0; }
6d8c522000-09-19Per Hedbor object roxenbuiltin; #ifdef THREADS Thread.Mutex lock = Thread.Mutex(); #endif
6a78452000-09-04Per Hedbor  Font open( string name, int size, int bold, int italic ) { switch( replace(lower_case(name)," ","_")-"_" ) {
6d8c522000-09-19Per Hedbor  case "roxenbuiltin":
0d98a72004-08-31Henrik Grubbström (Grubba)  Configuration conf = roxen->current_configuration->get(); License.Key key = conf && conf->getvar("license")->get_key(); if (key && key->type() == "personal") return Image.Font();
2078852000-12-11Per Hedbor #if constant(__rbf) && constant(grbf)
d2d4bf2001-02-01Per Hedbor #ifdef THREADS
34659f2000-12-11Per Hedbor  object key = lock->lock();
d2d4bf2001-02-01Per Hedbor #endif
d094f72001-09-03Per Hedbor  if( !roxenbuiltin ) if( mixed err = catch(roxenbuiltin = grbf()) )
632f512001-09-03Per Hedbor #ifdef DEBUG
d094f72001-09-03Per Hedbor  werror("Failed to open builtin font: %s\n", describe_backtrace( err ) );
632f512001-09-03Per Hedbor #else ; #endif
b5a1a72001-08-21Per Hedbor  if( roxenbuiltin ) #if constant(Image.FreeType.Face) return FTFont( roxenbuiltin, size,"-", bold, italic );
2078852000-12-11Per Hedbor #else
b5a1a72001-08-21Per Hedbor  return TTFWrapper( roxenbuiltin(), size, "-", bold, italic);
2078852000-12-11Per Hedbor #endif
6d8c522000-09-19Per Hedbor #endif
6a78452000-09-04Per Hedbor  case "pikebuiltin": return Image.Font(); } }