Skip to content
VIDEOMONTAZHERDAVINCI RESOLVE · VIDEO · AI

FUSION · Expressions

Text, counters and formatting

Text, string.format, numeric rounding and the limits of operations on Cyrillic strings.

Fusion / DaVinci Resolve 20–21

After this lesson

  • Convert a numeric result to text.
  • Control leading zeros and rounding.
  • Distinguish frame counters, timecode and real clocks.

Before you start

Composition
A separate Fusion Composition. 1920×1080, square pixels, 25 fps.
Parameter
Text1 → Styled Text
Range
Start at comp.RenderStart. Reference frames are local unless stated otherwise.

A text expression must return text. It can display numbers, percentages and timers while keeping Text+ styling. Recalculating content is different from character animation.

Turning a number into text

Text(string.format("%03d", 12)) returns 012. %d means integer; 03 means a minimum width padded with zeros. Use a format such as %.1f for decimals. Define rounding before integer formatting.

math.floor rounds down. For a non-negative value, round to nearest using math.floor(value+0.5). Check the behavior before applying this to negative numbers.

Frame and second counters

The formula below displays the local frame number. For elapsed whole seconds at 25 fps, divide the time offset by 25 before applying floor.

SIMPLE EXPRESSION · FUSION
Text(string.format("%03d", math.floor(math.max(0, time - comp.RenderStart))))

Strings and Cyrillic text

Lua concatenates with .., for example "Frame " .. string.format("%03d", 12). Do not use JavaScript backtick templates.

Basic Lua string operations work on bytes. Cutting a Cyrillic string one byte at a time with string.sub can corrupt UTF-8. Use Write On or Follower for character reveals instead of manual byte slicing.

Styling and purpose

Unequal digit widths can make a timer jump visually. Choose a font with suitable digits and check alignment. A text counter of seconds is not automatically SMPTE timecode or the camera’s source timecode.

What %03d means

In string.format, %03d requests an integer at least three characters wide, padded with leading zeros. 9 gives 009, 100 gives 100 and 1000 gives 1000: the width is a minimum, not a maximum. Apply floor first to make integer rounding explicit.

The outer Text constructs the Styled Text result. Remove formatting to check the number itself, then restore leading zeros. Keep units next to labels: frame for a local frame number, s for seconds. Frame 100 in a 25 fps project does not mean 100 seconds.

Why digits jump even with a correct formula

Different glyph widths for 1 and 8 can create horizontal jitter. Leading zeros preserve the character count, but not the total width in a proportional font. Choose tabular digits or a suitable monospaced font and lock the alignment.

For a percentage counter, define the range, such as 0…100, before choosing rounding. Ordinary rounding can display 100% before the actual end; floor holds 99 until progress reaches one. This is a design decision: keep it consistent with a progress bar showing the same value.

Parameters and ranges

ParameterWhat it changesExample / check
Text(…)A text result for Styled Text.Not used for numeric Size.
string.format("%03d", n)An integer with at least three digits.9 → 009; 1000 is not truncated.
math.floor(…)Rounds down.For timers, apply it after converting frames to seconds.
time−comp.RenderStartLocal counter.Starts at zero regardless of the absolute start.

USE IN A COMPOSITION

Build it in Fusion

Text1 → Styled Text

FUSION / FLOWNodes and parameter control
100%
ImageControl in the InspectorScroll or drag the graph. Choose “Fit” to see all of it.
Solid lines are node connections in the Flow. A dashed line is a parameter dependency configured in the Inspector. A solid arrow's color matches its destination input. Modifiers are shown separately from the Flow.control.Value → Text1.Styled TextText1.Output → MediaOut1.InputText(string.format) · Expression · InspectorEXPRESSIONText(string.format)Simple ExpressionText1 · Image node · FlowT+Text1Text+Styled TextStyled Text · an Inspector parameter, not an image portMediaOut1 · Image node · Flow↗MediaOut1MediaOut
Parameter · InspectorImage
Select a node or a colored arrow

Solid lines are node connections in the Flow. A dashed line is a parameter dependency configured in the Inspector.

Connections by port and parameter2

Color is determined by the destination input. Dashed connections are configured in the Inspector; they do not add an RGBA wire to the Flow.

Assembly steps

  1. Create Text+.
  2. Enable Expression on Styled Text.
  3. Paste the frame-counter formula.
  4. Check the start, frame 9 and frame 100; adjust alignment.
SIMPLE EXPRESSION · FUSION
Text(string.format("%03d", math.floor(math.max(0, time - comp.RenderStart))))

Expected result. The counter shows 000, 009 and 100. Values beyond 999 are not truncated because the format specifies a minimum width.

Checkpoints

When / what to checkExpectedWhy check it
Local 0000Initial format.
9009Leading zeros.
100100The third digit is occupied.
10001000No maximum width restriction.

INTERACTIVE EXAMPLE

Change a parameter. Compare the result.

EXPRESSION · INTERACTIVE EXAMPLE

The frame number becomes text

CONTROLLED PARAMETERText1 → Styled Text
0 f← → one frame at a time25 fps
VALUE GRAPH
Local frame
-14460013440 f600 f1200 f
Select a point on the graph to go to that frame. Values are checked throughout the range.

The local frame is rounded down and written with at least three digits. Zeros pad a short number without truncating a longer one.

TEXT IN STYLED TEXT009
CHECK THE ORIGINAL EXAMPLE

Frames 0, 9, 100 and 1000 produce 000, 009, 100 and 1000. This counts frames, not seconds.

Formula for the current settings +
Text1 → Styled Text
Text(string.format("%03d", math.floor(math.max(0, time - comp.RenderStart))))

The browser reproduces the numeric core and formatting result. Text and string.format run in Fusion after you paste the formula.

Errors and troubleshooting

Cyrillic letters turn into corrupted characters

Do not slice UTF-8 byte by byte. Use the built-in character-animation tools.

The counter shows fractions

Round explicitly and choose an integer format.

Independent exercise

Display elapsed seconds with one decimal place at 25 fps.

Show the solution and explanation

Text(string.format("%.1f", math.max(0,time-comp.RenderStart)/25)). Numeric literals inside the formula still use a decimal point.

Continue learning

Official sources

Blackmagic Design · Fusion Reference ManualThe chapter “Using Modifiers, Expressions, and Custom Controls”. Page numbers depend on the PDF edition.
Blackmagic Design · Text+ and text modifiersGenerator Nodes → Text+: Follower, Character Level Styling, Text Timer and Time Code.
Lua 5.1 Reference ManualSyntax, mathematical functions and strings. Fusion adds its own objects and functions; the full scripting environment is not available.

An original educational walkthrough. The browser model explains the principle but does not run Fusion. Control placement depends on the version; save the original composition before replacing a parameter's control source.