如何确定字体是否有衬线 [英] How to find out if a font has serifs or not

查看:134
本文介绍了如何确定字体是否有衬线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个字体查看器程序,显示我系统上的所有字体。我已经想出如何列出所有这些。现在我要过滤列表。



我有两个列表视图。 Listview一个FilterListView和第二个FontListView。 FontListView将填充我系统上可用的所有字体(1800),FilterListView将填充All,Serif,San-Serif,Decorative,Script等...取决于什么我可以过滤。



当从FilterListView进行选择时,我希望FontViewListView只显示那些字体,如果是从Serif字体中选择的字体FilterListView。



请不要告诉我什么是衬线。我知道这个。

我想过滤我系统上的字体列表,我已经超过1800.

I am writing a font viewer program that shows all the fonts on my system. I have figured out how to list them all. Now I want to filter the list.

I have two listviews. Listview one FilterListView and the second FontListView. The FontListView is populated will all the fonts available on my system over (1800) the FilterListView will be populated with "All", "Serif", "San-Serif", "Decorative", "Script" etc... depending on what I can filter by.

When a selection is made from the FilterListView I want the FontViewListView to show only those fonts that are say Serif fonts if that is what is selected from the FilterListView.

Please do not tell me what a serif is. I know this.
I want to Filter the list of fonts on my system and I have over 1800.

推荐答案

如果你正在使用C#System.Drawing.Font类有一个FontFamily属性。



从文档中不清楚这个属性是否对你有帮助,但是你可以研究一下你的每种字体的含义,看看它是否能解决这个问题。



在C / MFC中,你有可以使用的CFont类检索描述字体的LOGFONT结构 - 该结构中的一个字段是lfPitchAndFamily,定义为:



字体的音高和族。两个低位指定字体的间距,可以是以下值之一。

•DEFAULT_PITCH

•FIXED_PITCH

• VARIABLE_PITCH



会员的第4到第7位指定字体系列,可以是以下值之一。

•FF_DECORATIVE
•FF_DONTCARE

•FF_MODERN

•FF_ROMAN

•FF_SCRIPT

•FF_SWISS



它并不能给你serif / sans-serif - 最接近的是罗马/现代 - 但是如果你只是试图在某种形式上将它们分解出来组,它可能适合你。
If you are using C# the System.Drawing.Font class has a FontFamily property.

It''s not clear from the documentation if this property will be helpful for you or not, but you might investigate what it is for each of your fonts and see if it will do the trick.

In C/MFC, you have the CFont class which you can use to retrieve a LOGFONT struct that describes the font -- one of the fields in that struct is lfPitchAndFamily which is defined as:

The pitch and family of the font. The two low-order bits specify the pitch of the font and can be one of the following values.
•DEFAULT_PITCH
•FIXED_PITCH
•VARIABLE_PITCH

Bits 4 through 7 of the member specify the font family and can be one of the following values.
•FF_DECORATIVE
•FF_DONTCARE
•FF_MODERN
•FF_ROMAN
•FF_SCRIPT
•FF_SWISS

It doesn''t quite give you serif / sans-serif -- the closest is roman / modern -- but if you are just trying to break them up in some sort of groups, it might work for you.


据我所知,从TrueType和OpenType规范docume \ENTS(找到此处 [ ^ ]),没有这样的财产告诉你这个。但是,我没有阅读任何技术的整个规范。



我可以告诉你.NET中的Font类中没有这样的属性。因此,如果规范中提供了这些信息,那么你必须自己解析字体文件才能获得它。
As far as I can tell, from the TrueType and OpenType specification docume\nts (found here[^]), there is no such property to tell you this. But, I didn''t read the entire specification for either technology.

I can tell you there is no such property in the Font classes in .NET. So, if it''s in the specification that this information should be supplied, you''d have to parse the font files yourself to get at it.


这篇关于如何确定字体是否有衬线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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