[Lazarus] IDE editor BUG

Martin lazarus at mfriebe.de
Thu Oct 10 12:59:16 CEST 2013


On 10/10/2013 10:50, FreeMan wrote:
> Maybe this two screenshot give more info, copy and paste from 
> clipbord. same selected text. blackbackgroud in lazarus IDE, other one 
> in "Kate" text editor. 'I.' is okey on kate just font proble and dot 
> is small.
> Just look carefully to this string part  " ....', PChar...." before 
> comma space is different. My idea is unicode function problem in 
> synedit, or string ansisting problem
I already can tell what is happening.
Compare the width of the upper "i" with the width of the "2" below. It 
is not the same.

SynEdit is a monospace ONLY editor. It only works with monospaced fonts. 
(Some exceptions, see below)

SynEdit assumes that the "I" has the same width as every other char. So 
it assumes that the "S" behind the "I" is exactly above the ")" below.
You will note that the caret moves into the middle of the "S"

SynEdit makes one call to the OS TextOut function for all chars with the 
same color. And if the OS does not paint the chars at the pos that a 
strictly monospaced font would dictate, then SynEdit does not know. But 
SynEdit will behave as if the OS did.

The "," has a diff color. SynEdit makes a new TextOut call to the x-pos 
where it should be. That is why there is a gap.
Text selection changes color, so the gap starts moving around.

If you can not change the font, you can set "Extra Char Spacing"  in the 
editor options to 1 or -1 (or any none zero value). Then SynEdit will 
paint each char on its own (for internal reasons that does mess up 
script languages like Arab, except on windows)

SynEdit detects none monospaced fonts if Latin letters (i,w,m,@) do not 
have the same width.
It only test Latin letters as they are present in most fonts.

If SynEdit would include upper dotted i in that test, it would fix your 
problem. But it would have side effects for people who use such a font, 
but only use English alphabet. (In which case the font is ok).

Same for testing any other none English char. There would always be side 
effects between different languages (Arab to affect Chinese, or Turkish 
or English or vice versa...)


You can edit "TextDrawer" in SynEdit

line 735

>
>   //if OverHang >0 then debugln(['SynTextDrawer: Overhang=', OverHang]);;
>   FontData^.CharAdv := Width;
>   FontData^.CharHeight := Height;
>   FontData^.NeedETO := ETO;
> end;

change
   FontData^.NeedETO := ETO;
to
   FontData^.NeedETO := True;

It will use more CPU / be slower. It will mess up Arab (except on Win)

In the end: Your font is not monospaced. SynEdit only works with 
monospaced fonts


>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131010/34036267/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 11330 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131010/34036267/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 7641 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131010/34036267/attachment-0007.png>


More information about the Lazarus mailing list