Text functionalities¶
- class turtlethread.text.LetterDrawer(turtle, load_common_fonts: bool = False)[source]¶
- draw_letter_gap(fontsize=None, letter_gap=None)[source]¶
Draws a gap between two letters.
Parameters¶
- fontsizeint (optional)
The font size to take this letter gap to represent. Defaults to the previous font size in draw_one_letter or draw_string.
- letter_gapfloat (optional)
The letter gap scale factor. defaults to LetterDrawer.letter_gap (which defaults to -0.1)
- draw_one_letter(fontname, lettername, fontsize=120, colour='#000000', thickness=1, fill=False, outline=True, fill_min_y_dist: int = 10, fill_min_x_dist=10, full_fill=True, outline_satin_thickness=None, turtle=None, flip_y=False)[source]¶
This function draws a single letter.
Parameters¶
- fontnamestr
Specify a font name (from the loaded fonts)
- letternamestr
Specify the name of a letter. Spaces should be called ‘space’ and not ‘ ‘.
- fontsizeint (optional, default=20)
Specify the font size used to draw the text.
- fillbool (optional, default=False)
Specify whether or not the text should be filled.
- full_fillbool (optional, default=True)
Specify whether the text should be filled with
full_fillorpartial_fill(only used iffill=True). Note thatfull_fillcan have bugs at small font sizes (120 is considered small), whilepartial_fillmight cross over the boundaries of the text.- outlinebool (optional, default=True)
Specify whether the text should be outlined (it is recommended to outline when not filling or using
`partial_fill`, but not`full_fill`).- outline_satin_thicknessint, optional, can be None
If not None, the SVG’s lines will use satin stitch rather than direct stitch
- flip_ybool (optional, default=False)
Allow you to vertically flip the text if desired. Defaults to
False.- fill_min_x_distint (optional, default=10)
Advanced parameter deciding the resolution of
partial_fill. Ifpartial_fillis taking too long, consider increasing this value to make it run faster, at the cost of a lower resolution of fill. Default value is 10, and this should never be set below 5.- fill_min_y_distint (optional, default=10)
Advanced parameter deciding the resolution of
partial_fill. Ifpartial_fillis taking too long, consider increasing this value to make it run faster, at the cost of a lower resolution of fill. Default value is 10, and this should never be set below 5.
- draw_string(fontname, string, fontsize, colours='#000000', thicknesses=1, fills=False, outlines=True, fill_min_y_dist=10, fill_min_x_dist=10, full_fill=True, outline_satin_thickness=None, letter_gaps=None, turtle=None, flip_y=False)[source]¶
This function draws a string of letters.
Parameters¶
- fontnamestr
Specify a font name (from the loaded fonts)
- letternamestr
Specify the name of a letter. Spaces should be called ‘space’ and not ‘ ‘.
- fontsizeint (optional, default=20)
Specify the font size used to draw the text.
- fillsbool/list[bool] (optional, default=False)
Specify whether or not the text should be filled. Also accepts a list with one element per letter in the string.
- full_fillbool (optional, default=True)
Specify whether the text should be filled with
full_fillorpartial_fill(only used iffill=True). Note thatfull_fillcan have bugs at small font sizes (120 is considered small), whilepartial_fillmight cross over the boundaries of the text.- outlinesbool/list[bool] (optional, default=True)
Specify whether the text should be outlined (it is recommended to outline when not filling or using
`partial_fill`, but not`full_fill`). Also accepts a list with one element per letter in the string.- outline_satin_thicknessint, optional, can be None
If not None, the SVG’s lines will use satin stitch rather than direct stitch
- flip_ybool (optional, default=False)
Allow you to vertically flip the text if desired. Defaults to
False.- fill_min_x_distint (optional, default=10)
Advanced parameter deciding the resolution of
partial_fill. Ifpartial_fillis taking too long, consider increasing this value to make it run faster, at the cost of a lower resolution of fill. Default value is 10, and this should never be set below 5.- fill_min_y_distint (optional, default=10)
Advanced parameter deciding the resolution of
partial_fill. Ifpartial_fillis taking too long, consider increasing this value to make it run faster, at the cost of a lower resolution of fill. Default value is 10, and this should never be set below 5.