Text

Font List

Fonts are defined in the animation object, under fonts.

When fonts is present in the Animation object, it has a single attribute called list, which is an array of font objects:

Attribute Type Description
ascent number

Text will be moved down based on this value

fFamily string

Font Family

fName string

Name used by text documents to reference this font, usually it's fFamily followed by fStyle

fStyle string

Font Style

fPath string

Path

fWeight string

Weight

origin Font Path Origin

Origin

fClass string

CSS Class applied to text objects using this font

To understand how to load fonts it's better to look at some examples so here follow various ways of adding a font into lottie. The tables show the JSON, its resulting output, then an equivalent font definition using CSS.

Using a system font

Here we use origin 0 (and we can omit it).

fFamily needs to be an available font family.

JSONLottie Output
{
    "fFamily": "monospace",
    "fName": "MyFont",
    "fStyle": "Regular"
}

CSSOutput
{
    font-family: monospace;
}
Hello

Font from CSS URL

Here we use origin 1.

JSONLottie Output
{
    "fPath": "https://fonts.googleapis.com/css2?family=Montserrat:wght@800&display=swap",
    "fFamily": "Poppins",
    "fStyle": "Bold",
    "fName": "Poppins Bold",
    "origin": 1
}

CSSOutput
 @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@700&display=swap');
or
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@700&amp;display=swap" rel="stylesheet">
Hello

Font from URL

Here we use origin 3.

JSONLottie Output
{
    "fPath": "https://fonts.gstatic.com/s/ubuntu/v15/4iCp6KVjbNBYlgoKejZftWyI.ttf",
    "fFamily": "Ubuntu",
    "fStyle": "Light Italic",
    "fName": "Ubuntu Light Italic",
    "origin": 3
}

CSSOutput
@font-face {
  font-family: 'Ubuntu';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/ubuntu/v15/4iCp6KVjbNBYlgoKejZftWyI.ttf) format('truetype');
}
Hello

Character Data

You can also have font data directly into the lottie, this is done by having an array of character data objects in the chars attribute of the animation.

Attribute Type Description
data Character Shape or Character Precomp

Defines how the character is defined

ch string

Character

fFamily string

Font Family

size number

Font Size

style string

Font Style

w number

Width

Character Shapes

Defines a character as shapes

Attribute Type Description
shapes Shape List

Shapes forming the character

Character Precomp

Defines a character as a precomp layer

Attribute Type Description
refId string

ID of the precomp as specified in the assets

ks Transform

Layer transform

ip number

Frame when the layer becomes visible

op number

Frame when the layer becomes invisible

sr number

Time Stretch

st number

Start Time

Text Layer

The text layer has an attribute called t containing a Text Animator Data object.

Text Data

Contains all the text data and animation

Attribute Type Description
a array of Text Range

Ranges

d Animated Text Document

Document

m Text Alignment Options

Alignment

p Text Follow Path

Follow Path

Animated Text Document

This object is similar to an animated property for text.

The main difference is that it's always treated as animated (ie: you must use keyframes).

Attribute Type Description
k array of Text Document Keyframe

Array of keyframes

x string

Expression

sid string

One of the ID in the file's slots

Text Document Keyframe

This is similar to the keyframe object used by animated properties, but it doesn't have any attribute specifying interpolation as text is always animated in discrete steps.

Attribute Type Description
s Text Document

Start

t number

Time

Text Document

This is where the actual text data is stored.

Attribute Type Description
f string

Font Family

fc Color

Fill Color

sc Color

Stroke Color

sw number

Stroke Width

of boolean

Render stroke above the fill

s number

Font Size

lh number

Distance between lines on multiline or wrapped text

sz array of number

Size of the box containing the text

ps array of number

Position of the box containing the text

t string

Text, note that newlines are encoded with \r

j Text Justify

Justify

ca Text Caps

Text Caps

tr number

Text Tracking

ls number

Baseline Shift

0
0
0
0
0
0
0
5
80
100

Text Alignment Options

Used to change the origin point for transformations, such as Rotation, that may be applied to the text string. The origin point for each character, word, or line can be changed.

Attribute Type Description
a Animated Vector

Group alignment

g Text Grouping

Anchor point grouping

Text Follow Path

Uses the path described by a layer mask to put the text on said path.

Attribute Type Description
m integer

Index of the mask to use

f Animated number

First Margin

l Animated number

Last Margin

r Animated number

Reverse Path

a Animated number

Force Alignment

p Animated number

Perpendicular To Path

Text Range

Range of text with custom animations and style

Attribute Type Description
nm string

Name

s Text Range Selector

Selector

a Text Style

Style

Selector
60
75
0
0
0
Transform
0
0
0
100
Style
0
0
0
0
0

Text Range Selector

Defines the range of characters to apply a property value only to a specific subset of the text document.

r Defines whether the values are defined as a percentage or indices.

The range is defined by s, e, and o.

ne and xe define what happes to text that is only partly inside the selected range.

b changes whether selection is done on per character basis, per word, etc. It also changes the meaning of an index when r is set to Indices.

Attribute Type Description
t 0-1 integer

Expressible

xe Animated number

Max Ease

ne Animated number

Min Ease

a Animated number

Max Amount

b Text Based

Based On

rn 0-1 integer

Randomize

sh Text Shape

Shape

o Animated number

Offset

r Text Range Units

Range Units

sm Animated number

Selector Smoothness

s Animated number

Start

e Animated number

End

60
75
0
0
0

Text Style

Has the properties of a transform and the style options of a text document.

It applies such transform and style to the part of the text defined by the text selector property

Also has the attributes from Transform.

Attribute Type Description
sw Animated number

Stroke Width

sc Animated Color

Stroke Color

sh Animated number

Stroke Hue

ss Animated number

Stroke Saturation

sb Animated number

Stroke Brightness

so Animated number

Stroke Opacity

fc Animated Color

Fill Color

fh Animated number

Fill Hue

fs Animated number

Fill Saturation

fb Animated number

Fill Brightness

fo Animated number

Fill Opacity

t Animated number

Letter Spacing

bl Animated number

Blur

ls Animated number

Line Spacing

Transform
0
0
0
100
Style
0
0
0
0
0