Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub
TextFont Class Reference

The TextFont class provides text drawing. More...

Public Member Functions

def __init__ (self, height=16)
 Creates a new font. More...
 
def __del__ (self)
 Releases font context.
 
bool Resize (self, int height)
 Sets new size (height) to font. More...
 
int Height (self)
 Gets current font height. More...
 
[int, int] Measure (self, str text)
 Measures size of region which need to draw a text with using of current font. More...
 
def Draw (self, Image canvas, str text, position, array.array('B') color, background=None)
 Measures size of region which need to draw a text with using of current font. More...
 

Detailed Description

The TextFont class provides text drawing.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  height = 16 
)

Creates a new font.

Parameters
height- a height of created font. Ith default value is 16.

Member Function Documentation

◆ Resize()

bool Resize (   self,
int  height 
)

Sets new size (height) to font.

Parameters
height- a new font height.
Returns
True if resize operation is OK.

◆ Height()

int Height (   self)

Gets current font height.

Returns
height of the font.

◆ Measure()

[int, int] Measure (   self,
str  text 
)

Measures size of region which need to draw a text with using of current font.

Parameters
text- a text which size need to measure.
Returns
size of region which need to draw current text with using of given font.

◆ Draw()

def Draw (   self,
Image  canvas,
str  text,
  position,
array.array('B')  color,
  background = None 
)

Measures size of region which need to draw a text with using of current font.

Parameters
canvas- a canvas (image where we draw text).
text- a text to draw.
position- a start position to draw text (coordinates or Simd.Position).
color- a foreground text color.
background- a background text color. By default it is equal to None.