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 » Painter small text quality
Painter small text quality [message #39752] Tue, 23 April 2013 12:37 Go to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Hello all

I would like to improve text quality using Painter for small texts.

In the image it is the same screen with Draw and Painter. The small texts in the X axis (Jan, Feb, Mar, ...) look better with Draw.

index.php?t=getfile&id=4145&private=0

This is the code for both:

void DrawText(Draw &w, double x, double y, int angle, const String &text, Font font, Color color) {
	w.DrawText(fround(x), fround(y), angle, text, font, color);
}

void DrawText(Painter &w, double x, double y, int angle, const String &text, Font font, Color color) {
	w.Begin();
	w.Translate(x, y).Rotate(-angle*M_PI/1800.);
	w.Text(0, 0, text, font).Fill(color);
	w.End();
}

Do you know how to improve the quality?
  • Attachment: Painter.png
    (Size: 142.96KB, Downloaded 347 times)


Best regards
Iñaki
Re: Painter small text quality [message #39756 is a reply to message #39752] Tue, 23 April 2013 19:01 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1758
Registered: August 2008
Location: Czech Republic
Senior Contributor

Hi Koldo,

Small fonts always look ugly when they're anti-aliased. I'd suggest to round the values for the painter variant as well, it can make a huge difference:
index.php?t=getfile&id=4147&private=0
This preview was generated using this code:
void TextTest(Painter& sw) {
	sw.DrawText(10,100, "Hello world! // DrawText()", Roman(12), Black());
	for(int i=0; i<=5; ++i)
		sw.Text(10+0.2*i, 120+i*20, Format("Hello world! // Text() shifted %2vf pixel left",i*0.2), Roman(12))
		  .Fill(Black());
	for(int i=0; i<=5; ++i)
		sw.Text(300, 120+i*20.2, Format("Hello world! // Text() shifted %2vf pixel down",i*0.2), Roman(12))
		  .Fill(Black());
}


Also, you're pictures seem like there are errors in the letter spacing. Not sure where that comes from, I couldn't reproduce it on my system... I think you can safely use DrawText() everywhere, or do some compromise, e.g.
void DrawText(Painter &w, double x, double y, int angle, const String &text, Font font, Color color) {
	if(font.GetHeight()>15) {
		w.Begin();
		w.Translate(x, y).Rotate(-angle*M_PI/1800.);
		w.Text(0, 0, text, font).Fill(color);
		w.End();
	} else
		w.DrawText(fround(x), fround(y), angle, text, font, color);
}


Best regards,
Honza

EDIT: Corrected image and code
  • Attachment: text.png
    (Size: 24.82KB, Downloaded 327 times)

[Updated on: Tue, 23 April 2013 20:18]

Report message to a moderator

Re: Painter small text quality [message #39761 is a reply to message #39756] Wed, 24 April 2013 09:01 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Hello Honza

I like your proposal. Using it I get this:

index.php?t=getfile&id=4148&private=0

The letter spacing is solved although the look remains worse than the original Draw.

Initially I shifted the texts some tenths of pixel but now the results IMHO are not significantly improved.

I think that if it is not possible to improve this in the next future I will paint the texts using Draw over the graphs drawn with Painter.
  • Attachment: Paint.png
    (Size: 72.51KB, Downloaded 319 times)


Best regards
Iñaki
Re: Painter small text quality [message #39973 is a reply to message #39761] Tue, 21 May 2013 12:19 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3030
Registered: August 2008
Ultimate Member
Hello all

Problem solved. Now all ScatterCtrl texts are drawn using Draw even using Painter to plot. For ScatterDraw all is drawn using Painter.

index.php?t=getfile&id=4198&private=0
  • Attachment: plot.png
    (Size: 79.43KB, Downloaded 281 times)


Best regards
Iñaki
Re: Painter small text quality [message #39988 is a reply to message #39973] Wed, 22 May 2013 21:33 Go to previous message
BioBytes is currently offline  BioBytes
Messages: 284
Registered: October 2008
Location: France
Experienced Member
Hello Koldo,

Great job Thumbs Up

Regards
Biobytes
Previous Topic: ScatterDraw/ScatterCtrl new features
Next Topic: PATCH: plugin/jpg CMYK support
Goto Forum:
  


Current Time: Sun Nov 17 01:22:19 CET 2019

Total time taken to generate the page: 0.02059 seconds