python读取ttf,获取.TTF文件的字体名称

Lets say there is a .ttf (True Type Font) file. You can install it on windows with a click. The real name of the font is not the text that is before the .tff (lets say SuperFont.ttf => so the name is not "SuperFont" - it could be, but mostly not). I would like to read the .tff (somehow?) and get the name (without installing the font) of the font. Any ideas?

解决方案

You'll need to add the font to a private collection (PrivateFontCollection), then request the FontFamily instance and get its Name property.

Like this:

PrivateFontCollection fontCol = new PrivateFontCollection();

fontCol.AddFontFile(@"PATH TO FONT");

Console.WriteLine(fontCol.Families[0].Name);

You'll need the namespaces:

using System.Drawing;

using System.Drawing.Text;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值