<< Click to Display Table of Contents >> Font (object) |
Access paths:
▪Application à Documents à Item à Selection à Font
▪Application à ActiveDocument à Selection à Font
1 Description
The Font object describes the character formatting of a text fragment. It is a child object of Selection and allows you to get and set all character attributes of the current selection.
2 Access to the object
Each open document has exactly one instance of the Font object. It is accessed through Document.Selection.Font:
' Assign the Arial font to the current selection
tm.ActiveDocument.Selection.Font.Name = "Arial"
3 Properties, objects, collections and methods
Properties:
▪Name (default property)
▪Size
▪Bold
▪Italic
▪Underline
▪StrikeThrough
▪Superscript
▪Subscript
▪AllCaps
▪SmallCaps
▪PreferredSmallCaps
▪Blink
▪Color
▪ColorIndex
▪BColor
▪BColorIndex
▪Spacing
▪Pitch
Objects:
▪Application → Application
▪Parent → Selection
Name (property)
Data type: String
Gets or sets the font name (as a string).
If multiple fonts are used inside the selection, an empty string will be returned.
Size (property)
Data type: Single
Gets or sets the font size in points (pt).
If multiple font sizes are used inside the selection, the constant smoUndefined (9,999,999) will be returned.
Example:
' Set the size of the selected text to 10.3 pt
tm.ActiveDocument.Selection.Font.Size = 10.3
Bold (property)
Data type: Long
Gets or sets the character formatting "Bold":
▪True: Bold on
▪False: Bold off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly bold and partly not.
Italic (property)
Data type: Long
Gets or sets the character formatting "Italic":
▪True: Italic on
▪False: Italic off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly italic and partly not.
Underline (property)
Data type: Long (TmUnderline)
Gets or sets the character formatting "Underline". The following values are allowed:
tmUnderlineNone = 0 ' off
tmUnderlineSingle = 1 ' single underline
tmUnderlineDouble = 2 ' double underline
tmUnderlineWords = 3 ' word underline
tmUnderlineWordsDouble = 4 ' double word underline
If you are reading this property and the selection is partly underlined and partly not, the constant smoUndefined will be returned.
StrikeThrough (property)
Data type: Long
Gets or sets the character formatting "Strikethrough":
▪True: Strikethrough on
▪False: Strikethrough off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly struck through and partly not.
Superscript (property)
Data type: Long
Gets or sets the character formatting "Superscript":
▪True: Superscript on
▪False: Superscript off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly superscripted and partly not.
Subscript (property)
Data type: Long
Gets or sets the character formatting "Subscript":
▪True: Subscript on
▪False: Subscript off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly subscripted and partly not.
AllCaps (property)
Data type: Long
Gets or sets the character formatting "All caps":
▪True: All caps on
▪False: All caps off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly in all caps and partly not.
SmallCaps (property)
Data type: Long
Gets or sets the character formatting "Small caps":
▪True: Small caps on
▪False: Small caps off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly in small caps and partly not.
PreferredSmallCaps (property)
Data type: Long
Gets or sets the character formatting "Small caps", but as opposed to the SmallCaps property, lets you choose the scaling factor. The value 0 turns small caps off, all other values represent the percentual scaling factor of the small capitals.
Example:
' Format the selected text in small capitals at 75% size
tm.ActiveDocument.Selection.Font.PreferredSmallCaps = 75
' Deactivate small caps again
tm.ActiveDocument.Selection.Font.PreferredSmallCaps = 0
Blink (property)
Data type: Long
Gets or sets the character formatting "Blink" (obsolete):
▪True: Blink on
▪False: Blink off
▪smoToggle (only when setting): The current state is reversed.
▪smoUndefined (only when reading): The selection is partly blinking and partly not.
Color (property)
Data type: Long (SmoColor)
Gets or sets the foreground color of text as a "BGR" value (Blue-Green-Red triplet). You can either provide an arbitrary value or use one of the pre-defined BGR color constants.
If the selection is formatted in different colors, the constant smoUndefined will be returned when you read this property.
ColorIndex (property)
Data type: Long (SmoColorIndex)
Gets or sets the foreground color of text using an index color. "Index colors" are the 16 standard colors of TextMaker, numbered from 0 for black to 15 for light gray. You may use the values shown in the Index colors table.
If the selection is formatted in different colors or in a color that is not an index color, the constant smoUndefined will be returned when you read this property.
Note: It is recommended to use the Color property (see above) instead of this one, since it is not limited to the 16 standard colors but enables you to access the entire BGR color palette.
BColor (property)
Data type: Long (SmoColor)
Gets or sets the background color of text as a "BGR" value (Blue-Green-Red triplet). You can either provide an arbitrary value or use one of the pre-defined BGR color constants.
If the selection is formatted in different colors, the constant smoUndefined will be returned when you read this property.
BColorIndex (property)
Data type: Long (SmoColorIndex)
Gets or sets the background color of text using an index color. "Index colors" are the 16 standard colors of TextMaker, numbered from -1 for transparent to 15 for light gray. You may use the values shown in the Index colors table.
If the selection is formatted in different colors or in a color that is not an index color, the constant smoUndefined will be returned when you read this property.
Note: It is recommended to use the BColor property (see above) instead of this one, since it is not limited to the standard colors but enables you to access the entire BGR color palette.
Spacing (property)
Data type: Long
Gets or sets the character spacing. The standard value is 100 (normal character spacing of 100%).
If you read this property and the selection is formatted in different character spacings, the constant smoUndefined will be returned.
Pitch (property)
Data type: Long
Gets or sets the character pitch. The standard value is 100 (normal character pitch of 100%).
If you read this property and the selection is formatted in different character pitches, the constant smoUndefined will be returned.
Note that some printers ignore changes to the character pitch for their internal fonts.
Application (pointer to object)
Data type: Object
Returns the Application object.
Parent (pointer to object)
Data type: Object
Returns the parent object, i.e. an object of the type Document.