powershell - Adding Open Type Fonts to a Private Font Collection using Add Font File method
问题描述
This is my first question here on stack overflow. I hope someone can help me. I need to add a large collection of Open Type Fonts to a private font collection object so I can extract the font name from each of the otf files. This will allow me to check if the font is already installed on a target system. Instead of checking the file names which is not reliable.
Here is my code:
Add-Type -AssemblyName System.Drawing
$path = "\\Themis\Fonts\*.*"
$otffiles = Get-ChildItem $path
$fontCollection = New-Object System.Drawing.Text.PrivateFontCollection
$otffiles | ForEach-Object{
$fontCollection.AddFontFile($_.fullname)
}
$fontcollection.Families
The above code works perfectly on Windows 10. However if I run this same exact code on Windows 7 I receive a "File Not Found" exception which I understand is thrown when the font file is not supported. I cannot believe that Windows 10 supports this method of dealing with otf files and Windows 7 doesn't. Am I missing something? Is there another way to skin this cat?
Thanks in advance
解决方案
推荐阅读
- java - 如何使用 Jackson 反序列化空类型 JSON 字段
- python - 有效地从列表中删除重复元素和类似元素
- groovy - 存储 gremlin 计数值并稍后在遍历中进行比较
- scala - 如何在 spark 2.4.3 的 reduce rdd 中覆盖元组的哈希函数?
- python - 无法让 tesseract 在 python 上工作
- angular - 在 @NgModule 装饰器中调用函数
- javascript - 将下载链接添加到 Wordpress 默认音频播放器的代码损坏
- arrays - MATLAB 基础 - 解释数组操作中的括号和冒号
- reactjs - 向套接字添加代理,以便稍后部署应用程序
- sql-server-2012 - 如何在一个查询中使用多个 where 子句更新多个表