zoukankan      html  css  js  c++  java
  • 显示系统所有字体

    本实例创建一个能显示系统已安装的字体的程序,并将字体信息显示在RichTextBox中,程序运行结果如下图。

    20120409163115

    程序代码如下。

    using System;
    using System.Drawing;
    using System.Drawing.Text;
    using System.Windows.Forms;
    namespace eg48_displayFont
    {
    	public partial class MainForm : Form
    	{
    		public MainForm()
    		{
    			InitializeComponent();
    		}
    		
    		void B_DisplayFontsClick(object sender, EventArgs e)
    		{
    			InstalledFontCollection ifc=new InstalledFontCollection();
    			FontFamily[] ffs=ifc.Families;
    			Font f;
    			richTextBox1.Clear();
    			foreach(FontFamily ff in ffs)
    			{
    				if(ff.IsStyleAvailable(System.Drawing.FontStyle.Regular))
    					f=new Font(ff.GetName(1),12,System.Drawing.FontStyle.Regular);
    				else if(ff.IsStyleAvailable(System.Drawing.FontStyle.Bold))
    					f=new Font(ff.GetName(1),12,System.Drawing.FontStyle.Bold);
    				else if(ff.IsStyleAvailable(System.Drawing.FontStyle.Italic))
    					f=new Font(ff.GetName(1),12,System.Drawing.FontStyle.Italic);
    				else
    					f=new Font(ff.GetName(1),12,System.Drawing.FontStyle.Underline);
    				richTextBox1.SelectionFont=f;
    				richTextBox1.AppendText(ff.GetName(1)+"\r\n");
    				richTextBox1.SelectionFont=f;
    				richTextBox1.AppendText("abcdefghijklmnopqrstuvwxyz\r\n");
    				richTextBox1.SelectionFont=f;
    				richTextBox1.AppendText("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n");
    				richTextBox1.AppendText("==========================\r\n");
    			}
    			MessageBox.Show("已经把所有字体显示在文本框中","成功",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
    		}
    	}
    }
    作者:codee
    文章千古事,得失寸心知。


  • 相关阅读:
    tensorFlow(二)线性回归
    tensorFlow(一)相关重要函数理解
    Java NIO学习笔记-通道&缓冲区
    Code Plus插件开发笔记
    Java NIO框架Netty demo
    前端React开发入门笔记
    Tomcat性能优化
    Spring Boot整合Dubbo框架demo
    Spring Boot入门实例
    简单的RPC原型与实现原理
  • 原文地址:https://www.cnblogs.com/bimgoo/p/2437735.html
Copyright © 2011-2022 走看看