在SendGrid中是否可以导入字体? 我一直在尝试使用@font-face,但似乎不起作用,也许是我做错了什么。
我使用的代码示例:
@font-face {
font-family: Avenir;
src: url('http://cdn.linktofont.com/font.ttf');
}
在SendGrid中是否可以导入字体? 我一直在尝试使用@font-face,但似乎不起作用,也许是我做错了什么。
我使用的代码示例:
@font-face {
font-family: Avenir;
src: url('http://cdn.linktofont.com/font.ttf');
}
我们在StackOverflow使用SendGrid发送某些电子邮件,我可以保证如果嵌入正确,Web字体是有效的。我使用以下代码:
<!-- Desktop Outlook chokes on web font references and defaults to Times New Roman, so we force a safe fallback font. -->
<!--[if mso]>
<style>
* {
font-family: sans-serif !important;
}
</style>
<![endif]-->
<!-- All other clients get the webfont reference; some will render the font and others will silently fail to the fallbacks. More on that here: http://stylecampaign.com/blog/2015/02/webfont-support-in-email/ -->
<!--[if !mso]><!-->
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
<!--<![endif]-->
<style>
* {font-family: Roboto, sans-serif;}
</style>
我不确定如何最好地嵌入像 Avenir 这样的高级字体,也不知道 .ttf
格式在电子邮件客户端中的支持情况。但是,通过像这样引用 Google 字体,在支持它们的邮件客户端中可以使用自定义 Web 字体。
我曾经遇到过同样的问题,而我发现使用自定义的.ttf
文件使其正常工作的唯一方法是通过定义并使用一个类。在头部选项中添加您的样式:
@media screen {
@font-face {
font-family: 'MyFont';
src: url('https://some-server/fonts/MyFont.ttf');
format('truetype');
}
}
.title {
font-family: 'MyFont';
}
<h1 class="title"> Some fancy title </h1>