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;
        }
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-09-11
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-01-03
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
相关资源
相似解决方案