Skip to main content

From Remote URL

VideoEditor SDK supports loading fonts from a remote URL, this can be a resource hosted by a video hosting provider or your own servers. Although the editor supports adding assets with remote URLs, we highly recommend that you manage the download of remote resources yourself, since this gives you more control over the whole process.

Download fonts#

We construct a remote URL pointing the remote resource hosting the font we want to add and create a download task. Upon successful download we save it to a temporary location after checking if a file already exists at that location and removing it if necessary.

Dispatch to main queue#

In order to keep the UI responsive and prevent race conditions while the filter files are downloading, we dispatch to the main queue. Here, we keep track of the finished download task and the local URL of the downloaded font by writing to a localURL variable.

Create Font object#

Now that our custom font has finished downloading, we can pass the localURL to the Font constructor. A Font object is a simple collection of the metadata of a font, the fontName, the displayName and the url for non system fonts. We also create another system font using only the fontName.

Add fonts to asset catalog#

In order to add the new fonts to our asset catalog, we first add the default items and then append our fonts to the fonts array.