On 10.05.2011 14:00, MacArthur, Ian (SELEX GALILEO, UK) wrote:
P.S. When testing I found a strange effect: the first click on the
"rendering text" selection works as expected (the green and red box
are almost the same (w=105, h=30, the left red border is one pixel
left from the green border), but if I change to another display and
then back, then the red box is about 150 pixels wide. Maybe I did
something wrong in my test environment, or ... Could you take a
look at it? Please see attached file test1.diff.
Hmm, it seems to work OK for me - though I didn't try your mod to the
text_extents demo, as I already had a modified version of text_extents I
was using in my testing anyway.
I tested a little more with the latest svn version and with my standard
MinGW setup, and the effect seems to be the same. See attached modified
test program (test2.diff). The effect can also be seen when resizing
the window, so it is there as soon as that particular box is measured
a 2nd time, but it does not happen to the same output in the line
below. If I move setting the font with "fl_font(FL_FREE_FONT, 30);"
one line up (before "low small glyphs"), then all is normal. This
must be some initialization or similar problem, but I don't see it in
the test environment, so it is maybe in the measure function?
Need to go to a meeting - will try and get back to this later...
Okay, I'll be offline for the next hours, too, but I'm curious what
you may find. Thanks.
Albrecht
P.S. This is what I get as output from the test program for the
initial draw() and one redraw() - after that it's all the same with
the wrong size (maybe the UTF-8 glyphs are mangled, but you can see
what I mean ("wo=155").
Musica font set ...
fl_measure: text = '!abcdeABCDE"#A', wo=240, ho=35
fl_measure: text = 'oacs', wo=62, ho=35
fl_measure: text = 'qjgIPT', wo=87, ho=35
fl_measure: text = '````````', wo=80, ho=35
fl_measure: text = '--------', wo=80, ho=35
fl_measure: text = '________', wo=136, ho=35
fl_measure: text = 'ð ð¡ ð¢ ð£ ð¤', wo=105, ho=30
fl_measure: text = 'ð ð¡ ð¢ ð£ ð¤', wo=105, ho=30
fl_measure: text = '!abcdeABCDE"#A', wo=240, ho=35
fl_measure: text = 'oacs', wo=62, ho=35
fl_measure: text = 'qjgIPT', wo=87, ho=35
fl_measure: text = '````````', wo=80, ho=35
fl_measure: text = '--------', wo=80, ho=35
fl_measure: text = '________', wo=136, ho=35
fl_measure: text = 'ð ð¡ ð¢ ð£ ð¤', wo=155, ho=30
fl_measure: text = 'ð ð¡ ð¢ ð£ ð¤', wo=105, ho=30
Index: test/unittest_text.cxx
===================================================================
--- test/unittest_text.cxx (Revision 8643)
+++ test/unittest_text.cxx (Arbeitskopie)
@@ -31,6 +31,9 @@
//
// --- fl_text_extents() tests -----------------------------------------------
//
+
+static const char *musica = "\xf0\x9d\x85\xa0 \xf0\x9d\x85\xa1
\xf0\x9d\x85\xa2 \xf0\x9d\x85\xa3 \xf0\x9d\x85\xa4";
+
class TextExtentsTest : public Fl_Widget
{
void DrawTextAndBoxes(const char *txt, int X, int Y) {
@@ -39,6 +42,7 @@
// First, we draw the bounding boxes (fl_measure and fl_text_extents)
// draw fl_measure() typographical bounding box
fl_measure(txt, wo, ho, 0);
+ printf ("fl_measure: text = '%s', wo=%d, ho=%d\n",txt,wo,ho);
fflush(stdout);
int desc = fl_descent();
fl_color(FL_RED);
fl_rect(X, Y-ho+desc, wo, ho);
@@ -54,8 +58,12 @@
static Fl_Widget *create() {
return new TextExtentsTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H);
}
- TextExtentsTest(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) {}
+ TextExtentsTest(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) {
+ Fl::set_font(FL_FREE_FONT, " Musica");
+ printf("Musica font set ...\n"); fflush(stdout);
+ }
void draw(void) {
+
int x0 = x(); // origin is current window position for Fl_Box
int y0 = y();
int w0 = w();
@@ -66,6 +74,7 @@
fl_color(fl_gray_ramp(FL_NUM_GRAY - 3));
fl_rectf(x0, y0, w0, h0);
+ printf("\n");
fl_font(FL_HELVETICA, 30);
int xx = x0+55;
int yy = y0+40;
@@ -75,6 +84,9 @@
DrawTextAndBoxes("````````", xx, yy); yy += 50; // high small
glyphs
DrawTextAndBoxes("--------", xx, yy); yy += 50; // mid small
glyphs
DrawTextAndBoxes("________", xx, yy); yy += 50; // low small
glyphs
+ fl_font(FL_FREE_FONT, 30); // Musica
+ DrawTextAndBoxes(musica, xx, yy); yy += 50; // Musica font
+ DrawTextAndBoxes(musica, xx, yy); yy += 50; // Musica font
fl_font(FL_HELVETICA, 14);
fl_color(FL_RED); fl_draw("fl_measure bounding box in RED", xx,
yy); yy += 20;
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev