scistag.emojistag.emoji_renderer.EmojiRenderer¶
- class EmojiRenderer[source]¶
Bases:
objectRenders an emoji by either rendering an SVG or resizing a pre-rendered PNG from the Noto Emoji database.
Methods
Returns if SVG rendering is supported tne SVG repo installed
Tries to read an emoji and render it to a transparent image
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
- classmethod get_svg_support()[source]¶
Returns if SVG rendering is supported tne SVG repo installed
- Return type
- Returns
True if high quality rendering is possible
- classmethod render_emoji(identifier, size=None, width=None, height=None, bg_color=None, quality=90)[source]¶
Tries to read an emoji and render it to a transparent image
- Parameters
identifier (str | list[str]) – The emoji’s markdown identifier such as :deer:, the official unicode name such as “deer”, the unicode sequence, e.g. [“u1f98c”] for a stag or just the emoji as single character.
size (int | None | Size2DTypes) – The size in pixels in which the emoji shall be rendered. By default the original Noto Emoji data set will be used providing the Emojis in a 136x128 resolution.
width (float) – The desired emoji width. The height will be computed automatically.
height (float) – The desired emoji height. The width will be computed automatically.
bg_color (ColorTypes | None) – The color with which the background of the emoji shall be filled. By default the emoji will be a transparent RGBA image.
quality (int) –
The desired quality. By default the renderer will try to use pre-rendered PNGs if the requested emoji size is small (<=136x128). These images are slightly quantized. If you want to maximize the image quality at all costs, you can set this value to >90 to enforce SVG rendering.
This requires the SVG package to be installed.
See
python3 -m scistag.addonsfor details.If a very small value is passed (<50) SVG rendering will never be used.
- Return type
Image | None
- Returns
The SVG data on success, otherwise None