winForm如何使用C#在系统中没有安装的字体?

C# winForm. 如何使用系统中没有安装的字体,比如我想使用微软雅黑字体.可这种字体在XP上没有安装,怎么办?

  • catouse - 1年前

    将字体编译到程序中

  • lucifer - 1年前

    字体文件以资源的形式出现 编译在.EXE文件中

    PrivateFontCollection p_Font = new PrivateFontCollection();
                byte[] b_Font = new byte[Mentalarithmetic.Properties.Resources.DS_DIGIT.Length];
                IntPtr MeAdd = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(byte)) * b_Font.Length);
                Marshal.Copy(Mentalarithmetic.Properties.Resources.DS_DIGIT, 0, MeAdd, Mentalarithmetic.Properties.Resources.DS_DIGIT.Length);
                p_Font.AddMemoryFont(MeAdd, b_Font.Length);
                m_ShowNumber.Font = new Font(p_Font.Families[0],18,FontStyle.Bold|FontStyle.Regular);
    

  • 将字体文件打包,在客户端安装时,把它自动拷贝到Windows下边那个字体文件夹里边