1。空心字(只有外边缘的字,需要比较大的字号才能效果好 ) 

    主要用了 GraphicsPath 类

Windows Forms Programming In C# 读书笔记 - 第五章 Drawing TextGraphicsPath GetStringPath( string s, float dpi, RectangleF rect, Font font, StringFormat format) 
{
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    GraphicsPath path 
= new GraphicsPath();
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    
// Convert font size into appropriate coordinates
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text
    float emSize = dpi * font.SizeInPoints / 72;
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    path.AddString( s, font.FontFamily, (
int)font.Style, emSize, rect, format);
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    
return path;
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text}

Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    Graphics g 
= e.Graphics;
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    
string s = "Outline";
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    RectangleF rect 
= this.ClientRectangle;
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    Font font 
= new Font("Arial"32, GraphicsUnit.Point);
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    StringFormat format 
= StringFormat.GenericTypographic;
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    
float dpi = g.DpiY;
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    
using( GraphicsPath path = GetStringPath(s, dpi, rect, font, format) ) 
{
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text           g.DrawPath(Pens.Black, path);
Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text    }

Windows Forms Programming In C# 读书笔记 - 第五章 Drawing Text}

相关文章:

  • 2021-08-28
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2021-11-11
  • 2021-05-20
  • 2022-12-23
  • 2021-06-21
猜你喜欢
  • 2022-02-18
  • 2021-11-16
  • 2021-06-22
  • 2021-08-19
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案