Print Page | Close Window

Edges of characters missing at color boundaries

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Syntax Edit
Forum Description: Topics Related to Codejock Syntax Edit
URL: http://forum.codejock.com/forum_posts.asp?TID=14500
Printed Date: 11 December 2024 at 6:40pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Edges of characters missing at color boundaries
Posted By: robin_l
Subject: Edges of characters missing at color boundaries
Date 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++)



Replies:
Posted By: mdoubson
Date 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


-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)


Posted By: mdoubson
Date 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?


-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)


Posted By: znakeeye
Date 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/


Posted By: mdoubson
Date 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
 


-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)


Posted By: mdoubson
Date Posted: 19 June 2009 at 12:31pm
I don't understand that to incorporate? Advance options is part of ClearType ControlPanel Wizard

-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)


Posted By: znakeeye
Date 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.

http://www.codeproject.com/KB/GDI/italicText.aspx?display=Print - http://www.codeproject.com/KB/GDI/italicText.aspx?display=Print


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: robin_l
Date 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++)


Posted By: mdoubson
Date Posted: 08 July 2009 at 4:50pm
See results on XP with ClearType ON - I updated SVN. Thanks


-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)


Posted By: mdoubson
Date Posted: 08 July 2009 at 5:11pm
Done

-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)


Posted By: mdoubson
Date Posted: 27 August 2009 at 7:50pm
OK, done

-------------
Mark Doubson, Ph.D.


Posted By: robin_l
Date 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++)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net