繁体   English   中英

获取字体样式的整数枚举值

[英]Obtaining Integer Enumeration Value for a Font style

根据MSDN ,字体样式支持的枚举值为

Bold text.  1

斜体

Italic text.    2

定期

Normal text.    0

淘汰赛

Text with a line through the middle.    8

强调

Underlined text.    4

除了这些字体外,还有许多其他样式,如何从该字体的样式中获取特定字体的枚举整数值

只需将其转换为整数即可:

var intRepresentation = (int)myFont.Style;

如果您的目标是找出一种更好的字体样式,则将是这样的:

var isBold = myFont.Style & FontStyle.Bold; // isBold is 0 if not, 1 if it is
var isItalic = myFont.Style & FontStyle.Italic; // isItalic is 0 if not, 2 if it is

请参阅此页的“作为位标志枚举”部分: http : //msdn.microsoft.com/zh-cn/library/cc138362.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM