Click here to Skip to main content
15,900,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

how to get the weight from System.Drawing.FontDialog?
I can choose it in dialog window, but its not possible to read the value?
Posted

if it is related to WPF,check this
fontdialog[^]
 
Share this answer
 
Comments
Member 9246155 4-Jul-13 7:11am    
No, i'm using Windows Forms.
WPF is not possible.
Member 9246155 4-Jul-13 7:16am    
I need a value like im MFC: CFontDialog.GetWeight()
Naz_Firdouse 4-Jul-13 7:22am    
Wight in the sense what want to know whether it is bold or italic like this?
Member 9246155 4-Jul-13 7:45am    
Yes, i think its called 'font style'.
But it's not enough to know if bold or italic is true/false.
Some fonts can have more specific wight values, look here:
https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
MFC CFontDialog.GetWeight() returns a int value like 100, 200,...
Naz_Firdouse 4-Jul-13 7:51am    
I agree...
but using FontDialog, you can set only four values like Regular,Oblique,Bold,Bold Oblique...
In that case, how you can set the weight to lighter or bolder?
C#
private void button1_Click_1(object sender, EventArgs e)
       {
           FontDialog fontDialog1 = new FontDialog();
           // Show the dialog.
           DialogResult result = fontDialog1.ShowDialog();
           // See if OK was pressed.
           if (result == DialogResult.OK)
           {
               // Get Font.
               Font font = fontDialog1.Font;
               // Set TextBox properties.
               this.textBox1.Text = string.Format("Font is: {0} and style is: {1}", font.Name,font.Style);
               this.textBox1.Font = font;
           }
       }


Here font.Style shows the style you selected from FontDialog
 
Share this answer
 
Comments
Member 9246155 4-Jul-13 8:41am    
Yes, but only 'Regular' or 'Bold, Italic'.
Naz_Firdouse 4-Jul-13 9:12am    
what you need exactly??? Do you have an option to specify bolder,lighter or 100,200???
Member 9246155 4-Jul-13 10:02am    
My dialog is a standard- or default font dialog. I'm looking for a way to read all parameters (and set it later time from ini-file f.e.). Bolder, Lighter or 100,200 whatever.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900