Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Syntax Edit
  New Posts New Posts RSS Feed - Edges of characters missing at color boundaries
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Edges of characters missing at color boundaries

 Post Reply Post Reply
Author
Message
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Topic: Edges of characters missing at color boundaries
    Posted: 11 June 2009 at 3:43am
I've just noticed this with 13.1 beta, but it also happens with 13.0.
 
At the boundary between two differently colored regions of syntax, for some wide characters such as "w" the edge of the character is clipped.
 
For example:
 
 
Look at the right edge of the "w"
 
To show how this SHOULD appear, see the same file in the Visual Studio editor:
 
 
The comparison also shows that your color definitions are not quite the same as the visual studio defaults, which would be nice to fix, but is not a major issue
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 15 June 2009 at 6:48pm
Can't cofirm - at least with existed syntax - color scheme (Top - SyntaxEdit, Bottom - VS2008. If you zoom snapshot you will find that "w" symmetric in both cases - no droped pixels
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 15 June 2009 at 7:38pm
Try turning ClearType back on... your screen images suggest that you are not using this.
 
No ClearType: images display as you suggest
 
ClearType: clipping error
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 15 June 2009 at 8:25pm
I did not turn off Clear Type because I never turned it on - looks like this is not part of default setup.
Consider also that I attached jpg snapshots - not bmp!
 
But you are right - with ClearType it is different ("w" cutted from right side!)
The question - how to deal with it?
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2009 at 2:48am
I don't know the code well enough, but it must be a question of clipping boundaries. Perhaps check the  ExtTextOut calls in XTPSyntaxEditDrawTextProcessor.cpp, which use ETO_CLIPPED. Presumably you are being too strict about the clipping rectangle by a pixel?
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2009 at 4:23am
To determine the exact width of a string is extremely hard. You cannot rely on the GetTextExtentPoint32 API. It's not exact. Same goes for GDI+ equivalence. I sense ExtTextOut could suffer from the same...
PokerMemento - http://www.pokermemento.com/
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2009 at 11:46am

Sure - see:

pDC->ExtTextOut(nX, nY, ETO_CLIPPED, &rcText,

pcszText, nTextLen, NULL);

//--------------------------------------------------------

if (m_arBuf_aDx.GetSize() < nTextLen)

m_arBuf_aDx.SetSize(nTextLen + 100);

int nMaxExtent = m_rcTextRect.Width() + m_nScrollXOffset - m_nNextRowPosX + 30; // 30 is a gap to be sure

nMaxExtent = max(nMaxExtent, 30);

int nFit = 0;

LPINT alpDx = (int*)m_arBuf_aDx.GetData();

CSize szText(0, 0);

BOOL bResExt = GetTextExtentExPoint(pDC->m_hAttribDC, pcszText, nTextLen,

0, // nMaxExtent,

NULL, // &nFit,

alpDx, // array of partial string widths

&szText // string dimensions

);

nFit = nTextLen;

btw - ClearType is approximation method and it is not ideal for all cases - only as average
You can use ClearType but select in advance options Usual (non ClearType) font smoothing mode - after all works fine
 
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2009 at 4:27pm
Are you intending to incorporate this into 13.1.1....?
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2009 at 12:31pm
I don't understand that to incorporate? Advance options is part of ClearType ControlPanel Wizard
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2009 at 1:43pm
Errr no... I wondered whether anything could be done to prevent the display problem.
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 26 June 2009 at 2:55am

In the past I've played a lot with text measuring. So far, the only 100% working solution, I've seen, is to blit the text to a white bitmap and scan for non-white pixels from the right.

PokerMemento - http://www.pokermemento.com/
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2009 at 4:46pm
I've found a way to fix this and produce much cleaner looking output. Unfortunately it requires a slight modification to CXTPSyntaxEditDrawTextProcessor::DrawRowPart (and probably CXTPSyntaxEditDrawTextProcessor::PrintRowPart) in XTPSyntaxEditDrawTextProcessor.cpp

The problem arises because each successive ExtTextOut call seems to overwrite part of the previous one. To prevent this, the clipping rectangle needs to be set to disallow the overwriting. This can be fixed with a single line of code!!!
 

CRect rcText = m_rcTextRect;

rcText.left = nX; // ADD THIS LINE TO ENSURE THE TEXT IS CLIPPED APPROPRIATELY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

pDC->ExtTextOut(nX, nY, ETO_CLIPPED, &rcText, pcszText, nTextLen, NULL);

 
Note to Mark Doubson: Could you incorporate this change into DrawRowPart and PrintRowPart for the next release?
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2009 at 4:50pm
See results on XP with ClearType ON - I updated SVN. Thanks
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2009 at 4:53pm

Thanks!

Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2009 at 5:11pm
Done
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 27 August 2009 at 7:25pm
Oops... I've just discovered that the "fix" I suggested introduces a problem if the control scrolls to the right.
 
The correct correction is as below:
rcText.left = max(rcText.left, nX); // MODIFIED!!!
Sorry about that... can you update this again
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 27 August 2009 at 7:50pm
OK, done
Back to Top
robin_l View Drop Down
Senior Member
Senior Member


Joined: 15 October 2006
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote robin_l Quote  Post ReplyReply Direct Link To This Post Posted: 27 August 2009 at 7:52pm
Thanks! I'll try not to have to change it again
Product: Xtreme ToolkitPro 2009 (13.4.1)
Platform: Windows 7 Ultimate(64bit)
Language: Visual Studio 2010 (C++)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.297 seconds.