0

我想在我的应用程序中使用波斯语数字,而文本是任何语言此代码在 Windows 7 中有效,但在 Windows 8 和 8.1 中无效。请帮我。

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        SetDigitSubExample(e);
    }

    public void SetDigitSubExample(PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        SolidBrush blueBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255));
        Font myFont = new Font("Courier New", 12);
        StringFormat myStringFormat = new StringFormat();
        string myString = "0 1 2 3 4 5 6 7 8 9";

        // Farsi (1065) digits. 

        // Use National substitution method.
        myStringFormat.SetDigitSubstitution(1065, StringDigitSubstitute.National);
        g.DrawString("Farsi:\nMethod of substitution = National:     " + myString, myFont, blueBrush, new PointF(10.0f, 20.0f), myStringFormat);

        // Use Traditional substitution method.
        myStringFormat.SetDigitSubstitution(1065, StringDigitSubstitute.Traditional);
        g.DrawString("Method of substitution = Traditional:  " + myString, myFont, blueBrush, new PointF(10.0f, 55.0f), myStringFormat);
    }

Windows 7: http ://tinypic.com/r/etb5gl/5

Windows 8: http ://tinypic.com/r/30j1ysm/5

4

1 回答 1

0

用这个

// Arabic (0x0C01) digits. 

// Use National substitution method.
myStringFormat.SetDigitSubstitution(0x0C01,
    StringDigitSubstitute.National);
g.DrawString(
    "Arabic:\nMethod of substitution = National:     " + myString,
    myFont, blueBrush, new PointF(10.0f, 20.0f), myStringFormat);

// Use Traditional substitution method.
myStringFormat.SetDigitSubstitution(0x0C01,
    StringDigitSubstitute.Traditional);
g.DrawString(
    "Method of substitution = Traditional:  " + myString,
    myFont, blueBrush, new PointF(10.0f, 55.0f), myStringFormat);
于 2014-07-03T14:19:52.760 回答