--- parser3/src/classes/image.C 2002/11/22 16:16:33 1.80 +++ parser3/src/classes/image.C 2002/11/28 08:38:14 1.85 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_IMAGE_C="$Date: 2002/11/22 16:16:33 $"; +static const char* IDENT_IMAGE_C="$Date: 2002/11/28 08:38:14 $"; /* jpegsize: gets the width and height (in pixels) of a jpeg file @@ -78,7 +78,7 @@ public: value, whence, strerror(errno), errno, fname); } - /*override*/long tell() { return ::tell(f); } + /*override*/long tell() { return lseek(f, 0, SEEK_CUR); } private: Pool& pool; @@ -212,7 +212,7 @@ inline uint endian_to_uint(bool is_big, static void measure_gif(Pool& pool, const String *origin_string, Measure_reader& reader, ushort& width, ushort& height) { - void *buf; + const void *buf; const int head_size=sizeof(GIF_Header); if(reader.read(buf, head_size)get(0), /*0/*no name* /,*/ false/*don't intercept string*/); - if(vattribs.is_defined()) // allow 'void' + if(!vattribs.is_string()) // allow empty if(attribs=vattribs.get_hash(&method_name)) { Attrib_info attrib_info={&tag, 0}; attribs->for_each(append_attrib_pair, &attrib_info); @@ -891,10 +891,10 @@ static void _polybar(Request& r, const S // font -#define Y(y)(y+index*height+1) +#define Y(y)(y+index*height) /// simple gdImage-based font storage & text output -class Font : public Pooled { +class Font: public Pooled { public: const static int letter_spacing; @@ -906,7 +906,7 @@ public: Font(Pool& pool, 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), height(aheight), monospace(amonospace), spacebarspace(aspacebarspace), ifont(aifont) { @@ -933,7 +933,7 @@ public: void index_display(gdImage& image, int x, int y, int index){ 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 ********************************** */ @@ -976,6 +976,12 @@ static void _font(Request& r, const Stri throw Exception("parser.runtime", &method_name, "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(r.get_self())->font=new(pool) Font(pool, alphabet,