tcutility.report package#
Submodules#
tcutility.report.character module#
- get_pixel_width(character, font='calibri', font_size=11)[source]#
Get the pixel width of a character for a given font and font-size. For this we need to interpolate the pixel width between two reference values. In the _char_widths.txt file you will find for each font a set of character pixel widths for font-size 1. We then simply multiply the 1-width value by the desired value to get the correct pixel width. See
- Parameters:
character (
str
) – the character to get the pixel width for.font (
str
) – the font family that is used.font_size (
float
) – the font-size to get the pixel width at.
- Return type:
float
- text_width(text, font='calibri', font_size=11, mode='pixels')[source]#
Get the width of a string for a given font and font size.
- Parameters:
text (
str
) – the object to determine the length for. Will be cast to a string before calculating width.font (
str
) – the font family that is used.font_size (
float
) – the font-size to get the pixel width at.mode (
str
) – the width-mode. Can be ‘excel’ or ‘pixels’.
- Return type:
float
- Returns:
The width of the text for a certain font and font size. If mode is ‘excel’ we pad it with 8 pixels and then divide by 7.6 (i.e. standard excel char width).