我正在使用 Thymeleaf 模板生成 HTML 页面,然后将该页面用作电子邮件的内容。所需的字体系列是 Calibri。然而,当生成 HTML 文档(然后作为电子邮件发送)时,检索到的包含该文档的电子邮件不包含 Calibri 中的字体。
但是,如果我删除与 Thymeleaf 相关的元素并在浏览器中将页面作为普通 HTML 页面启动,它确实会在 Calibri 中显示内容。问题可能出在哪里?
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<link href='http://fonts.googleapis.com/css?family=Calibri'
rel='stylesheet' type='text/css' />
<style>
body {
font-family: 'Calibri', serif;
font-size: 11pt;
}
</style>
</head>
<body>
<p style="line-height:25pt;">
We from <span th:text="${nameCompany}"></span> are sending you an email.
</p>
</body>
</html>
最佳答案
您可以尝试更改这行代码并告诉我这是否有帮助
改变
<link href='http://fonts.googleapis.com/css?family=Calibri'
rel='stylesheet' type='text/css' />
至
<link th:href="@{http://fonts.googleapis.com/css?family=Calibri}"
rel='stylesheet' type='text/css' />
关于spring - Thymeleaf 文档中所需的字体未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38210346/