diff options
| author | Greg Ercolano <erco@seriss.com> | 2009-08-28 20:14:41 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2009-08-28 20:14:41 +0000 |
| commit | 41cef82137b76855cfc02f0d4c6d68162de691da (patch) | |
| tree | a7ca4508c1ae27926feb0cd42cbdd73a6928f5f5 | |
| parent | 2cf1337c44337e54edc58190b83a76277853eb37 (diff) | |
Applied patch from STR#2115.
This fix to fl_height(int,int) solves the "digital drit"
problem in Fl_Text_Editor, where doing insert/delete
operations was leaving a trail of dead pixels.
Also fixes problem with font display problem in fluid's
code editor. See the STR for screenshots of the problem.
NOTE: THIS IS A WORKAROUND FOR A DEEPER PROBLEM.
Somewhere during the port of UTF8, the actual pixel size
of the displayed font is a little off, causing FLTK to
miscalculate line height, causing 'digital drit'.
It used to be that when you specified a font size,
the font's actual displayed pixel size matched the
font size value.
This fix makes the fl_height(int,int) function more robust,
actually inquiring the font system for its font size, instead
of assuming the font size is the same as the 'size' argument.
Since Fl_Text_Editor makes use of this function, it helps
that widget calculate font sizes correctly.
The real fix will be restoring FLTK's old behavior where the
font size specified is the actual pixel size of the displayed font.
Then this function can be reverted to just returning the 'size' argument.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6845 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/fl_draw.H | 9 | ||||
| -rw-r--r-- | src/fl_draw.cxx | 25 |
2 files changed, 26 insertions, 8 deletions
diff --git a/FL/fl_draw.H b/FL/fl_draw.H index f10bcaa7c..ea2d315fb 100644 --- a/FL/fl_draw.H +++ b/FL/fl_draw.H @@ -203,14 +203,7 @@ inline Fl_Fontsize fl_size() {return fl_size_;} You can also use the value of \p size passed to fl_font() */ FL_EXPORT int fl_height(); // using "size" should work ok -/** - Dummy passthru function called only in Fl_Text_Display that simply returns - the font height as given by the \p size parameter in the same call! - - \todo Is fl_height(int, int size) required for Fl_Text_Dispay? - Why not use \p size parameter directly? -*/ -inline int fl_height(int, int size) {return size;} +FL_EXPORT int fl_height(int font, int size); /** Returns the recommended distance above the bottom of a fl_height() tall box to draw the text at so it looks centered vertically in that box. diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx index 061b50e77..65f554f6b 100644 --- a/src/fl_draw.cxx +++ b/src/fl_draw.cxx @@ -422,6 +422,31 @@ void fl_measure(const char* str, int& w, int& h, int draw_symbols) { h = lines*h; } +/** + This function returns the actual height of the specified \p font + and \p size. Normally the font height should always be 'size', + but with the advent of XFT, there are (currently) complexities + that seem to only be solved by asking the font what its actual + font height is. (See STR#2115) + + This function was originally undocumented in 1.1.x, and was used + only by Fl_Text_Display. We're now documenting it in 1.3.x so that + apps that need precise height info can get it with this function. + + \returns the height of the font in pixels. + + \todo In the future, when the XFT issues are resolved, this function + should simply return the 'size' value. +*/ +int fl_height(int font, int size) { + if ( font == fl_font() && size == fl_size() ) return(fl_height()); + int tf = fl_font(), ts = fl_size(); // save + fl_font(font,size); + int height = fl_height(); + fl_font(tf,ts); // restore + return(height); +} + // // End of "$Id$". // |
