Link to home
Start Free TrialLog in
Avatar of korky
korky

asked on

FONT

How can I retreive what size a font supports?
Avatar of korky
korky

ASKER

Edited text of question.
i am not understanding you.. but try something like this?

control.fontsize = 12

label1.Font = "Times New Roman"
label1.FontSize = 10
i meant control = text1, label1, etc.
Avatar of korky

ASKER

What I mean is:
When I, for exemple in WordPad want to change the fontsize of a selected word, I am proposed a list of available size. System has only one size: 10 when Times New Roman has from 8 to 72...
What I am lookink for is a way to get that list.
try to give you a comment.

get any control from the toolbox on the form. click one time on that control so it brings the property window. click on the font. you will see the list of the fontsize.
Avatar of korky

ASKER

You still don't get it I want to get the list to show it to my users so they can format their text in a rich edit control.
oh ok.. i am sorry for misunderstanding your problem. any comments/suggestions for korky.

all the best.
Most Fonts are True-Type fonts. Basically it means that they are scaleable. So any size is OK within the range up to 2160. A practical limit is 8 to 72 points like Word or Excel. You can use the TextWidth function to see what sizes will cause a change in the width of the text. There may be some differences based on the object (Picture1, Screen or Printer).

    Dim I As Integer
    For I = 0 To Screen.FontCount - 1
        Picture1.Font = Screen.Fonts(I)
        Debug.Print Picture1.Font, Picture1.FontSize
        z = Picture1.TextWidth("X")
        For x = 7 To 72
            Picture1.FontSize = x
            If Picture1.TextWidth("X") <> z Then
                Debug.Print Picture1.FontSize
                z = Picture1.TextWidth("X")
            End If
        Next x
    Next I
Avatar of korky

ASKER

That's not really what I'm looking for... But thanks for your time.
I know the list exists but don't know how to make it work...
Tell me more about this list?
Avatar of korky

ASKER

Take a look at wordpad:
- Write Something
- Select it
- Change the font to system
- And take a look at the font size combo...
The only proposed size is 10. On the other hand if you had chosen Times New Roman you would have found list from 8 to 72 font size combo.
That list is what I am looking for.
Hi! This(the program below) is not very practical...but you can modify it.
I display the list of font size in a text box(text1) with multiline=true. You can change
this into combo box or whatever you want.

Dim info(100) As Integer
lfcr = Chr(13) + Chr(10)

Text1.Font.size = 1
info(0) = Text1.Font.size
For i = 2 To 100 Step 1
    Text1.Font.size = i
    info(i) = Text1.Font.size
    If info(i) <> info(i - 1) Then
        size = size + Str(info(i)) + lfcr
    End If
Next
Text1.Font.size = 1
Text1.Text = size

End Sub
See http://www.vietnam411.com/Computer_Tips/vbasic/0019.html

There's a function to Enum Fonts.
Avatar of korky

ASKER

This was very nice but not really what I was looking for...
For "system" I get:
 10
 20
 29
 39
 49
 58
 68
 78
While all I should get should be: 10


ASKER CERTIFIED SOLUTION
Avatar of Lewy
Lewy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial