This class is static and provides several font properties and methods. The most important font properties are presented first, which are used
Property | Type | Description |
---|---|---|
.Name | String | The font name is set or read → Font family |
.Size | Float | The font size is set or read absolutely → Font size |
.Grade | Integer | The font size can be set or read relative in the range -4 ≤ R ≤ +16 to the default size Size=9, corresponds to R= |
.Fixed | Boolean | It is only possible to read whether the characters have the same width. |
Table: 23.2.2.1 Description of selected font properties
Property | Type | Description |
---|---|---|
.Bold | Boolean | Bold font is switched on or off or it is determined whether bold font is switched on or not. |
.Italic | Boolean | Italic font is switched on or off or it is determined whether italic font is switched on or not. |
.Underline | Boolean | Switches on or off whether text is displayed underlined or determines whether the “underline” font style is switched on or not. |
.Strikeout | Boolean | It is switched on or off whether text is displayed with a strikeout or whether the “strikeout” font style is switched on or not. |
Table: 23.2.2.2 Description of the font styles
Defining font properties or changing them for a component or text in a drawing is always carried out in full. Specified font properties overwrite the default values. If specifications are missing, the corresponding default values apply.
1st variant:
TextArea1.Font.Name = "Verdana" TextArea1.Font.Size = 22 TextArea1.Font.Bold = TRUE TextArea1.Font.Italic = FALSE '-- Can also be omitted because default value TextArea1.Font.Underline = FALSE '-- Can also be omitted because default value
2nd variant:
The compact assignment TextArea1.Font = Font[“-3,Italic”] is therefore equivalent to:
TextArea1.Font.Name = "Sans Serif" '-- Standard TextArea1.Font.Size = 6 '-- Set to -3, standard size 9 is overwritten TextArea1.Font.Bold = FALSE '-- Standard TextArea1.Font.Italic = TRUE '-- The default value FALSE is overwritten TextArea1.Font.Underline = FALSE '-- Standard TextArea1.Font.StrikeOut = FALSE '-- Standard
Pay attention to the order of the entries in the font string Font[“Name, Size, Bold, Italic, Underline, Strikeout”] if you want to specify certain font properties:
3rd variant:
Use of the FontChooser control. You can find information on this control and a complete project in chapter 23.2.3.
Font properties of a control can be read out in compact form using the .ToString() method or in individual properties, for example:
Public Sub FontAuslesen() TextBox1.Text = TextArea1.Font.ToString() End
Note the data type of the property whose value is returned:
DIM sFontname As String DIM iFontSize As Float DIM bFontBold As Boolean sFontname = TextArea1.Font.Name iFontSize = TextArea1.Font.Size bFontBold = TextArea1.Font.Bold ...
Font styles cause a change in the display in a control element - here in a TextArea - and you can read these styles via the elements of the styles array:
DIM sElement AS Variant FOR EACH sElement IN TextArea1.Font.Styles PRINT sElement NEXT
Although you would expect it, the font colour is <uuuu>not a font property. For the TextArea1 control element, for example, the font colour 'red' is defined with TextArea1.Foreground = Color.Red.
Further information on colours - especially in connection with the Color class - can be found in chapter 23.1.1.
This class is static and only has one property that provides information about the number of installed fonts in the system.
DIM iFontCount AS Integer iFontCount = Fonts.Count
The names of all fonts can be read from the (virtual) compilation:
PUBLIC SUB Form_Open() DIM sFontName AS String cmbFonts.Clear() cmbFonts.ReadOnly = True For Each sFontName In Fonts cmbFonts.Add(sFontName) Next END