Greg Ercolano wrote:
> Ian, also added a few more extents tests mainly out of curiosity..
> I wanted to see what "`````", "-----", and "_____" looked like,
> as well as some separate text with descenders (gjpq).
>
> I basically made a subroutine out of the code that draws the text
> and boxes; maybe you can double check my work to make sure I didn't
> drop something out that was important.
>
> I've applied the above mods to the website copy at:
> http://seriss.com/people/erco/fltk/tmp/unittests-revised.cxx
Good work, Greg, thanks!
I suggest to draw the text _over_ the frames (last) in the text_extents
demo, because this way one can better see single pixels that overwrite
the frame.
In the attached patch I also changed BLUE to GREEN for better contrast,
but this seems to be a matter of taste (works well with Window's
magnifier, but maybe not as well without it) - better contrast with
text, but less with the white background. Please see yourself ...
Albrecht
$ diff -u unittests-revised_v2.cxx unittests-revised_v3.cxx
--- unittests-revised_v2.cxx 2009-02-13 13:10:40.799317800 +0100
+++ unittests-revised_v3.cxx 2009-02-13 13:15:44.381409800 +0100
@@ -313,9 +313,6 @@
class TextExtentsTest : public Fl_Widget
{
void DrawTextAndBoxes(const char *txt, int X, int Y) {
- // draw text
- fl_color(FL_BLACK);
- fl_draw(txt, X, Y);
int wo = 0, ho = 0;
int dx, dy;
// draw fl_measure() typographical bounding box
@@ -325,8 +322,11 @@
fl_rect(X, Y-ho+desc, wo, ho);
// draw fl_text_extents() glyph bounding box
fl_text_extents(txt, dx, dy, wo, ho);
- fl_color(FL_BLUE);
+ fl_color(FL_GREEN);
fl_rect(X+dx, Y+dy, wo, ho);
+ // draw text
+ fl_color(FL_BLACK);
+ fl_draw(txt, X, Y);
}
public: TextExtentsTest(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) {}
void draw(void) {
@@ -352,7 +352,7 @@
fl_font(FL_HELVETICA, 14);
fl_color(FL_RED); fl_draw("fl_measure bounding box in RED", xx,
yy); yy += 20;
- fl_color(FL_BLUE); fl_draw("fl_text_extents bounding box in BLUE", xx,
yy); yy += 20;
+ fl_color(FL_GREEN); fl_draw("fl_text_extents bounding box in GREEN", xx,
yy); yy += 20;
}
fl_pop_clip(); // remove the local clip
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev