Printing Right-To-Left in c#

后端 未结 2 459
终归单人心
终归单人心 2020-12-15 19:35

According to msdn: http://www.microsoft.com/middleeast/msdn/arabicsupp.aspx

How GDI+ Support Arabic?

GDI+ supports Arabic text manipul

相关标签:
2条回答
  • 2020-12-15 20:23

    You could make a very simple coordinate transformation:

    public static class CoordinateConverter
    {
        public static RectangleF Convert(RectangleF source, RectangleF drawArea)
        {
            // I assume drawArea.X to be 0
            return new RectangleF(
                drawArea.Width - source.X - source.Width,
                source.Y,
                source.Width,
                source.Height);
        }
    
        public static RectangleF ConvertBack(Rectangle source, RectangleF drawArea)
        {
           return new RectangleF(
               source.X + source.Width - drawArea.Width,
               source.Y,
               source.Width,
               source.Height);
        }
    }
    

    Now every time you want something texty to be drawn, you can use this converter to change the coordinates. Of course you could also ref a rectangle so you don't create new ones all the time. But the principle stays the same. I hope I understood your question correctly.

    0 讨论(0)
  • 2020-12-15 20:24

    Use StringFormatFlags.DirectionRightToLeft, like this:

    StringFormat format = new StringFormat(StringFormatFlags.DirectionRightToLeft);
    e.Graphics.DrawString("سلام",
                    this.Font,
                    new SolidBrush(Color.Red),
                    r1,
                    format);
    
    0 讨论(0)
提交回复
热议问题