Hi,
recently I am having some problems with a RichTextBox displaying Unicode characters, especially arabic, when the font used is Verdana.
However, displaying the same content on a Label or TextBox shows good and correct results. Also when using Microsoft Sans Serif instead of Verdana.
Is anyone having an idea how to solve? You can take the following as an example input for the Text property of either control:
b, t, th, dsch, h´, ch, d, th, r, z, ß, sh, s, d, t, th, a, r, f, q, k, l, m, n, h, w(u), y(i)
ﺃ, ﺐ, ﺕ, ﺚ, ﺝ, ﺡ, ﺥ, ﺪ, ﺫ, ﺭ, ﺯ, ﺱ, ﺵ, ﺹ , ﺽ, ﻁ , ﻅ, ﻉ, ﻍ, ﻑ, ﻕ, ﻙ, ﻝ, ﻡ, ﻥ, ﻩ, ﻭ, ﻱ
On a RichTextBox using Verdana the arabic characters will be displayed as squares. You can also try the following code:
using System.Windows.Forms;
namespace RichTextBoxDoesNotUnderstandArabic
{
public partial class Form1 : Form
{
public Form1()
{
string unicodeText = "a, b, t, th, dsch, h´, ch, d, th, r, z, ß, sh, s, d, t, th, a, r, f, q, k, l, m, n, h, w(u), y(i) ﺃ, ﺐ, ﺕ, ﺚ, ﺝ, ﺡ, ﺥ, ﺪ, ﺫ, ﺭ, ﺯ, ﺱ, ﺵ, ﺹ , ﺽ, ﻁ , ﻅ, ﻉ, ﻍ, ﻑ, ﻕ, ﻙ, ﻝ, ﻡ, ﻥ, ﻩ, ﻭ, ﻱ";
this.SuspendLayout();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.richTextBox1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (0)));
this.richTextBox1.Location = new System.Drawing.Point(25, 80);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(260, 103);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = unicodeText;
this.label1 = new System.Windows.Forms.Label();
this.label1.BackColor = System.Drawing.Color.White;
this.label1.Font = new System.Drawing.Font("Verdana", 8.25F);
this.label1.Location = new System.Drawing.Point(309, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(260, 103);
this.label1.TabIndex = 1;
this.label1.Text = unicodeText;
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox1.Font = new System.Drawing.Font("Verdana", 8.25F);
this.textBox1.Location = new System.Drawing.Point(591, 80);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(260, 103);
this.textBox1.TabIndex = 2;
this.textBox1.Text = unicodeText;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(883, 222);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.richTextBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
}
}
Best regards,
Michael