我有一个阿拉伯字符串,它是阿拉伯字符串和“:100”连接的结果。该字符串的测量和绘制不正确。为什么?
public partial class Form1 : Form {
string strIncorrectMeasure = "مەھسۇلات باھاسى" + " : " + "100";//"مەھسۇلات باھاسى : 100";
string strCorrectMeasure = "100 : مەھسۇلات باھاسى";
Font font = new Font("Oybab tuz", 18);
public Form1() {
InitializeComponent();
}
void button1_Click(object sender, EventArgs e) {
var bitmap = new Bitmap(100, 100);
var graphics = Graphics.FromImage(bitmap);
StringFormat format = new StringFormat(StringFormatFlags.DirectionRightToLeft | StringFormatFlags.NoFontFallback | StringFormatFlags.NoClip);
SizeF measuredIcorrectSize = graphics.MeasureString(strIncorrectMeasure, font, 0, format);
SizeF measuredCorrectSize = graphics.MeasureString(strCorrectMeasure, font);
MessageBox.Show(string.Format("FirstString : {0}\nSecondString: {1}", measuredIcorrectSize, measuredCorrectSize));
}
void Form1_Paint(object sender, PaintEventArgs e) {
var font = new Font("Oybab tuz", 18);
StringFormat format = new StringFormat(StringFormatFlags.DirectionRightToLeft);
e.Graphics.DrawString(this.strIncorrectMeasure, font, Brushes.Black, new PointF(300, 10), format);
e.Graphics.DrawString(this.strCorrectMeasure, font, Brushes.Black, new PointF(10, 50));
}
}
这个问题有可能是由这个特定的字体引起的吗?