View previous topic :: View next topic |
Author |
Message |
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Mon Jul 02, 2007 1:41 pm Post subject: MonoFontMode question |
|
|
In looking at Mantis issue #153, I decided to try the code change...
TSyntaxMemo.MonoFontMode := mfVariable;
...in our editor an voila! it seems to resolve an issue that we have had. If the font is courier and style is italicized then the last half of the last character is cut off. MonoFontMode := mfVariable corrects this.
So here's the question. Is there any reason why we would not want to use mfVariable as the MonoFontMode? Are there any problems with this setting for certain fonts or is it safe to use with all fonts?
Thanks. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Tue Jul 03, 2007 7:28 am Post subject: |
|
|
I've tested with mfVariable and "Courier" font, but cutting still present.
There was no difference between mfFixed and mfVariable modes.
The problem is in small forward painting (there was only 3 pixels).
After I changed it on 6 pixels, drawing of italic Courier text is OK.
Fix (ecSyntMemo.pas):
Code: | function TCustomSyntaxMemo.ProcessLine(Canvas: TCanvas; LineInfo: TLineInfo;
.....
procedure FillRectEx(Rect: TRect);
begin
if IsPrint and (Canvas.Brush.Color = clWhite) then Exit;
if sv_bg_color = Canvas.Brush.Color then
begin
Rect.Left := Rect.Left + 6; // <==
if Rect.Left > Rect.Right then Exit;
end;
Canvas.FillRect(Rect);
sv_bg_color := clNone;
end;
.....
procedure DrawElem;
.....
if Length(S) > 0 then
begin
// + Uncommented in v 2.32
if (S[Length(S)] <> ' ') and not IsPrint and
((k + ElemLen >= Sl - 1) or (GetChar(k + ElemLen + 1) = ' ')) then
begin
sv_bg_color := Canvas.Brush.Color;
Canvas.FillRect(Rect(X + ElemSize.cx + w, Y, X + ElemSize.cx + w + 6, BaseLine)); // <==
end;
// - Uncommented in v 2.32 |
I.e. 3 is replaced with 6.
Michael. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Tue Jul 03, 2007 7:31 am Post subject: |
|
|
P.S. This problem is specific for this font "Courier"
For italic font TextExtent gives the same size as for normal font, but displayed string occupies more space.
Michael. |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Mon Jul 09, 2007 9:15 pm Post subject: |
|
|
There is still an issue with this. If I set the font to Arial, load a file (make sure it has quite a few lines so that you can see the issue better), then set the font to Courier there are "holes" in the editor. It almost seems like a painting issue. Sometimes I do not see the holes, but I can always get them to appear if I go to the Windows desktop and then back to the application. At this point there are visible holes. If you need more information or some screenshots the let me know.
Thanks. |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Mon Jul 09, 2007 9:23 pm Post subject: |
|
|
Actually my steps are a bit misleading. You don't need to do all of the font switching. Simply set font to Arial, go to windows desktop, go back to application. You should see holes. If not, select all text and they should stand out more. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Thu Jul 12, 2007 7:33 pm Post subject: |
|
|
Fix (ecSyntMemo.pas):
Code: | function TCustomSyntaxMemo.ProcessLine(Canvas: TCanvas; LineInfo: TLineInfo;
.....
procedure FillRectEx(Rect: TRect);
begin
if IsPrint and (Canvas.Brush.Color = clWhite) then Exit;
if sv_bg_color = Canvas.Brush.Color then
begin
Rect.Left := Rect.Left + 6;
if Rect.Left > Rect.Right then
begin
sv_bg_color := clNone;
Exit;
end;
end;
Canvas.FillRect(Rect);
sv_bg_color := clNone;
end; |
|
|
Back to top |
|
|
|