Learn how to load in Google Fonts and use them in your images.
How it works
The API supports all Google Fonts. To use them, you must specify the fonts you would like loaded via the google_fonts parameter when creating your image.
To load a single font, set the parameter to the font name: google_fonts=Roboto. And then set the font family in your CSS: font-family: 'Roboto';. On render, the API will load the font and use it for creating your image.
Multiple fonts must be delimited by the | character: google_fonts=Open Sans|Roboto|Montserrat
Fonts and rendering speed
A large number of custom fonts can slow down initial render time. Only include the fonts you use.
Example
This image was rendered using multiple Google Fonts. Here was passed google_fonts=Montserrat|Roboto. And then referenced them in the CSS.
HTML
<div class="box">
<h1>Hello world! ๐ /h1>
<p>Just getting started with the HTML/CSS to Image <code>API</code>.</p>
</div>
<div class="box fancy-font gradient">
<h1>Fancy font + Gradient + Emoji ๐</h1>
</div>
The API supports loading in any type of web font. You can do this by including your font in your HTML with a normal link tag. It will get loaded in at render like a normal webpage.
Handling flash of unstyled text (FOUT)
If you are seeing intermittent issues with your font rendering, itโs possible that the image is being rendered before the font has updated the text.
To fix this, you can use the ms_delay parameter to adjust how long the API lets the HTML render before creating the image. Start with a low value, such as 500 and increase from there until your image generates reliably.
Need help?
Talk to a human. Please email us support@htmlcsstoimage.com with any questions and weโll gladly help you get started.