Left alignment
Right alignment
Center alignment
class FT2(object)
A FreeType2 Wrapper class
Class Attributes: mono for EPD mode
monochrome drawing for EPD
bold style when drawing
def __init__(file: str,
render: FrameBuffer,
size: int = 16,
mono: bool = False,
bold: bool = False,
italic: bool = False) -> instance
Load font from file(.ttf, .pcf). Args: file: file path to load. render: an instance of framebuf.FrameBuffer which pixel() method will be called when drawString(). size: default size to draw text mono: true for loading as mono font for EPD bold: bold style to draw text italic: italic style to draw text Returns: return True if font was loaded Raises: Error - raises an exception
def unload()
Unload font and free resources.
def drawString(x: int,
y: int,
w: int = -1,
h: int = -1,
align: int = 0,
text: str = "",
size: int = 16) -> int
Draw text string. Args: x: x coordinate of text drawing box y: y coordinate of text drawing box w: width of text drawing box h: height of text drawing box align: alignment of text, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT text: text to draw size: optional size to draw text Return: next x coordinate after drawing
def getStringWidth(text: str) -> int
Get text width when drawing. Args: text: text for measurement Return: text width
def setSize(size: int)
Set font size to draw. Args: Size, to modify
def setColor(fg: int, bg: int)
Set the foreground and background color when monochrome mode Args: fg: foreground color bg: background color
def setRender(render: FrameBuffer)
Set font new render Args: render, new render to use
class Image(object)
def __init__(width: int,
height: int) -> instance
Args: width, height: container width and height when drawing
def load(self,
file: str,
mono: bool = False)
Load image from file(.png, .jpg). Args: file: file path to load mono: load as mono image for EPD Return: loaded image (width, height)
def draw(self,
render:framebuf.FrameBuffer,
x: int = 0,
y: int = 0,
unload: bool = True)
Render image at(render, x, y). Args: render: the container to rend, must be a FrameBuffer (derived) instance x, y: left-top position to draw unload: free image resources after drawing automatically.
def unload()
Unload image, free image resource
def setColor()
Set the foreground and background color when monochrome mode. Args: fg: foreground color bg: background color
'pydoc-markdown -I . -m efont --render-toc > efont.md' 2023/09/09