10

Have any way set font style ItalicUnderline or BoldItalicUnderline? enter image description here

Thanks

Shahdat
  • 5,343
  • 4
  • 37
  • 37

1 Answers1

17

XFontStyle is an enum type. You can use bitwise logic to combine values.

const XFontStyle ItalicUnderline = XFontStyle.Italic | XFontStyle.Underline ;

const XFontStyle BoldItalicUnderline = XFontStyle.Bold | XFontStyle.Italic | XFontStyle.Underline ;
H H
  • 263,252
  • 30
  • 330
  • 514
  • Seems strange (to me) to use OR rather than AND, but it works, thanks. – Bernhard Hofmann May 31 '13 at 15:05
  • @Henk: bitwise logic is not available for all enumerations. Flags attribute is required on the enum definition (which is ok for XFontStyle) – Koen Jul 29 '13 at 14:34
  • 1
    @BernhardHofmann: Don't confuse bitwise logic with boolean logic. Every bit in the value has a different meaning. The 1st bit defines bold, the 2nd bit defines italic, etc. The '|' (bitwise OR) combines values by applying the operator to each bit of the same index and if you want to combine binary values "1000" and "0100" you need to use OR to get "1100". Bitwise AND (&) would return "0000". – Koen Jul 29 '13 at 14:37
  • 2
    @Koen - sorry for the late response but `[Flags]` is irrelevant. It only affects `ToString()`. The essential part is a 1,2,4,8,16 numbering. – H H Jul 05 '14 at 06:33