From b6bde2e4569aa617c8a6af64947c688c624ed7f8 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Wed, 10 Sep 2008 23:56:49 +0000 Subject: Merging the UTF8 patch, consisting of O'ksi'd s original 1.1.6 patch and additions by Ian. PLEASE BE AWARE that the patch in its current incarnation is a regression in many aspects and further work is required before we can announce Unicode support. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6212 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_draw.cxx | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/fl_draw.cxx') diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx index 216ec072a..0a1f55a97 100644 --- a/src/fl_draw.cxx +++ b/src/fl_draw.cxx @@ -33,6 +33,8 @@ // Aligns them against the inside of the box. #define min(a,b) ((a)<(b)?(a):(b)) +#include +#include #include #include @@ -53,11 +55,11 @@ static char* underline_at; // Sets n to the number of characters put into the buffer. // Sets width to the width of the string in the current font. -static const char* -expand(const char* from, char* buf, double maxw, int& n, double &width, - int wrap, int draw_symbols) { +const char* +fl_expand_text(const char* from, char* buf, int maxbuf, double maxw, int& n, + double &width, int wrap, int draw_symbols) { char* o = buf; - char* e = buf+(MAXBUF-4); + char* e = buf+(maxbuf-4); underline_at = 0; char* word_end = o; const char* word_start = from; @@ -88,7 +90,8 @@ expand(const char* from, char* buf, double maxw, int& n, double &width, if (o > e) break; // don't overflow buffer if (c == '\t') { - for (c = (o-buf)%8; c<8 && o1) e = expand(p, buf, w - symtotal, buflen, width, - align&FL_ALIGN_WRAP, draw_symbols); + if (lines>1) e = fl_expand_text(p, buf, MAXBUF, w - symtotal, buflen, + width, align&FL_ALIGN_WRAP, draw_symbols); else e = ""; if (width > symoffset) symoffset = (int)(width + 0.5); @@ -313,7 +318,9 @@ void fl_measure(const char* str, int& w, int& h, int draw_symbols) { symtotal = symwidth[0] + symwidth[1]; for (p = str, lines=0; p;) { - e = expand(p, buf, w - symtotal, buflen, width, w != 0, draw_symbols); +// e = expand(p, buf, w - symtotal, buflen, width, w != 0, draw_symbols); + e = fl_expand_text(p, buf, MAXBUF, w - symtotal, buflen, width, + w != 0, draw_symbols); if ((int)ceil(width) > W) W = (int)ceil(width); lines++; if (!*e || (*e == '@' && draw_symbols)) break; -- cgit v1.2.3