Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6859197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:15:11+00:00 2026-05-27T02:15:11+00:00

I,m using a font dialog to select a font and create a font from

  • 0

I,m using a font dialog to select a font and create a font from the selected font using

font = new Font(fontDialog1.Font.Name, fontDialog1.Font.Size, FontStyle.Regular, GraphicsUnit.Pixel);

When i Select a Non True type font I’m getting an ‘This is not a TrueType font’ Exception,I know GDI+ has support only for TTF.I’ve worked around this by using a try catch block.But how can i configure the font dialog to show only TTF’s.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:15:11+00:00Added an answer on May 27, 2026 at 2:15 am

    I don’t think there is a solution to this issue (as stated by numerous others articles on the web), but you can rewrite the FontDialog somehow to fit your need.

    To get you started, here is the implementation of a FontListBox that displays an owner draw listbox with fonts rendered in it:

    enter image description here

    Sample dialog that hosts it:

    public partial class MyFontDialog : Form
    {
        private FontListBox _fontListBox;
    
        public MyFontDialog()
        {
            InitializeComponent();
    
            _fontListBox = new FontListBox();
            _fontListBox.Dock = DockStyle.Fill;
            Controls.Add(_fontListBox);
        }
    }
    

    The list box:

    public class FontListBox : ListBox
    {
        private List<Font> _fonts = new List<Font>();
        private Brush _foreBrush;
    
        public FontListBox()
        {
            DrawMode = DrawMode.OwnerDrawFixed;
            ItemHeight = 20;
            foreach (FontFamily ff in FontFamily.Families)
            {
                // determine the first available style, as all fonts don't support all styles
                FontStyle? availableStyle = null;
                foreach (FontStyle style in Enum.GetValues(typeof(FontStyle)))
                {
                    if (ff.IsStyleAvailable(style))
                    {
                        availableStyle = style;
                        break;
                    }
                }
    
                if (availableStyle.HasValue)
                {
                    Font font = null;
                    try
                    {
                        // do your own Font initialization here
                        // discard the one you don't like :-)
                        font = new Font(ff, 12, availableStyle.Value);
                    }
                    catch
                    {
                    }
                    if (font != null)
                    {
                        _fonts.Add(font);
                        Items.Add(font);
                    }
                }
            }
        }
    
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (_fonts != null)
            {
                foreach (Font font in _fonts)
                {
                    font.Dispose();
                }
                _fonts = null;
            }
            if (_foreBrush != null)
            {
                _foreBrush.Dispose();
                _foreBrush = null;
            }
        }
    
        public override Color ForeColor
        {
            get
            {
                return base.ForeColor;
            }
            set
            {
                base.ForeColor = value;
                if (_foreBrush != null)
                {
                    _foreBrush.Dispose();
                }
                _foreBrush = null;
            }
        }
    
        private Brush ForeBrush
        {
            get
            {
                if (_foreBrush == null)
                {
                    _foreBrush = new SolidBrush(ForeColor);
                }
                return _foreBrush;
            }
        }
    
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);
            if (e.Index < 0)
                return;
    
            e.DrawBackground();
            e.DrawFocusRectangle();
            Rectangle bounds = e.Bounds;
            Font font = (Font)Items[e.Index];
            e.Graphics.DrawString(font.Name, font, ForeBrush, bounds.Left, bounds.Top);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code block to get the font name, style and size selected
Using the CSS font-size property, one can specify the size as a percentage. What
I want to display font dialog box in my web application(asp.net). Im using the
I want to use a pixel font on the web. I'm including it using
Can anyone tell me how I can change the font using a font dialog.
I just started using @font-face This is on top of my css @font-face {
Anyone have an example snippet showing how to scale a Font using AffineTransform? Thanks.
I'm having issues with my SQL Reporting Services reports. I'm using a custom font
I want to change the font I am using in a CEikLabel on S60
I'm using an external swf containing a number of font classes to load and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.