zoukankan      html  css  js  c++  java
  • 使用资源文件(内存)中的字体 或 使用文件中的字体

    // 一、使用资源文件(内存)中的字体
    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;
  • 相关阅读:
    对于global的介绍
    elang和python互通的例子
    gen_server的一些心得
    erlang分布式例子
    erlang热部署
    erlang配置三方库
    opencv学习之PyImageSearch
    雅克比矩阵
    罗德里格斯公式的证明
    opencv学习网站
  • 原文地址:https://www.cnblogs.com/chengulv/p/4830148.html
Copyright © 2011-2022 走看看