|
-
Apr 14th, 2011, 12:02 AM
#1
Thread Starter
Addicted Member
How to Get Font Name and it's Own Styles.?
Hello.........
i have 2 Combo boxes[_cmbxFontName, _cmbxStyleName]
i can load all installed fonts into _cmbxFontName. but i could not load Fonts Style. if i select a Font Name in _cmbxFontName then the other _cmbxstyleName combo box wants to load it's Styles [Regular,Normal,Bold,Italic......].
i know all fonts has different styles but how can i found and load its....
Thanks.............
-
Apr 14th, 2011, 01:12 AM
#2
Thread Starter
Addicted Member
Re: How to Get Font Name and it's Own Styles.?
can anybody help........?
-
Apr 14th, 2011, 01:19 AM
#3
Re: How to Get Font Name and it's Own Styles.?
Hi,
You can try something like this:
vb Code:
Imports System.Drawing.Text
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim installed_fonts As New InstalledFontCollection
For Each font_family As FontFamily In _
installed_fonts.Families
ComboBox1.Items.Add(font_family.Name)
Next font_family
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox2.Font = New System.Drawing.Font(ComboBox1.SelectedItem.ToString, 25, FontStyle.Regular)
End Sub
End Class
-
Apr 14th, 2011, 01:29 AM
#4
Re: How to Get Font Name and it's Own Styles.?
There's no property or method that will give you the list you want. What you have to do is, once you've got a Font, get its FontFamily first and then call IsStyleAvailable on that for each FontStyle value. Note that you're going to have to call it for composite values as well as discrete, e.g
vb.net Code:
Dim availableStyles As List(Of FontStyle) If myFontFamily.IsStyleAvailable(FontStyle.Bold) Then availableStyles.Add(FontStyle.Bold) End If If myFontFamily.IsStyleAvailable(FontStyle.Italic) Then availableStyles.Add(FontStyle.Italic) End If If myFontFamily.IsStyleAvailable(FontStyle.Bold Or FontStyle.Italic) Then availableStyles.Add(FontStyle.Bold Or FontStyle.Italic) End If
You can make it nicer than that but you get the idea.
-
Apr 14th, 2011, 01:30 AM
#5
Thread Starter
Addicted Member
Re: How to Get Font Name and it's Own Styles.?
 Originally Posted by sparrow1
Hi,
You can try something like this:
vb Code:
Imports System.Drawing.Text
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim installed_fonts As New InstalledFontCollection
For Each font_family As FontFamily In _
installed_fonts.Families
ComboBox1.Items.Add(font_family.Name)
Next font_family
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox2.Font = New System.Drawing.Font(ComboBox1.SelectedItem.ToString, 25, FontStyle.Regular)
End Sub
End Class
Thanks For your Help Sparrow.......
-
Apr 14th, 2011, 01:33 AM
#6
Thread Starter
Addicted Member
Re: How to Get Font Name and it's Own Styles.?
 Originally Posted by jmcilhinney
There's no property or method that will give you the list you want. What you have to do is, once you've got a Font, get its FontFamily first and then call IsStyleAvailable on that for each FontStyle value. Note that you're going to have to call it for composite values as well as discrete, e.g
vb.net Code:
Dim availableStyles As List(Of FontStyle)
If myFontFamily.IsStyleAvailable(FontStyle.Bold) Then
availableStyles.Add(FontStyle.Bold)
End If
If myFontFamily.IsStyleAvailable(FontStyle.Italic) Then
availableStyles.Add(FontStyle.Italic)
End If
If myFontFamily.IsStyleAvailable(FontStyle.Bold Or FontStyle.Italic) Then
availableStyles.Add(FontStyle.Bold Or FontStyle.Italic)
End If
You can make it nicer than that but you get the idea.
Yes..!..Yes..! this is i am expecting one .......
but different fonts has different Styles Name ...
how can i find that Mr.jmcilhinney
-
Apr 14th, 2011, 01:33 AM
#7
Re: How to Get Font Name and it's Own Styles.?
I think sparrow1 has misinterpreted the question, or else I have. sparrow1's code will display the name of a font in that font, which I don't think is what you're getting at. You want a list of styles that can be selected for the selected font, right?
-
Apr 14th, 2011, 01:33 AM
#8
Re: How to Get Font Name and it's Own Styles.?
 Originally Posted by medsont
Yes..!..Yes..! this is i am expecting one ....... 
but different fonts has different Styles Name ...
how can i find that Mr.jmcilhinney
I just told you how.
-
Apr 14th, 2011, 01:36 AM
#9
Thread Starter
Addicted Member
Re: How to Get Font Name and it's Own Styles.?
In Photoshop has that option

Uploaded with ImageShack.us
-
Apr 14th, 2011, 01:40 AM
#10
Thread Starter
Addicted Member
Re: How to Get Font Name and it's Own Styles.?
 Originally Posted by jmcilhinney
I think sparrow1 has misinterpreted the question, or else I have. sparrow1's code will display the name of a font in that font, which I don't think is what you're getting at. You want a list of styles that can be selected for the selected font, right?
Yes i know that but i say Thanks for him bcz he spend his time for my questions thats all.
-
Apr 14th, 2011, 01:50 AM
#11
Re: How to Get Font Name and it's Own Styles.?
 Originally Posted by medsont
Yes i know that but i say Thanks for him bcz he spend his time for my questions thats all. 
I wasn't suggesting that you shouldn't thank someone who made an effort on your behalf. I was just trying to make a clear statement of the problem so I, and others, could be sure of exactly what it was.
We don't need an image. We have a clear statement of the problem and I've provided a solution. What exactly is your issue now? Have you done what I suggested? If not, why not? If so, did it work? If not, what exactly did you do and what exactly happened?
-
Apr 14th, 2011, 02:29 AM
#12
Re: How to Get Font Name and it's Own Styles.?
Actually, looking at that image, that is not the same information that you get using the Font and related classes in Windows Forms. If you use the FontFamily.Families property, you get Arial, Arial Black and Arial Narrow as three different families and the number of styles is limited to the five provided by the FontStyle enumeration. If you want to see the information in that image, I think that you'd probably have to do so using the Windows API. I couldn't tell you how.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|