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 » Community » Coffee corner » Antigrain author on text rasterisation
Antigrain author on text rasterisation [message #30831] Mon, 24 January 2011 15:07 Go to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Finally someone explained why Apple fonts are good, why M$ fonts are worse and Linux fonts are ugly. Cool
http://www.antigrain.com/research/font_rasterization/index.h tml
Author proposes good approach to make rendered fonts good looking.
May be it will be interesting as U++ has it's own text rendering.

[Updated on: Mon, 24 January 2011 15:08]

Report message to a moderator

Re: Antigrain author on text rasterisation [message #30832 is a reply to message #30831] Mon, 24 January 2011 16:14 Go to previous messageGo to next message
chickenk is currently offline  chickenk
Messages: 168
Registered: May 2007
Location: Grenoble, France
Experienced Member
Indeed, the author's article is very interesting, I read it a while ago. This was one of the reason I also asked about antigrain integration in U++, and Mirek gave this request the best anwser: he created Painter, which introduces the concepts of antigrain without the downsides.

Maybe Mirek took some inspiration for fonts rendering in Painter from this article as well ?

[Updated on: Mon, 24 January 2011 16:16]

Report message to a moderator

Re: Antigrain author on text rasterisation [message #30834 is a reply to message #30831] Mon, 24 January 2011 17:31 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1781
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Interesting article, thanks Mindtraveller.

It raises many question about how the U++ text rendering works. (And I am too busy/lazy to look search for the answers in the code Rolling Eyes ). So, is the U++ font rendering used everywhere (i.e. in Draw) or only in Painter? Does U++ use win api? (I already know that it does use FreeFont based Xft on X11...). What approach was chosen in Painter? There is subpixel positioning available, so is it used on texts too?

Sorry for so many questions, but the article woke up my curiosity Smile

Best regards,
Honza
Re: Antigrain author on text rasterisation [message #30836 is a reply to message #30834] Mon, 24 January 2011 17:58 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
dolik.rce wrote on Mon, 24 January 2011 16:31

Interesting article, thanks Mindtraveller.

It raises many question about how the U++ text rendering works. (And I am too busy/lazy to look search for the answers in the code Rolling Eyes ). So, is the U++ font rendering used everywhere (i.e. in Draw) or only in Painter? Does U++ use win api? (I already know that it does use FreeFont based Xft on X11...). What approach was chosen in Painter? There is subpixel positioning available, so is it used on texts too?

Sorry for so many questions, but the article woke up my curiosity Smile

Best regards,
Honza


First of all, Mindtraveller, that article is 4 years old (2007?). agg was the reason for Painter (I think, if you have studied our forums Wink )

UPP::Painter = ( 2% ? agg) + (mirek's brain juice)
Everything else is ugly. Smile

honza, for your reference from UPP DrawTextWin32.cpp:
#ifdef PLATFORM_WIN32

#define LLOG(x)

HFONT GetWin32Font(Font fnt, int angle);

void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink,
                      int n, const int *dx) {
	Std(font);
	while(n > 30000) {
		DrawTextOp(x, y, angle, text, font, ink, 30000, dx);
		if(dx) {
			for(int i = 0; i < 30000; i++)
				x += *dx++;
		}
		else
			x += GetTextSize(text, font, 30000).cx;
		n -= 30000;
		text += 30000;
	}
	GuiLock __;
	COLORREF cr = GetColor(ink);
	if(cr != lastTextColor) {
		LLOG("Setting text color: " << ink);
		::SetTextColor(handle, lastTextColor = cr);
	}
	HGDIOBJ orgfont = ::SelectObject(handle, GetWin32Font(font, angle));
	int ascent = font.Info().GetAscent();
	if(angle) {
		double sina, cosa;
		Draw::SinCos(angle, sina, cosa);
		Size offset;
		::ExtTextOutW(handle, x + fround(ascent * sina), y + fround(ascent * cosa), 0, NULL, (const WCHAR *)text, n, dx);
	}
	else
		::ExtTextOutW(handle, x, y + ascent, 0, NULL, (const WCHAR *)text,
		              n, dx);
	::SelectObject(handle, orgfont);
}

#endif


On the other hand, many people with LCD screens still don't know how to enable and tune antialiasing on their Windows or Linux systems...

Re: Antigrain author on text rasterisation [message #30837 is a reply to message #30836] Mon, 24 January 2011 18:12 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Of course I'm aware that Mirek used Antigrain and derived Painter package. That is why I posted this link above. My idea was - if U++ will draw text with vertical-only hinting, it will improve visual quality on ALL platforms.

[Updated on: Mon, 24 January 2011 18:22]

Report message to a moderator

Re: Antigrain author on text rasterisation [message #30845 is a reply to message #30834] Tue, 25 January 2011 00:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13442
Registered: November 2005
Ultimate Member
dolik.rce wrote on Mon, 24 January 2011 11:31


So, is the U++ font rendering used everywhere (i.e. in Draw) or only in Painter?



SystemDraw is using host platform facilities to render text.

Quote:


Does U++ use win api? (I already know that it does use FreeFont based Xft on X11...).



Painter uses only winapi to get font outlines, same is done by FreeType in X11. See Painter/FontWin32 and Painter/FontX11

Quote:


What approach was chosen in Painter? There is subpixel positioning available, so is it used on texts too?



Actually, Painter does not distinguish (at least at the moment) text from any other painting.

And yes, you can request subpixel rendering in Painter. In PainterExamples, there is even GUI switch to activate it (so you can freely study differences Smile...
Re: Antigrain author on text rasterisation [message #30846 is a reply to message #30837] Tue, 25 January 2011 00:33 Go to previous message
mirek is currently offline  mirek
Messages: 13442
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Mon, 24 January 2011 12:12

Of course I'm aware that Mirek used Antigrain and derived Painter package.



Actually, while I have seen Antigrain sources, I have only recycled about 30 lines (interestigly, those fetching font glyphs in X11 and Win32).

Generally I think AGG approach is somewhat inflexible in the real life, for no good performance gain (we are faster anyway Smile

Quote:


That is why I posted this link above. My idea was - if U++ will draw text with vertical-only hinting, it will improve visual quality on ALL platforms.


Well, maybe we can try. But I am not so sure about it...
Previous Topic: Are they serious with this 'security' in Win7?
Next Topic: Thoughts about resource management
Goto Forum:
  


Current Time: Thu Oct 21 03:28:31 CEST 2021

Total time taken to generate the page: 0.01129 seconds