Janyou's blog

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 protected void DrawText(Graphics graphics, string curLine, int xPos, int yPos, int width,
                                                 int height)
        {
            graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
            graphics.SmoothingMode = SmoothingMode.AntiAlias;    
      
            TextFormatFlags flags = TextFormatFlags.PreserveGraphicsTranslateTransform;
          
            Point p = new Point(xPos, yPos);
            TextRenderer.DrawText(
                 graphics, curLine,
                 ScaleFont(graphics, TextFont), 
                 ScaleRect(graphics, xPos, yPos, width, height), 
                 TextColor, flags);

        }
 

float Scale=1.3;
 
private Rectangle ScaleRect(Graphics g, int xPos, int yPos, int width, int height)
        {
          
            return new Rectangle(
                (int)Math.Ceiling(xPos * Scale),
                (int)Math.Ceiling(yPos * Scale),
                (int)Math.Ceiling(width * Scale),
                (int)Math.Ceiling(height * Scale));
     
        }
        
private Font ScaleFont(Graphics g, Font font)
       {
           
            return new Font(
                font.FontFamily, font.SizeInPoints * Scale, font.Style, GraphicsUnit.Point,
                font.GdiCharSet, font.GdiVerticalFont);
          
       }     
posted on 2008-09-11 13:27  janyou  阅读(319)  评论(0编辑  收藏  举报