1、第一种方法
using System.Windows.Media; String fontFilePath = "PATH TO YOUR FONT"; GlyphTypeface glyphTypeface = new GlyphTypeface(fontFileURI); String fontFamily = glyphTypeface.Win32FamilyNames[new System.Globalization.CultureInfo("en-us")]; String fontFace = glyphTypeface.Win32FaceNames[new System.Globalization.CultureInfo("en-us")]; Console.WriteLine("Font: " + fontFamily + " " + fontFace);
2、第二种方法
using System;
using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Text; using System.Runtime.InteropServices; namespace Utility { public class Font { public string GetFont(byte[] [FONTASBYTEARRAY]) { PrivateFontCollection fc = new PrivateFontCollection(); IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement([FONTASBYTEARRAY], 0); fc.AddMemoryFont(pointer, Convert.ToInt32([FONTASBYTEARRAY].Length)); System.Drawing.Font f = new System.Drawing.Font(fc.Families[0], 10); FontFamily ff = f.FontFamily; return ff.Name; } } }