DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2076
Version: 1.3-feature


Attached should be the first cut at my proposed patch to implement an
"fl_text_extents" function in fltk-1.3.

This mechanism is analogous to the fl_measure function, but instead of
returning the typographical bounding box for a string of text, it tries to
return the minimal bounding box, fitted tightly round the glyphs as they
will be rendered on the screen.

The function is prototyped as follows:

void fl_text_extents(const char*, int& dx, int& dy, int& w, int& h);
void fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int&
h);

Usage is as follows; 

given a string "txt" drawn like this

    fl_draw(tst, x, y);

we measure it like this

    fl_text_extents(tst, dx, dy, wo, ho);

then the bounding box can be drawn

    fl_rect(x+dx, y+dy, wo, ho);

note the dx, dy values hold the offset of the glyphs from the draw origin.

The patch implements the function "correctly" for OSX, win32 and X+XFT.
There is a stub implemented for X+Xlib (based on fl_measure) as I do not
use that combination so have not yet got round to creating the proper
patch for it.

Also, the current text handling in the function DOES NOT do fltk symbol
expansion. I do not know whether that is something we want or not?
fl_measure does do symbol expansion, but fl_width does not. I saw this
function as being more like fl_width so did not attempt symbol expansion.
Perhaps that is a wrong decision?

Do we think this function is something we could add? I am using this
functionality a fair bit, it would be useful if it were officially built
in!

Comments, feedback, etc. welcome.
-- 
Ian


Link: http://www.fltk.org/str.php?L2076
Version: 1.3-feature
Attachment: http://www.fltk.org/strfiles/2076/te-patch.zip

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to