如何实例化一个字体时设置多个FontStyles? [英] How to set multiple FontStyles when instantiating a font?

查看:268
本文介绍了如何实例化一个字体时设置多个FontStyles?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在看构造为System.Drawing.Font类有在System.Drawing.FontStyle枚举定义的FontStyles之一传递参数。

In looking at the constructors for the System.Drawing.Font class there is a parameter to pass in one of the FontStyles defined in the System.Drawing.FontStyle enum.

IE浏览器。
    胆大
    斜体
    定期
    下划线

ie. Bold Italic Regular Underline

和存在的实例化对象粗体,斜体,下划线等布尔属性,但它们是只读的。

and there are boolean properties for Bold, Italic, Underline etc. in the instantiated object, but they are read only.

如果我想定义我的字体有多种样式,比如粗体,下划线,怎么办?

What if I want to define my font to have multiple styles like Bold and Underline?

我怎样才能做到这一点?

How can I do this?

推荐答案

fontstyle的枚举是一个标记枚举。这意味着,它的成员是两个一切权力,允许你使用二进制或将它们结合起来。

The FontStyle enum is a Flags enum. This means that its members are all powers of two, allowing you to combine them using a binary OR.

例如,如果你想大胆和下划线,你会通过

For example, if you want bold and underline, you'd pass

FontStyle.Bold | FontStyle.Underline

竖线( | )是二进制或运营商

这篇关于如何实例化一个字体时设置多个FontStyles?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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