Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
286
fontdata, font and the fontdialog
posted

Hi!

I would like to start a fontDialog containing the columns Header Font like

 FontData f = DisplayLayout.Bands[0].Columns[0].Header.Appearance.FontData;

( All columns are alike)

I can read the fontdata properties from the column's Header Appearance object. What I am missing is , how can I create a font from fontdata ? I would like to set the font dialog to the fontdata setting.

A special fontdialog using fontdata input would of course also do it. Maybe I missed something in fontdata workings ?

 

best regards

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    luke_sky said:
    What I am missing is , how can I create a font from fontdata ?

    Create a Font instance from the relevant properties of the FontData struct.

    Example:
    string name = string.IsNullOrEmpty(fontData.Name) ? SystemFonts.DefaultFont.Name : fontData.Name;

    FontStyle style = FontStyle.Regular;
    if ( fontData.Bold == DefaultableBoolean.True )
        style |= FontStyle.Bold;

    if ( fontData.Italic == DefaultableBoolean.True )
        style |= FontStyle.Italic;

    if ( fontData.Strikeout == DefaultableBoolean.True )
        style |= FontStyle.Strikeout;

    if ( fontData.Underline == DefaultableBoolean.True )
        style |= FontStyle.Underline;

    float size = fontData.SizeInPoints > 0f ? fontData.SizeInPoints : SystemFonts.DefaultFont.SizeInPoints;

    Font font = new Font( name, size, style );

Children