HighTechTalks DotNet Forums  

Combining Accents not Displayed Nicely with DrawString

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Combining Accents not Displayed Nicely with DrawString in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Florian Haag
 
Posts: n/a

Default Combining Accents not Displayed Nicely with DrawString - 11-18-2009 , 04:18 AM






Hi,
I'd like to draw strings using System.Drawing.Graphics.DrawString. I have
found that combining accents sometimes do not display well, though. I have
prepared a small example project:

using System;
using System.Windows.Forms;
using System.Drawing;

namespace Test
{
public class DrawStringTest
{
public static void Main(string[] args)
{
Form frm = new Form();

TextBox tb = new TextBox();
tb.Font = new Font("Arial Unicode MS", 10);
tb.TextChanged += delegate(object sender, EventArgs e) {
frm.Refresh();
};
tb.Parent = frm;
tb.Left = 10;
tb.Top = 10;
tb.Text = "aa\x0301AA\x0301";

frm.Paint += delegate(object sender, PaintEventArgs e) {
Graphics g = e.Graphics;
g.DrawString(tb.Text, tb.Font, SystemBrushes.WindowText, new
PointF(10, 40));
};

frm.Width = 400;
frm.Height = 300;

frm.ShowDialog();
}
}
}

The text box contains two small 'a's and two capital 'a's, the 2nd of each
has a combining acute accent. While the text box displays both accents fine,
DrawString only draws the small 'á' prettily, whereas the accent on the
capital 'Á' is misplaced.
Now, I could normalize my string before passing it to DrawString, but I fear
losing correspondance to the character widths obtained via
System.Drawing.Graphics.MeasureCharacterRanges which I have to call using the
original (not normalized) string.

Is there any way to draw these strings correctly?
Thanks in advance

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.