[Lazarus] GetTextExtent on Windows

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Sep 12 14:12:32 CEST 2015


I use "LCLIntf.DrawText" for drawing text on the screen and "Canvas.TextWidth"
to determine its width to increment a TRect for the next text output.
But these functions cause some trouble with drawing (UTF-8-) text on Windows.
In general it works okay but sometimes peculiar clipping or other pixel differences occur.
Are the functions above the correct ones to draw and measure text?

After looking a bit at the code I saw that in the file "intfbasewinapi.inc" almost
everywhere the Windows API function "GetTextExtentPoint" is used to determine text metrics.
But
https://msdn.microsoft.com/en-us/library/windows/desktop/dd144937%28v=vs.85%29.aspx
says:
"This function is provided only for compatibility with 16-bit versions of Windows.
Applications should call the *GetTextExtentPoint32* <https://msdn.microsoft.com/en-us/library/windows/desktop/dd144938%28v=vs.85%29.aspx> function, which provides more accurate results."

I think many of my problems come from using this deprecated API function.
Are there any plans to change this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150912/a307f86b/attachment-0002.html>


More information about the Lazarus mailing list