Roxen.git / server / font_handlers / ttf.pike

version» Context lines:

Roxen.git/server/font_handlers/ttf.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2000, Roxen IS.      #if !constant(Image.FreeType.Face)   #if constant(has_Image_TTF)   #include <config.h> - constant cvs_version = "$Id: ttf.pike,v 1.14 2002/08/16 13:55:50 mattias Exp $"; + constant cvs_version = "$Id: ttf.pike,v 1.15 2003/05/05 14:31:08 jonasw Exp $";      constant name = "TTF fonts";   constant doc = "True Type font loader. Uses freetype to render text.";   constant scalable = 1;      inherit FontHandler;      static mapping ttf_font_names_cache;      static string trimttfname( string n )   {    n = lower_case(replace( n, "\t", " " ));    return ((n/" ")*"")-"'";   }      static string translate_ttf_style( string style )   { -  switch( lower_case( (style-"-")-" " ) ) -  { -  case "normal": case "regular": return "nn"; -  case "italic": return "ni"; -  case "oblique": return "ni"; -  case "bold": return "bn"; -  case "bolditalic":case "italicbold": return "bi"; -  case "black": return "Bn"; -  case "blackitalic":case "italicblack":return "Bi"; -  case "light": return "ln"; -  case "lightitalic":case "italiclight":return "li"; +  // Check for weight. Default is "n" for normal/regular/roman. +  style = lower_case((style - "-") - " "); +  string weight = "n"; +  if (has_value(style, "bold")) +  weight = "b"; +  else if (has_value(style, "black")) +  weight = "B"; +  else if (has_value(style, "light")) +  weight = "l"; +  +  // Check for slant. Default is "n" for regular. +  string slant = "n"; +  if (has_value(style, "italic") || +  has_value(style, "oblique")) +  slant = "i"; +  +  // Combine to full style +  return weight + slant;   } -  if(search(lower_case(style), "oblique")) -  return "ni"; // for now. -  return "nn"; - } +       static void build_font_names_cache( )   {    mapping ttf_done = ([ ]);    mapping new_ttf_font_names_cache=([]);    void traverse_font_dir( string dir )    {    foreach(r_get_dir( dir )||({}), string fname)    {    string path=combine_path(dir+"/",fname);