Skip to content

Commit

Permalink
Workaround SytleBuffer bug.
Browse files Browse the repository at this point in the history
https://github.com/jamescoxon/dl-fldigi/issues/22 and upstream:
 Invalid data breaking fl_height() and fl_width(). Rare but locally abundant.
  • Loading branch information
John Greb authored and John Greb committed Feb 20, 2014
1 parent d308fa7 commit 9520568
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/widgets/Fl_Text_Display_mod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,15 @@ void Fl_Text_Display_mod::resize(int X, int Y, int W, int H) {
text_area.y = Y+TOP_MARGIN;
text_area.w = W-LEFT_MARGIN-RIGHT_MARGIN;
text_area.h = H-TOP_MARGIN-BOTTOM_MARGIN;
#ifdef STYLEBUFFER_CORRUPT_FIX
int i;

/* Find the new maximum font height for this text display */
for (i = 0, mMaxsize = fl_height(textfont(), textsize()); i < mNStyles; i++)
mMaxsize = max(mMaxsize, fl_height(mStyleTable[i].font, mStyleTable[i].size));
#else
mMaxsize = fl_height(textfont(), textsize());
#endif

// did we have scrollbars initially?
unsigned int hscrollbarvisible = mHScrollBar->visible();
Expand Down Expand Up @@ -2190,7 +2194,8 @@ double Fl_Text_Display_mod::string_width( const char *string, int length, int st

Fl_Font font;
Fl_Fontsize fsize;


#ifdef STYLEBUFFER_CORRUPT_FIX
if ( mNStyles && (style & STYLE_LOOKUP_MASK) ) {
int si = (style & STYLE_LOOKUP_MASK) - 'A';
if (si < 0) si = 0;
Expand All @@ -2202,6 +2207,10 @@ double Fl_Text_Display_mod::string_width( const char *string, int length, int st
font = textfont();
fsize = textsize();
}
#else
font = textfont();
fsize = textsize();
#endif
fl_font( font, fsize );
return fl_width( string, length );
}
Expand Down

0 comments on commit 9520568

Please sign in to comment.