chengulv

 

 

// 一、使用资源文件(内存)中的字体
System.Runtime.InteropServices.GCHandle hObject = System.Runtime.InteropServices.GCHandle.Alloc(Properties.Resources.QuartzMS, System.Runtime.InteropServices.GCHandleType.Pinned);
            IntPtr intptr = hObject.AddrOfPinnedObject();
            System.Drawing.Text.PrivateFontCollection fc = new System.Drawing.Text.PrivateFontCollection();
            fc.AddMemoryFont(intptr, Properties.Resources.QuartzMS.Length);
            Font font1 = new Font(fc.Families[0], 20);
            label1.UseCompatibleTextRendering = true; //这句很关键
            label1.Text = "0123456789";
            label1.Font = font1;

 

// 二、使用文件中的字体
System.Drawing.Text.PrivateFontCollection fc = new System.Drawing.Text.PrivateFontCollection();
            fc.AddFontFile("x:\\QuartzMS.ttf");
            Font font1 = new Font(fc.Families[0], 20);
            label1.Text = "0123456789";
            label1.Font = font1;

 

分类:

技术点:

相关文章:

  • 2021-10-06
  • 2022-12-23
  • 2021-09-06
  • 2021-11-03
  • 2021-11-17
  • 2021-11-25
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-11-03
  • 2021-11-01
  • 2022-12-23
相关资源
相似解决方案