Wicked PDF 无法在 rails 4.1.2 中选择字体
Wicked PDF is not able to pick the font in rails 4.1.2
I tried almost all the available option, but my font is not included in generated PDF file.
I tried base64 bit solution , converting css files to .scss and many more.
一切都在 assets.rb 下定义和预编译,application.rb.Please 让我知道是否有任何遗漏。我遵循了解决方案 http://apleroy.com/posts/custom-pdf-fonts-with-wicked_pdf-and-heroku 但没有成功。示例代码:
@font-face {
font-family: 'Source Sans Pro Light';
src: url(data:font/truetype;charset=utf-8;base64,T1RUTw..)
}
.custom_font {
font-size: 24px;
font-family: 'Source Sans Pro ExtraLight';
}
这是我正在使用的 CSS 代码示例
基本布局
<!doctype html>
<html>
<head>
<meta charset='utf-8' />
<%= wicked_pdf_stylesheet_link_tag "filename"-%>
</head>
<style>
@font-face {
font-family: 'proximanova';
src:url(data:font/truetype;;charset=utf-8;base64, AAA.....);
}
</style>
<body >
<%= yield %>
</body>
</html>
我之前在 filename.css 中添加了字体,但没有用。
尝试 your_font.ttf
的绝对路径
src: url('file:///path/to/your_font.ttf') format('truetype')
我终于解决了这个问题,我有字体 "fontname" 和它的子 类 作为普通的打火机等。早些时候我使用 font-family: 'fontname' 我猜这不是正确的。
当我使用 font-family 时:'fontname regular' 它工作正常。
I tried almost all the available option, but my font is not included in generated PDF file.
I tried base64 bit solution , converting css files to .scss and many more.
一切都在 assets.rb 下定义和预编译,application.rb.Please 让我知道是否有任何遗漏。我遵循了解决方案 http://apleroy.com/posts/custom-pdf-fonts-with-wicked_pdf-and-heroku 但没有成功。示例代码:
@font-face {
font-family: 'Source Sans Pro Light';
src: url(data:font/truetype;charset=utf-8;base64,T1RUTw..)
}
.custom_font {
font-size: 24px;
font-family: 'Source Sans Pro ExtraLight';
}
这是我正在使用的 CSS 代码示例
基本布局
<!doctype html>
<html>
<head>
<meta charset='utf-8' />
<%= wicked_pdf_stylesheet_link_tag "filename"-%>
</head>
<style>
@font-face {
font-family: 'proximanova';
src:url(data:font/truetype;;charset=utf-8;base64, AAA.....);
}
</style>
<body >
<%= yield %>
</body>
</html>
我之前在 filename.css 中添加了字体,但没有用。
尝试 your_font.ttf
的绝对路径src: url('file:///path/to/your_font.ttf') format('truetype')
我终于解决了这个问题,我有字体 "fontname" 和它的子 类 作为普通的打火机等。早些时候我使用 font-family: 'fontname' 我猜这不是正确的。
当我使用 font-family 时:'fontname regular' 它工作正常。