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 #50966 is a reply to message #50852] Tue, 15 January 2019 10:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member

FontEntry fi_cache[63];

const CommonFontInfo& GetFontInfo(Font font)
{
	INTERLOCKED {
		font.RealizeStd();
		unsigned hash = FoldHash(font.GetHashValue()) % 63;
		FontEntry& e = fi_cache[hash];
		if(e.font != font.AsInt64()) {
			Mutex::Lock __(sFontLock);
			e.font = font.AsInt64();
			e.info = GetFontInfoSys(font);
		}
		return e.info;
	}
}



(Removal of thread__ for fi_cache)
Re: Strange issue with text in Painter [message #50967 is a reply to message #50966] Tue, 15 January 2019 10:19 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Hi,

Removal of thread__ for fc_cache and fi_cache do not help. The issue is still there.

-

As for the testcode, I could not spot any false characters there, but the granularity due to significant zooming ruins part of the larger texts.

BR, Tom
Re: Strange issue with text in Painter [message #50968 is a reply to message #50852] Tue, 15 January 2019 10:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
That testing code I have posted works better with

	virtual void LeftDown(Point p, dword)
	{
		start = (Pointf)p / scale;
		SetCapture();
	}

	virtual void MouseMove(Point p, dword keyflags)
	{
		if(HasCapture()) {
			Pointf pos = (Pointf)p / scale;
			translate += (pos - start);
			start = pos;
			Refresh();
		}
	}


Smile
Re: Strange issue with text in Painter [message #50969 is a reply to message #50968] Tue, 15 January 2019 11:13 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Yes Smile

And:

PainterText().MinimizeBox().MaximizeBox().Sizeable().Run();


Is nice to have too to fill the screen.

But I still can't reproduce the issue with this.

One thing that caught my attention, though, is that the large bold upright texts show up extremely coarse, which is kind of expected due to the original zoom level fitting it all in one UHD screen. But why on earth are those smaller non-bold italic / upright fonts perfectly rendered although they are even smaller in the original view?

BR, Tom
Re: Strange issue with text in Painter [message #50970 is a reply to message #50969] Tue, 15 January 2019 11:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes, I have noticed it too. I am not so sure original zoom level has anything to do with that though... (it should get new tolerance value)
Re: Strange issue with text in Painter [message #50971 is a reply to message #50970] Tue, 15 January 2019 11:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
As to this issue, is it possible that all other texts are using your custom "Sheer" italic?

It actually looks like setting tolerance to 0.3 is not a good idea...

EDIT: tolerance is ok

[Updated on: Tue, 15 January 2019 11:27]

Report message to a moderator

Re: Strange issue with text in Painter [message #50972 is a reply to message #50971] Tue, 15 January 2019 11:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Is it by any means possible that missing letter are from those 'ugly' texts?
Re: Strange issue with text in Painter [message #50973 is a reply to message #50971] Tue, 15 January 2019 11:43 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
mirek wrote on Tue, 15 January 2019 12:23
As to this issue, is it possible that all other texts are using your custom "Sheer" italic?

It actually looks like setting tolerance to 0.3 is not a good idea...

EDIT: tolerance is ok


My custom reverse italic (using sheer to lean back) is using standard upright font and the normal italic is using standard italic served by Painter (as is without custom sheer). The ugly characters appear when the font is bold.

The names of lakes and other water areas (light blue) are using this reverse italic. Smaller place names are in plain italic. Larger place names are in straight-up bold. Municipalities are in even larger straight-up capital non-bold letters.

Best regards,

Tom
Re: Strange issue with text in Painter [message #50974 is a reply to message #50972] Tue, 15 January 2019 11:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Interesting, I have tried to hunt down 'ugly text issue' like this:

void Painter::TextOp(const Pointf& p, const wchar *text, Font fnt, int n, const double *dx)
{
	DDUMP(WString(text, n));


And interestingly, it looks like those are not painted as Text... or at least not stored into painting file as Text. Is that somehow possible that you have some separate path for them?
Re: Strange issue with text in Painter [message #50975 is a reply to message #50972] Tue, 15 January 2019 11:45 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
mirek wrote on Tue, 15 January 2019 12:27
Is it by any means possible that missing letter are from those 'ugly' texts?


I do not know about the missing letters, but the wrong size / wrong italicizing letters tend to come at same size and italicizing as many of the other texts that already occur on the view.

BR, Tom
Re: Strange issue with text in Painter [message #50976 is a reply to message #50975] Tue, 15 January 2019 11:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
(gtg now, 2-3 hours)
Re: Strange issue with text in Painter [message #50977 is a reply to message #50976] Tue, 15 January 2019 11:54 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
I have 1 h 8'...

Anyway, I need to pull back that 'Bold' from some place names. E.g. 'Paloniemi', which is rendered ugly, is just slightly larger straight up text than the more common place names which are italic... not even bold!

Best regards,

Tom

Re: Strange issue with text in Painter [message #50978 is a reply to message #50977] Tue, 15 January 2019 12:27 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Tom1 wrote on Tue, 15 January 2019 12:54
I have 1 h 8'...

Anyway, I need to pull back that 'Bold' from some place names. E.g. 'Paloniemi', which is rendered ugly, is just slightly larger straight up text than the more common place names which are italic... not even bold!

Best regards,

Tom



OK, now I know: There is no separate path for those ugly texts. But I suppose the font size causes some conditional conversion to polygons in Painting. I forced all fonts to be of height 12, and then applied suitable Scale to Painter. As a result all the fonts were (ugly) rendered with precision that was insufficient when zooming in. Then I did this using height 75 and again suitable scale to painter. This time all the texts rendered beautifully in Painting. So I guess the storage format and precision in Painting is dependent on font size.

BR, Tom

EDIT: I changed font height to 1 and tried again: This time all fonts rendered perfectly!! But, the inter-character spacing precision in words was terrible.

EDIT: I think I understand why I cannot send the problem in a painting to you: The Painting is generated ST and characters are partly rendered already, so the error will not show up. I must generate a file with only unrendered characters, which get rendered at your end only.

[Updated on: Tue, 15 January 2019 12:59]

Report message to a moderator

Re: Strange issue with text in Painter [message #50979 is a reply to message #50967] Tue, 15 January 2019 13:28 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Tom1 wrote on Tue, 15 January 2019 11:19
Hi,

Removal of thread__ for fc_cache and fi_cache do not help. The issue is still there.

-

As for the testcode, I could not spot any false characters there, but the granularity due to significant zooming ruins part of the larger texts.

BR, Tom


Hi!

It looks like this change of removing thread__ for fc_cache and fi_cache did not get compiled for me as I was simultaneously working on the testcode. Now I recompiled all and tried this once more and BANG! The problem was gone from my own program. And I also got it back by adding the thread__ ahead of those two caches. I think this solved the issue!

I must fly now... Will be back for more testing tomorrow.

A million thanks and best regards,

Tom
Re: Strange issue with text in Painter [message #50980 is a reply to message #50978] Tue, 15 January 2019 14:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 15 January 2019 12:27

So I guess the storage format and precision in Painting is dependent on font size.


Except it is not, AFAIK... Smile

Besides, in this situation you are just using PaintingPainter, which really just directly stores Painter commands (including TextOp and CharacterOp). And the problem is that those ugly texts get stored as curves. Maybe I am blind, but I do not see a code path that could lead to THAT.

Mirek
Re: Strange issue with text in Painter [message #50981 is a reply to message #50979] Tue, 15 January 2019 14:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 15 January 2019 13:28
Tom1 wrote on Tue, 15 January 2019 11:19
Hi,

Removal of thread__ for fc_cache and fi_cache do not help. The issue is still there.

-

As for the testcode, I could not spot any false characters there, but the granularity due to significant zooming ruins part of the larger texts.

BR, Tom


Hi!

It looks like this change of removing thread__ for fc_cache and fi_cache did not get compiled for me as I was simultaneously working on the testcode. Now I recompiled all and tried this once more and BANG! The problem was gone from my own program. And I also got it back by adding the thread__ ahead of those two caches. I think this solved the issue!

I must fly now... Will be back for more testing tomorrow.

A million thanks and best regards,

Tom


Obviously the next step is to try whether it is caused by first, second or both...

Mirek
Re: Strange issue with text in Painter [message #50982 is a reply to message #50981] Tue, 15 January 2019 16:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Upon further investigation we can forget about ugly texts. Most likely these are just results of font hinting process in Win32.

(As to what got me so confused, those texts are so mangled that I misread the name and then failed to find it in the list...)

EDIT: Hinting confirmed. I have added |GGO_UNHINTED to the GetGlyphOutlineW call and problem disappeared... (now in trunk).

[Updated on: Tue, 15 January 2019 16:26]

Report message to a moderator

Re: Strange issue with text in Painter [message #50983 is a reply to message #50981] Tue, 15 January 2019 16:37 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Ok, I will try both one at a time tomorrow.

BR, Tom
Re: Strange issue with text in Painter [message #50984 is a reply to message #50983] Wed, 16 January 2019 08:54 Go to previous messageGo to next message
Tom1
Messages: 1212
Registered: March 2007
Senior Contributor
Good morning Mirek,

Removing "thread__" from "thread__ CharEntry fc_cache[512];" fixes it.

Removing "thread__" from "thread__ FontEntry fi_cache[63];" does not have any effect on the problem.

Best regards,

Tom

BTW: Why should the caches be thread_local anyway? Isn't it true that Painter will use the same fonts with a whole bunch of threads when painting in MT? Having them common for all threads would have the used fonts cached after first hit and available to all threads. (Well, I'm likely missing something important here, but you'll probably educate me on that shortly...) Smile

[Updated on: Wed, 16 January 2019 09:12]

Report message to a moderator

Re: Strange issue with text in Painter [message #50986 is a reply to message #50984] Wed, 16 January 2019 09:18 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 16 January 2019 08:54
Good morning Mirek,

Removing "thread__" from "thread__ CharEntry fc_cache[512];" fixes it.

Removing "thread__" from "thread__ FontEntry fi_cache[63];" does not have any effect on the problem.

Best regards,

Tom

BTW: Why should the caches be thread_local anyway? Isn't it true that Painter will use the same fonts with a whole bunch of threads when painting in MT? Having them common for all threads would have the used fonts cached after first hit and available to all threads. (Well, I'm likely missing something important here, but you'll probably educate me on that shortly...) Smile


Only to avoid confusion, how the code for CharEntry exactly looks now for you? And again, the rest of the code is absolutely the same as trunk?

Mirek
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: Thu Mar 28 22:21:39 CET 2024

Total time taken to generate the page: 0.01940 seconds