Skip to Content
Welcome to Diffusion Studio Core v4.0 - Now Available! šŸŽ‰

Text Clips

The following example demonstrates how to style text clips:

import * as core from '@diffusionstudio/core'; const thin = await core.loadFont({ family: 'Geologica', weight: '300', size: 19 }); const bold = await core.loadFont({ family: 'Geologica', weight: '700', size: 24 }); await composition.add( new core.TextClip({ text: "The quick\nbrown fox jumps over the lazy dog.", align: 'center', baseline: 'middle', font: bold, maxWidth: '40%', leading: 1.3, glow: { intensity: 1, color: '#000000', radius: 10, opacity: 100, }, strokes: [{ width: 5, color: '#000000', lineJoin: 'round', lineCap: 'round', miterLimit: 4, }], shadows: [ { offsetX: 4, offsetY: 5, blur: 20, color: '#000000', opacity: 100, }, { offsetX: -8, offsetY: -4, blur: 20, color: '#FFFFFF', opacity: 90, }, ], x: '50%', y: '50%', styles: [{ start: 0, stop: 9, style: { font: thin, color: '#0000FF', casing: 'upper', } }] }) );

With the styles property, you can define the styles you want to override for specific sections of the TextClip.


We have loaded the web font from a predefined set of popular web fonts. You can also use custom web fonts like this:

const roboto = await core.loadFont({ source: "https://fonts.gstatic.com/s/roboto/v32/KFOlCnqEu92Fr1MmSU5fBBc4AMP6lQ.woff2", weight: '400', family: 'Roboto' });

or local fonts (in Chrome):

const localFonts = await core.getLocalFonts(); console.log(localFonts); const font = await core.loadFont(localFonts[0].variants[0]);

to get all loaded fonts you can use:

const loadedFonts = await core.getLoadedFonts(); // JSON serializable array

and to restore loaded fonts, call:

await core.restoreFonts(loadedFonts);
Last updated on