scistag.imagestag.font.Font¶
- class Font(source, size, framework, index=0)[source]¶
Bases:
objectSDK independent font handle
Initializer :type source: str | bytes | BytesIO :param source: The font source. Either a file path, a bytes like object
or a stream
- Parameters
size (int) – The font’s size
framework (ImsFramework) – The framework to be used
index – The font face index
Methods
Returns the area in which this text will modify pixels, relative to pos 0,0.
Returns the low level font handle :rtype:
FreeTypeFont:return: The font handleReturns the text size in pixels
Returns the relative y starting offset for given vertical alignment type.
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
The framework being used to render the font
The font size in pixels as passed in the constructor when creating the font.
The maximum size of a character above the baseline (in pixels)
The maximum size of a character below the baseline (in pixels)
The real size of the font in pixels, assuming characters with large ascends such as German umlauts and descending characters.
Dictionary for converting a vertical alignment to a relative y starting offset
- get_covered_area(text, h_align=HTextAlignment.LEFT, v_align=VTextAlignment.TOP)[source]¶
Returns the area in which this text will modify pixels, relative to pos 0,0.
The bounding box defines the area of the printed text which is covered with pixels where the smallest y can be zero and the biggest y2 can be
ascend+descend.- Parameters
text (
str) – The text to be verifiedh_align (
Union[HTextAlignment,Literal[‘l’, ‘c’, ‘r’, ‘left’, ‘center’, ‘right’]]) – The horizontal text alignmentv_align (
Union[VTextAlignment,Literal[‘t’, ‘c’, ‘rc’, ‘b’, ‘bl’, ‘top’, ‘center’, ‘realCenter’, ‘bottom’, ‘baseLine’]]) – The vertical text alignment
- Return type
- Returns
The bbox (x,y,x2,y2)
- get_handle()[source]¶
Returns the low level font handle :rtype:
FreeTypeFont:return: The font handle
- get_y_offset(vert_alignment)[source]¶
Returns the relative y starting offset for given vertical alignment type.
- Param
vert_alignment: The vertical alignment
- Returns
The y shifting relative to a top-left starting point in pixels.
- _y_start_offsets¶
Dictionary for converting a vertical alignment to a relative y starting offset
- ascend¶
The maximum size of a character above the baseline (in pixels)
- descend¶
The maximum size of a character below the baseline (in pixels)
- framework¶
The framework being used to render the font
- row_height¶
The real size of the font in pixels, assuming characters with large ascends such as German umlauts and descending characters. This is the height a text printed with this font will cover at max.
- size¶
The font size in pixels as passed in the constructor when creating the font. Usually this defines (coarsely) the height of the font above the baseline.