On 10.05.2011 11:20, MacArthur, Ian (SELEX GALILEO, UK) wrote:
<OT here in fltk.general>
To Ian: it's your code, and it compiles well with the /broken/ MinGW
wingdi.h, but not with Visual C++ (STR #2623) and the
corrected mingw64
header files. If you have a better idea than an autoconf
"feature" test,
please give a comment on STR #2622. Thanks.
</OT>
I've noted this on the STR now, but...
If I understand the STR, the problem is that the lpClass member of the
GCP_RESULTSW struct is given inconsistent type depending on which header
we get?
Correct.
And I wrote my code to match the headers I have - and the headers I have
are wrong...
Yep.
So... We don't need the lpClass data at all (we don't use it) but I
initially thought we had to provide it anyway.
It now *appears* that we can set that to NULL if we are not using it,
and that might appease all the different compiler versions.
Yes, I noticed that it wasn't used at all, but I didn't know whether
it could be set to NULL or not. I looked at my (VS 2008/2010) docs, and
I didn't find an explicit statement about it, but ... there is one small
side note in the docs for GetCharacterPlacement() at
http://msdn.microsoft.com/en-us/library/dd144860%28v=vs.85%29.aspx
in the paragraph on GCP_REORDER: "If this flag is set for Semitic
languages and the lpClass array is used, ..."
Note: "and the lpClass array is used". Does this mean that it can
be set to NULL?
Can others test this? It works just fine for me, but then it worked
before too...
Here's the "patch" as I have it so far. In fl_font_win32.cxx @ line 345;
gcp_res.lpClass = NULL;//c_buff; -- here's the "fix"
gcp_res.lpGlyphs = (LPWSTR)w_buff;
gcp_res.nGlyphs = wc_len;
gcp_res.lStructSize = sizeof(gcp_res);
I've tested this in my surrogate-pairs test and it seems to run fine,
and I'm not seeing any other side effects.
We need more opinions though!
I tested it now with the Cygwin/mingw64 cross compiler ;-) that has the
correct header, and the patch fixed the compiler error, as expected.
But testing was a little more effort: I had to load the Musica font and
change unittest_text.cxx to use a text with surrogate pairs, and then
it seems to work (I also checked that GetCharacterPlacement() was called
and returned plausible values), hence I can say now that it seems to
work for me too on Windows 7.
If this works, then we can strip out any references to c_buff, as it is
no longer used at all...
Any good?
Yep, that would be wonderful!
Does this work in all cases?
Who knows? I suggest that we try it and wait ...
Albrecht
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.
Index: src/fl_font_win32.cxx
===================================================================
--- src/fl_font_win32.cxx (revision 8642)
+++ src/fl_font_win32.cxx (working copy)
@@ -342,12 +342,13 @@
memset(c_buff, 0, (sizeof(WCHAR) * wc_len));
memset(w_buff, 0, (sizeof(WORD) * wc_len));
memset(&gcp_res, 0, sizeof(GCP_RESULTSW));
- gcp_res.lpClass = c_buff;
+ gcp_res.lpClass = NULL; // c_buff;
gcp_res.lpGlyphs = (LPWSTR)w_buff;
gcp_res.nGlyphs = wc_len;
gcp_res.lStructSize = sizeof(gcp_res);
DWORD dr = GetCharacterPlacementW(gc, (WCHAR*)ext_buff, len, 0, &gcp_res,
GCP_GLYPHSHAPE);
+ printf ("GetCharacterPlacementW() returned %ld
(%d,%d)\n",dr,dr>>16&0xFFFF,dr&0xFFFF); fflush(stdout);
if(dr) {
len = gcp_res.nGlyphs;
} else goto exit_error;
Index: test/unittest_text.cxx
===================================================================
--- test/unittest_text.cxx (revision 8642)
+++ test/unittest_text.cxx (working copy)
@@ -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) {
@@ -54,8 +57,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();
@@ -74,7 +81,9 @@
DrawTextAndBoxes("qjgIPT", xx, yy); yy += 50; xx -= 100; //
glyphs with descenders
DrawTextAndBoxes("````````", xx, yy); yy += 50; // high small
glyphs
DrawTextAndBoxes("--------", xx, yy); yy += 50; // mid small
glyphs
- DrawTextAndBoxes("________", xx, yy); yy += 50; // low 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
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