如何列出另一个目录中的字体 [英] How to list fonts from another directory

查看:102
本文介绍了如何列出另一个目录中的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上创建了一个列表框,显示存储在网络驱动器上的字体文件。效果很好,但我需要列表显示字体姓氏/标题而不是文件名。即:Arial,Arial Black,Calibri,Tahoma等.......



我尝试过:



 Public Sub LoadList2()
'加载网络文件夹中的字体列表
Dim directory =c:\ Odds& ; Ends \FontSync \MasterFontList
Dim files()As System.IO.FileInfo
Dim dirinfo As New System.IO.DirectoryInfo(Directory)
files = dirinfo.GetFiles()
For Each file in file
ListBox2.Items.Add(file.Name)
Next
End Sub

解决方案

尝试:

  Dim  fontCol  As   PrivateFontCollection()
fontCol.AddFontFile( D:\ Test Data \ MyFont.otf
Console.WriteLine(fontCol.Families( 0 )。名称)


I have created a list box on a form that shows font files that are stored on a network drive. Works great, but i need the list to show the font "family name" / "Title" and not the file name. ie: Arial, Arial Black, Calibri, Tahoma, etc.......

What I have tried:

Public Sub LoadList2()
       'loading list of fonts in network folder
       Dim directory = "c:\Odds & Ends\FontSync\MasterFontList"
       Dim files() As System.IO.FileInfo
       Dim dirinfo As New System.IO.DirectoryInfo(Directory)
       files = dirinfo.GetFiles()
       For Each file In files
           ListBox2.Items.Add(file.Name)
       Next
   End Sub

解决方案

Try:

Dim fontCol As New PrivateFontCollection()
fontCol.AddFontFile("D:\Test Data\MyFont.otf")
Console.WriteLine(fontCol.Families(0).Name)


这篇关于如何列出另一个目录中的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆