Hi,
we are trying to migrate from regular .NET version to WPF version.
in comparison to the regular version, in WPF we get the text(using TextOut function and also using GdiPlusCanvas.DrawText) blurry - we are using Tahoma font with size 8.
i read about it a little bit and i assume it's a general rendering problem\feature in WPF. i found that in WPF4 microsoft added a new DP called TextOptions.TextRenderingMode, to control how the text render.
after trying it on the TeeChart, nothing happen:
TextOptions.SetTextRenderingMode(Chart,TextRenderingMode.Grayscale); //Or Aliasing
Chart.Graphics3D.TextOut(tRect.Left, tRect.Top, sText);
i tried many other variations, but i couldn't find a solution to display the text clear like in regular .net version.
do you have any solutions for me?
how can i use the TextRenderingMode DP with the teechart and make it work?
are they any other ways to make the text look clear?
WPF blurry text
Re: WPF blurry text
Hello MVUser6,
I inform you that we have added your problem in feature request list with number [TW16016325] to be consdier its inclusion in upcoming versions of WPF. On the other hand, you need know that Blurry text has been a problem in WPF forever as you can see here, Nowadays, .net framework 4.0 we have the TextOptions class.unfortunately, this can only be applied directly to a framework element as explain in next link:
http://stackoverflow.com/questions/4095 ... t-glyphrun.
So, at the moment , the only way we're going to get this to work , is using the "FormattedText.BuildGeometry() trick" suggested in the stackoverflow thread.
I hope will help.
Thank you,
I inform you that we have added your problem in feature request list with number [TW16016325] to be consdier its inclusion in upcoming versions of WPF. On the other hand, you need know that Blurry text has been a problem in WPF forever as you can see here, Nowadays, .net framework 4.0 we have the TextOptions class.unfortunately, this can only be applied directly to a framework element as explain in next link:
http://stackoverflow.com/questions/4095 ... t-glyphrun.
So, at the moment , the only way we're going to get this to work , is using the "FormattedText.BuildGeometry() trick" suggested in the stackoverflow thread.
I hope will help.
Thank you,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF blurry text
hi,
can you post a sample code of writing text in this way?
can you post a sample code of writing text in this way?
Re: WPF blurry text
hi,
i found a solution.
in formattedtext constructor there is a flag called TextFormattingMode. if you set it to TextFormattingMode.Display, the text looks like in GDI.
the only way to set this flag is in the constructor. this property is not exposed.
i found a solution.
in formattedtext constructor there is a flag called TextFormattingMode. if you set it to TextFormattingMode.Display, the text looks like in GDI.
the only way to set this flag is in the constructor. this property is not exposed.
Re: WPF blurry text
Hello MVUser6,
I am glad that you can solve your problem. Many thanks for your information, we consider it for treat the feature request.
Thanks,
I am glad that you can solve your problem. Many thanks for your information, we consider it for treat the feature request.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: WPF blurry text
Hi MVUser6,
Thanks for your feedback. I don't see this makes any difference though. I tried using this code:
Which produce this chart:
I'm not able to see any difference between the two bottom text lines. Do you see any difference on it? Are you doing any modifications on the code?
Thanks in advance.
Thanks for your feedback. I don't see this makes any difference though. I tried using this code:
Code: Select all
public MainWindow()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.AfterDraw += new Steema.TeeChart.WPF.PaintChartEventHandler(tChart1_AfterDraw);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.WPF.Drawing.Graphics3D g)
{
g.Font.Size = 8;
g.Font.Name = "Tahoma";
g.TextOut(100, 75, "Default WPF text");
TextOptions.SetTextRenderingMode(tChart1, TextRenderingMode.Grayscale);
g.TextOut(100, 100, "TextRenderingMode.Grayscale");
TextOptions.SetTextRenderingMode(tChart1, TextRenderingMode.Aliased);
g.TextOut(100, 125, "TextRenderingMode.Aliased");
TextOptions.SetTextRenderingMode(tChart1, TextRenderingMode.ClearType);
g.TextOut(100, 150, "TextRenderingMode.ClearType");
FormattedText text = new FormattedText("GDI+ text!", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, g.Font.DrawingFont, g.Font.Size * 3, g.Brush.DrawingBrush);
g.GDIplusCanvas.DrawText(text , new Point(100, 175));
FormattedText text2 = new FormattedText("GDI+ text!", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, g.Font.DrawingFont, g.Font.Size * 3, g.Brush.DrawingBrush, new NumberSubstitution(), TextFormattingMode.Display);
g.GDIplusCanvas.DrawText(text2, new Point(100, 200));
}
I'm not able to see any difference between the two bottom text lines. Do you see any difference on it? Are you doing any modifications on the code?
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: WPF blurry text
hi,
try this one:
private void TChart_AfterDraw(object sender, Steema.TeeChart.WPF.Drawing.Graphics3D g)
{
g.Font.Size = 10.6;
g.Font.Name = "Tahoma";
g.TextOut(100, 75, "Default WPF text");
TextOptions.SetTextRenderingMode(tchart1, TextRenderingMode.Grayscale);
g.TextOut(100, 100, "TextRenderingMode.Grayscale");
TextOptions.SetTextRenderingMode(tchart1, TextRenderingMode.Aliased);
g.TextOut(100, 125, "TextRenderingMode.Aliased");
TextOptions.SetTextRenderingMode(tchart1, TextRenderingMode.ClearType);
g.TextOut(100, 150, "TextRenderingMode.ClearType");
FormattedText text = new FormattedText("GDI+ text!", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, tchart1.Graphics3D.Font.DrawingFont, g.Font.Size, g.Brush.DrawingBrush);
tchart1.Graphics3D.GDIplusCanvas.DrawText(text, new Point(100, 175));
FormattedText text2 = new FormattedText("GDI+ text!", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, tchart1.Graphics3D.Font.DrawingFont, g.Font.Size, new SolidColorBrush(Color.FromArgb(255, 0, 0, 80)), new NumberSubstitution(), TextFormattingMode.Display);
tchart1.Graphics3D.GDIplusCanvas.DrawText(text2, new Point(100, 200));
}
now you will notice
try this one:
private void TChart_AfterDraw(object sender, Steema.TeeChart.WPF.Drawing.Graphics3D g)
{
g.Font.Size = 10.6;
g.Font.Name = "Tahoma";
g.TextOut(100, 75, "Default WPF text");
TextOptions.SetTextRenderingMode(tchart1, TextRenderingMode.Grayscale);
g.TextOut(100, 100, "TextRenderingMode.Grayscale");
TextOptions.SetTextRenderingMode(tchart1, TextRenderingMode.Aliased);
g.TextOut(100, 125, "TextRenderingMode.Aliased");
TextOptions.SetTextRenderingMode(tchart1, TextRenderingMode.ClearType);
g.TextOut(100, 150, "TextRenderingMode.ClearType");
FormattedText text = new FormattedText("GDI+ text!", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, tchart1.Graphics3D.Font.DrawingFont, g.Font.Size, g.Brush.DrawingBrush);
tchart1.Graphics3D.GDIplusCanvas.DrawText(text, new Point(100, 175));
FormattedText text2 = new FormattedText("GDI+ text!", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, tchart1.Graphics3D.Font.DrawingFont, g.Font.Size, new SolidColorBrush(Color.FromArgb(255, 0, 0, 80)), new NumberSubstitution(), TextFormattingMode.Display);
tchart1.Graphics3D.GDIplusCanvas.DrawText(text2, new Point(100, 200));
}
now you will notice
Re: WPF blurry text
Hello MVUser6,
Sorry for the delay. I have tested your code and I have gotten next image:
Do you get the same result as us? If you have the same results as us, please explain exactly wherewhere is the problem? On the other hand, if the result is different please attached an image with your result, because we can investigate what could be the problem.
Thanks,
Sorry for the delay. I have tested your code and I have gotten next image:
Do you get the same result as us? If you have the same results as us, please explain exactly wherewhere is the problem? On the other hand, if the result is different please attached an image with your result, because we can investigate what could be the problem.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |