Saturday, June 12, 2021

【Visual Studio Visual Csharp】System Fonts

 using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; // make sure that using System.Drawing; is included using System.Drawing; // make sure that using System.Diagnostics; is included using System.Diagnostics; using System.Runtime.InteropServices; namespace systemfontC { public partial class Form1 : Form { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class LOGFONT { public int lfHeight = 0; public int lfWidth = 0; public int lfEscapement = 0; public int lfOrientation = 0; public int lfWeight = 0; public byte lfItalic = 0; public byte lfUnderline = 0; public byte lfStrikeOut = 0; public byte lfCharSet = 0; public byte lfOutPrecision = 0; public byte lfClipPrecision = 0; public byte lfQuality = 0; public byte lfPitchAndFamily = 0; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string lfFaceName = string.Empty; } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { foreach (FontFamily font in FontFamily.Families) { listBox1.Items.Add(font.Name); } } } }

No comments:

Post a Comment