Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Strange issue with text in Painter
Re: Strange issue with text in Painter [message #51058 is a reply to message #51057] Thu, 17 January 2019 14:16 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 12257
Registered: November 2005
Ultimate Member
Tom1 wrote on Thu, 17 January 2019 14:12
mirek wrote on Thu, 17 January 2019 14:58
...
It starts to look like Win32 does not like the sharing of HDC... (despite of what the documentation says).

What about this:

void RenderCharacterSys(FontGlyphConsumer& sw, double x, double y, int ch, Font fnt)
{
	RLOG(CoWork::GetWorkerIndex() << " RenderCharSys " << fnt << " " << ch << " " << (char)ch);
	static Atomic h;
	h++;
	HFONT hfont = GetWin32Font(fnt, 0);
	VERIFY(hfont);
	if(hfont) {
		HDC hdc = CreateIC("DISPLAY", NULL, NULL, NULL);
		HFONT ohfont = (HFONT) ::SelectObject(hdc, hfont);
		GLYPHMETRICS gm;
		MAT2 m_matrix;
		memset(&m_matrix, 0, sizeof(m_matrix));
		m_matrix.eM11.value = 1;
		m_matrix.eM22.value = 1;
		int gsz = GetGlyphOutlineW(hdc, ch, GGO_NATIVE|GGO_UNHINTED, &gm, 0, NULL, &m_matrix);
		if(gsz < 0) {
			LOGFONT lf;
			int ret = GetObject(hfont, sizeof(lf), &lf);
			RLOG("Failed " << CoWork::GetWorkerIndex() << " RenderCharSys " << fnt << " " << ch << " " << (char)ch
			               << ", real: "  << " " << lf.lfFaceName << " " << lf.lfHeight);
			RDUMP((void *)hdc);
			RDUMP((void *)hfont);
			RDUMP(GetLastErrorMessage());
		}
		VERIFY(gsz >= 0);
		if(gsz < 0)
			return;
		StringBuffer gb(gsz);
		gsz = GetGlyphOutlineW(hdc, ch, GGO_NATIVE|GGO_UNHINTED, &gm, gsz, ~gb, &m_matrix);
		if(gsz < 0) {
			LOGFONT lf;
			int ret = GetObject(hfont, sizeof(lf), &lf);
			RLOG("Failed2 " << CoWork::GetWorkerIndex() << " RenderCharSys " << fnt << " " << ch << " " << (char)ch
			               << ", real: "  << " " << lf.lfFaceName << " " << lf.lfHeight);
			RDUMP((void *)hdc);
			RDUMP((void *)hfont);
			RDUMP(GetLastErrorMessage());
		}
		VERIFY(gsz >= 0);
		if(gsz < 0)
			return;
		RenderCharPath(~gb, gsz, sw, x, y + fnt.GetAscent());
		::SelectObject(hdc, ohfont);
		::DeleteDC(hdc);
	}
	h--;
	VERIFY(h == 0);
}



As far as I can see, not a single bad or missing letter in 8 minutes of systematic intensive scanning of names. No VERIFYs/ASSERTs either. The log is attached.

BR, Tom


Well, so be it, lets call it a fix. I will remove shared information context from the trunk... There will be small performance penalty, but it should be negligible (as there are caches on many levels anyway).

Hopefully my interpretation is right and we are not just hiding some other bug...
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MT + Subpixel appear incompatible in Painter
Next Topic: Painter: Excessive memory usage in PainterExamples moving window to edges of screen.
Goto Forum:
  


Current Time: Sat Mar 28 15:20:19 CET 2020

Total time taken to generate the page: 0.01731 seconds