Skip to main content

Using Italic Fonts with Rich-Text and HTML5 Assets

P
Written by Peace Aisosa

The rich-text asset's font object does not currently accept a style (or similar) property for italic or oblique text. The font object only supports family, size, weight, color, opacity, stroke, and background.


Workaround: registering the italic face directly

Font family names in timeline.fonts[] are read from inside the font file itself (its internal nameID 1 record), not from anything in your JSON. This has an important consequence: if you register both the regular and italic files of the same typeface, they usually share the same internal family name, and referencing that family name will always resolve to the regular face. The italic file becomes unreachable, even though it's correctly registered.

The fix is to register only the italic font file for that family (leave the regular face out of timeline.fonts[] for that render) and reference it by its family name as normal. Because the regular face isn't competing for the same name, it binds correctly to the italic face:


JSON

"fonts": [
{ "src": "https://your-cdn.com/fonts/YourFont-Italic.ttf" }
]
"asset": {
"type": "rich-text",
"text": "Your italic text here",
"font": {
"family": "YourFont",
"size": 48
}
}


The constraint: this approach supports one face per family per render. If a single render needs both the regular and italic face of the same typeface, you'll need to make their internal family names distinct — for example, rewriting nameID 1 in the italic file to something like "Your Font Italic" using a tool like fonttools or FontForge, then hosting and registering that renamed file separately.
Once the names differ, both faces can be registered and referenced independently in the same render.



Alternative: the html5 asset

The html5 asset supports italic directly via standard CSS (font-style: italic), since it renders through a browser engine rather than the rich-text renderer. A few things to know before relying on it:

  • timeline.fonts[] does not apply to html5 assets. Remote @font-face URLs are blocked in the sandbox environment, so custom fonts need to be inlined as a base64 data: URI.

  • width and height are properties of the clip, not the asset, for html5.

  • Use html5 rather than the deprecated html asset — html mis-renders text that wraps onto a second line.

Did this answer your question?