The Font class represents a font object used by GUI controls and drawing surfaces.
A Font inherits from CustomFont, CanvasHelper, and Object. Font objects can be created with createFont and can also be accessed through properties such as Control.Font or Canvas.Font.
Inheritance
| Class
|
Inherits From
|
Description
|
| Font
|
CustomFont
|
Represents a configurable font object.
|
| CustomFont
|
CanvasHelper
|
Base class for font handling.
|
| CanvasHelper
|
Object
|
Base class for canvas-related helper objects.
|
Related Function
function createFont() : Font
Returns a new Font object. The created font is initialized based on the main Cheat Engine window.
Properties
| Property
|
Type
|
Description
|
| Name
|
String
|
The font name.
|
| Size
|
Integer
|
The font size.
|
| Height
|
Integer
|
The font height.
|
| Orientation
|
Integer
|
The font orientation.
|
| Pitch
|
String
|
The font pitch. See Pitch Values.
|
| Color
|
Integer
|
The font color.
|
| CharSet
|
Integer
|
The font character set.
|
| Quality
|
String
|
The font quality. See Quality Values.
|
| Style
|
String set
|
The font style set. See Style Values.
|
Methods
| Method
|
Return Type
|
Description
|
| getName()
|
String
|
Gets the font name of the font.
|
| setName(name)
|
void
|
Sets the font name of the font.
|
| getSize()
|
Integer
|
Gets the size of the font.
|
| setSize(size)
|
void
|
Sets the size of the font.
|
| getColor()
|
Integer
|
Gets the color of the font.
|
| setColor(color)
|
void
|
Sets the color of the font.
|
| assign(font)
|
void
|
Copies the contents of the given font to this font.
|
Pitch Values
| Value
|
Description
|
| fpDefault
|
Default font pitch.
|
| fpVariable
|
Variable-width font pitch.
|
| fpFixed
|
Fixed-width font pitch.
|
Quality Values
| Value
|
Description
|
| fqDefault
|
Default font quality.
|
| fqDraft
|
Draft font quality.
|
| fqProof
|
Proof font quality.
|
| fqNonAntialiased
|
Non-antialiased font quality.
|
| fqAntialiased
|
Antialiased font quality.
|
| fqCleartype
|
ClearType font quality.
|
| fqCleartypeNatural
|
Natural ClearType font quality.
|
Style Values
| Value
|
Description
|
| fsBold
|
Bold text.
|
| fsItalic
|
Italic text.
|
| fsStrikeOut
|
Strikeout text.
|
| fsUnderline
|
Underlined text.
|
Examples
Create a Font object
1 local font = createFont()
2
3 print(font.Name)
Set font properties
1 local font = createFont()
2
3 font.Name = "Consolas"
4 font.Size = 12
5 font.Color = 0x0000FF
6 font.Style = "[fsBold]"
Use getter and setter methods
1 local font = createFont()
2
3 font.setName("Consolas")
4 font.setSize(14)
5
6 print(font.getName())
7 print(font.getSize())
Set font pitch and quality
1 local font = createFont()
2
3 font.Name = "Consolas"
4 font.Pitch = "fpFixed"
5 font.Quality = "fqCleartype"
Assign a font to a label
1 local form = createForm()
2 local label = createLabel(form)
3
4 local font = createFont()
5 font.Name = "Consolas"
6 font.Size = 14
7 font.Style = "[fsBold]"
8 font.Color = 0x0000FF
9
10 label.Font.assign(font)
11 label.Caption = "Styled label"
Copy one font to another
1 local sourceFont = createFont()
2 sourceFont.Name = "Consolas"
3 sourceFont.Size = 12
4 sourceFont.Style = "[fsBold]"
5 sourceFont.Color = 0x0000FF
6
7 local targetFont = createFont()
8 targetFont.assign(sourceFont)
9
10 print(targetFont.Name)
11 print(targetFont.Size)
12
13 sourceFont.destroy()
14 targetFont.destroy()
Use a font with Canvas text
1 local form = createForm()
2 form.Width = 300
3 form.Height = 160
4
5 form.OnPaint = function(sender)
6 local canvas = sender.Canvas
7
8 canvas.Font.Name = "Consolas"
9 canvas.Font.Size = 14
10 canvas.Font.Color = 0x0000FF
11 canvas.Font.Style = "[fsBold]"
12
13 canvas.textOut(20, 40, "Canvas text")
14 end
15
16 form.show()
Restore a control font
1 local oldFont = createFont()
2 oldFont.assign(MainForm.Font)
3
4 MainForm.Font.Name = "Consolas"
5 MainForm.Font.Size = 12
6 MainForm.Font.Style = "[fsBold]"
7
8 sleep(1000)
9
10 MainForm.Font.assign(oldFont)
11 oldFont.destroy()
Core Lua documentation entry points