--- parser3/src/classes/image.C 2002/11/25 14:57:32 1.82 +++ parser3/src/classes/image.C 2002/11/28 12:23:39 1.87 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_IMAGE_C="$Date: 2002/11/25 14:57:32 $"; +static const char* IDENT_IMAGE_C="$Date: 2002/11/28 12:23:39 $"; /* jpegsize: gets the width and height (in pixels) of a jpeg file @@ -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)=0; x--) { - for(int y=0; y=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 ********************************** */ + 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){ const char *cstr=s.cstr(); int result=0; for(; *cstr; cstr++) - result+=index_width(index_of(*cstr)); + result+=step_width(index_of(*cstr)); return result; } @@ -951,7 +956,7 @@ public: if(cstr) for(; *cstr; cstr++) { int index=index_of(*cstr); index_display(image, x, y, index); - x+=letter_spacing + (monospace ? monospace : index_width(index)); + x+=step_width(index); } } @@ -976,6 +981,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,