
using HGL, I notice that there does not appear to be a way to get at the rendered size of text strings. this makes it very difficult to work with text in any meaningful way. although perhaps i am missing something. John -- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@foo.net ---------------------------------------------------------------------------

On Tuesday 08 July 2003 1:30 am, John Meacham wrote:
using HGL, I notice that there does not appear to be a way to get at the rendered size of text strings. this makes it very difficult to work with text in any meaningful way. although perhaps i am missing something.
The module Graphics.HGL.X11.Picture exports this function: -- textInfo s returns: -- -- 1) The offset at which the string would be drawn according to the -- current text alignment (e.g., (Center, Baseline) will result in -- an offset of (-width/2,0)) -- -- 2) The size at which the text would be drawn using the current font. -- textInfo :: String -> Draw ((Point,Size)) This is not yet available on Win32 and, due to an oversight, was not exported from Graphics.HGL.X11 or Graphics.HGL. I'll fix that in the next release. -- Alastair

there also seems to be a bug in it's implementation causing the size result to diverge. changing the lines: x2 = x2 + width y2 = y2 + ascent + descent to x2 = x1 + width y2 = y1 + ascent + descent seems to fix it. I also see various ways the X11 version could be improved, helping efficiency when double buffering, and improving compliance with modern window manager protocols. where should patches be sent? I have write access to the repository but wouldn't want to step on someones toes if sending patches to the list is more appropriate. John On Tue, Jul 08, 2003 at 10:38:40AM +0100, Alastair Reid wrote:
On Tuesday 08 July 2003 1:30 am, John Meacham wrote:
using HGL, I notice that there does not appear to be a way to get at the rendered size of text strings. this makes it very difficult to work with text in any meaningful way. although perhaps i am missing something.
The module Graphics.HGL.X11.Picture exports this function:
-- textInfo s returns: -- -- 1) The offset at which the string would be drawn according to the -- current text alignment (e.g., (Center, Baseline) will result in -- an offset of (-width/2,0)) -- -- 2) The size at which the text would be drawn using the current font. -- textInfo :: String -> Draw ((Point,Size))
This is not yet available on Win32 and, due to an oversight, was not exported from Graphics.HGL.X11 or Graphics.HGL. I'll fix that in the next release.
-- Alastair
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@foo.net ---------------------------------------------------------------------------

On Tuesday 08 July 2003 11:09 am, John Meacham wrote:
there also seems to be a bug in it's implementation causing the size result to diverge. changing the lines:
I was sure I'd tested the code and that I'd received a thank you for adding it... But with a bug like that, I must have hallucinated both... Thanks for spotting it!
I also see various ways the X11 version could be improved, helping efficiency when double buffering, and improving compliance with modern window manager protocols. where should patches be sent? I have write access to the repository but wouldn't want to step on someones toes if sending patches to the list is more appropriate.
Commit away. Can you mention in the commit messages any changes that may need to be carried over to the Win32 version? -- Alastair
participants (2)
-
Alastair Reid
-
John Meacham