Diff for /parser3/src/classes/image.C between versions 1.83 and 1.87

version 1.83, 2002/11/25 15:37:12 version 1.87, 2002/11/28 12:23:39
Line 891  static void _polybar(Request& r, const S Line 891  static void _polybar(Request& r, const S
   
 // font  // font
   
 #define Y(y)(y+index*height+1)  #define Y(y)(y+index*height)
   
 /// simple gdImage-based font storage & text output   /// simple gdImage-based font storage & text output 
 class Font : public Pooled {  class Font: public Pooled {
 public:  public:
                   
         const static int letter_spacing;          const static int letter_spacing;
Line 906  public: Line 906  public:
                   
         Font(Pool& pool,           Font(Pool& pool, 
                 const String& aalphabet,                   const String& aalphabet, 
                 gdImage& aifont, int aheight, int amonospace, int aspacebarspace) : Pooled(pool),                   gdImage& aifont, int aheight, int amonospace, int aspacebarspace): Pooled(pool), 
                 alphabet(aalphabet),                   alphabet(aalphabet), 
                 height(aheight), monospace(amonospace),  spacebarspace(aspacebarspace),                  height(aheight), monospace(amonospace),  spacebarspace(aspacebarspace),
                 ifont(aifont) {                  ifont(aifont) {
Line 924  public: Line 924  public:
                         return spacebarspace;                          return spacebarspace;
                 int tr=ifont.GetTransparent();                  int tr=ifont.GetTransparent();
                 for(int x=ifont.SX()-1; x>=0; x--) {                  for(int x=ifont.SX()-1; x>=0; x--) {
                         for(int y=0; y<height-1; y++)                          for(int y=0; y<height; y++)
                                 if(ifont.GetPixel(x, Y(y))!=tr)                                   if(ifont.GetPixel(x, Y(y))!=tr) 
                                         return x+1;                                          return x+1;
                 }                  }
Line 933  public: Line 933  public:
                   
         void index_display(gdImage& image, int x, int y, int index){          void index_display(gdImage& image, int x, int y, int index){
                 if(index>=0)                   if(index>=0) 
                         ifont.Copy(image, x, y, 0, Y(0), index_width(index), height-1);                          ifont.Copy(image, x, y, 0, Y(0), index_width(index), height);
         }          }
                   
         /* ******************************** string ********************************** */          /* ******************************** string ********************************** */
                   
           int step_width(int index) {
                   return letter_spacing + (monospace ? monospace : index_width(index));
           }
   
           // counts trailing letter_spacing, consider this OK. useful for contiuations
         int string_width(const String& s){          int string_width(const String& s){
                 const char *cstr=s.cstr();                  const char *cstr=s.cstr();
                 int result=0;                  int result=0;
                 for(; *cstr; cstr++)                  for(; *cstr; cstr++)
                         result+=index_width(index_of(*cstr));                          result+=step_width(index_of(*cstr));
                 return result;                  return result;
         }          }
                   
Line 951  public: Line 956  public:
                 if(cstr) for(; *cstr; cstr++) {                  if(cstr) for(; *cstr; cstr++) {
                         int index=index_of(*cstr);                          int index=index_of(*cstr);
                         index_display(image, x, y, index);                          index_display(image, x, y, index);
                         x+=letter_spacing + (monospace ? monospace : index_width(index));                          x+=step_width(index);
                 }                  }
         }          }
                   
Line 976  static void _font(Request& r, const Stri Line 981  static void _font(Request& r, const Stri
                 throw Exception("parser.runtime",                  throw Exception("parser.runtime",
                         &method_name,                          &method_name,
                         "alphabet must not be empty");                          "alphabet must not be empty");
   
           if(int remainder=image.SY() % alphabet.size())
                   throw Exception("parser.runtime",
                           &method_name,
                           "font-file height(%d) not divisable by alphabet size(%d), remainder=%d",
                                   image.SY(), alphabet.size(), remainder);
                   
         static_cast<VImage *>(r.get_self())->font=new(pool) Font(pool,           static_cast<VImage *>(r.get_self())->font=new(pool) Font(pool, 
                 alphabet,                   alphabet, 

Removed from v.1.83  
changed lines
  Added in v.1.87


E-mail: