EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MonoFontMode question

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
mstaszew



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Mon Jul 02, 2007 1:41 pm    Post subject: MonoFontMode question Reply with quote

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
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Tue Jul 03, 2007 7:28 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Tue Jul 03, 2007 7:31 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mstaszew



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Mon Jul 09, 2007 9:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
mstaszew



Joined: 21 Jul 2006
Posts: 67
Location: North Carolina, USA

PostPosted: Mon Jul 09, 2007 9:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Thu Jul 12, 2007 7:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group