python-lottie  0.6.10+dev2509936
A framework to work with lottie files and telegram animated stickers (tgs)
text_emoji_svg.py
1 #!/usr/bin/env python3
2 import sys
3 import os
4 sys.path.insert(0, os.path.join(
5  os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
6  "lib"
7 ))
8 from lottie.utils import script
9 from lottie import objects
10 from lottie import Color, Point
11 from lottie.utils.font import FontStyle
12 
13 parser = script.get_parser()
14 parser.add_argument("text", nargs="?", default="Hello\nWorld\nF\U0001F600O\nE🇪🇺U")
15 parser.add_argument("--emoji", default="twemoji/assets/svg/")
16 ns = parser.parse_args()
17 
18 an = objects.Animation(120)
19 layer = objects.ShapeLayer()
20 an.add_layer(layer)
21 
22 # The font name "Ubuntu" here, can be detected among the system fonts if fontconfig is available
23 # Otherwise you can use the full path to the font file
24 # `emoji_svg` needs to point to a directory with the supported emoji as svg
25 style = FontStyle("Ubuntu", 128, emoji_svg=ns.emoji)
26 t = layer.add_shape(style.render(ns.text))
27 t.transform.position.value.y += t.line_height
28 layer.add_shape(objects.Fill(Color(0, 0, 0)))
29 layer.add_shape(objects.Stroke(Color(1, 1, 1), 2))
30 
31 script.run(an, ns)
32 
lottie.utils.font
Definition: font.py:1
lottie.utils
Definition: __init__.py:1