Branch: Tag:

2000-09-04

2000-09-04 05:22:01 by Per Hedbor <ph@opera.com>

Handle space and nonbreakable space specially if nthe characters are not present in the font

Rev: server/font_handlers/imagedir.pike:1.2

1:   #include <config.h>   #include <stat.h> - constant cvs_version = "$Id: imagedir.pike,v 1.1 2000/09/04 05:09:13 per Exp $"; + constant cvs_version = "$Id: imagedir.pike,v 1.2 2000/09/04 05:22:01 per Exp $";      constant name = "Image directory fonts";   constant doc = ("Handles a directory with images (in almost any format), each "
9:      inherit FontHandler;    + static mapping nullchar = ([ "image":Image.Image(1,1), +  "alpha":Image.Image(1,1) ]); + static mapping spacechar = ([ "image":Image.Image(10,1), +  "alpha":Image.Image(10,1) ]); + static mapping smallspacechar = ([ "image":Image.Image(2,1), +  "alpha":Image.Image(2,1) ]);   class myFont   {    inherit Font;    static string path;    static int size, rsize; -  static mapping nullchar = ([ "image":Image.Image(1,1), -  "alpha":Image.Image(1,1) ]); +     static array files;      
33:       static mapping(string:Image.Image) load_char( string c )    { +  if( c[0] == 0x120 ) return smallspacechar;    if(!files)    files = get_dir( path ) - ({ "fontname" });   
40:    foreach( possible, string pf )    if( mapping r = Image._load( path+pf ) )    return r; +  if( c == " " ) return spacechar;    return nullchar;    }    mapping(string:mapping(string:Image.Image)) char_cache = ([]);