How do I use custom fonts in Function Compute?
Function Compute runtimes include a set of common system fonts. When those fonts don't cover your requirements, you can bundle custom .ttf font files directly in your function code and configure the runtime to load them.
Prerequisites
Before you begin, ensure that you have:
A Function Compute function. See the "Create a function" section in Manage functions.
The Python sample code downloaded and extracted. This example uses a Python runtime.
Install a custom font
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click the function you want to configure.
On the function details page, click Upload Code, select an upload method, and upload the sample code. After the upload, your code directory contains the following files:
Tangerine-xxx.ttfis the example custom font. Replace it with your own.ttffont files as needed./code ├── fonts.conf # Font configuration file └── Tangerine-xxx.ttf # Custom font file (.ttf format)
On the function details page, configure
fonts.confas an environment variable for the function. This enables the runtime to locate and load fonts from your custom font directory.Invoke the function and check the response. If the output includes
style=Regularandstyle=Bold, the fonts are loaded successfully.