Use a Google Font in mails with email-templates for NodeJS

11,243

Google Fonts Do Not Work With Gmail Or Outlook

Webfonts do not work in all email clients. They do not work with Gmail, Yahoo, Android clients and spotty support for Outlook 2007-2016. I know this sounds ridiculous, since Google has Google Fonts, but the current reality is that Gmail does not support Google Fonts.

You need to settle on a fallback font which is not Tillana or Open Sans, which is also a Google Font. In your case, the backup font for Gmail will be Arial.

Fonts supported by Gmail

These links will give you a better understanding of web fonts and how to use them in email.

Outlook Custom Fonts

Microsoft Outlook is frustrating. Outlook 2007-2016 will work sometimes with Google Fonts. It has a problem with web-safe fonts as well. If the font has a space in the name, it will revert to it's default font, Times-New Roman, which is frustrating because that font has a space in the name!

To make sure Outlook does not default to Times, add this just below your <style></style> block:

<!--[if (gte mso 9)|(IE)]><style type="text/css">
body, table, td, a, p {font-family: Arial, sans-serif !important; font-size: 12px; font-weight: 300;}
</style><![endif]-->

Add more html elements as needed to the list of body, table, td, etc. You can customize as you would with any other style sheet. Outlook should use your style sheet, but if it doesn't this usually forces it to work.

Good luck.

Share:
11,243
R3uK
Author by

R3uK

French engineer who need help sometimes and can provide some on VBA issues! #SOreadytohelp

Updated on June 15, 2022

Comments

  • R3uK
    R3uK almost 2 years

    I using NodeJS, with nodemailer, email-templates and ejs to send an invitation to my wedding guests.

    I've managed most issues, but I can't seem to manage a custom font and there is a lot all over the web about it...

    I think that this one is the most elaborate article that I've seen :

    So I've added this in the head tag :

    <link href='https://fonts.googleapis.com/css?family=Tillana' rel='stylesheet' type='text/css'>
    

    but this still doesn't display in the correct font in gmail, nor outlook (haven't tested yahoo and others)...

    <td align="center" valign="top" style="padding: 0; font-family: Tillana, Open Sans, Helvetica, Arial, sans-serif; color: #999999;">
        <p style="font-size: 14px; line-height: 20px;">
            Some text hopefully in Tillana
        </p>
    </td>
    

    I've seen in email-templates documentation that you can use an image rendering of the font with custom-fonts-in-emails, but it seems to be a bit of an overkill...

    Any suggestions on how to proceed to cover most cases ?

  • kehers
    kehers almost 6 years
    Gmail supports custom fonts. I have a Changelog newsletter with custom Roboto Mono font opened in my gmail as I write this.
  • gwally
    gwally about 5 years
    @kehers is correct. Roboto is one of the few Google fonts supported by default by Gmail. It does not require an @import to work. You do need a link for other email clients. jsfiddle.net/wallyglenn/g35nchmL