在Laravel应用中将MALAYALAM字体添加到MPDF中
我在Laravel应用程序中使用MPDF。我的PDF文件都带有英语和马拉雅拉姆语。但是马拉雅拉姆语内容无法正确加载。我尝试添加新字体,但是它总是显示缺少OTL Table
错误。这是我的代码。
config/pdf.php
return [
'mode' => 'utf-8',
'format' => 'A4',
'author' => '',
'subject' => '',
'keywords' => '',
'creator' => 'Laravel Pdf',
'display_mode' => 'fullpage',
//'tempDir' => base_path('../temp/'),
'tempDir' => __DIR__.'/../temp/',
//'tempDir' => __DIR__.'/../storage/framework/pdf/',
'pdf_a' => false,
'pdf_a_auto' => false,
'icc_profile_path' => '',
'font_path' => base_path('resources/fonts/'),
'font_data' => [
'malayalam' => [
'R' => 'ECBThinkal.ttf', // regular font
'B' => 'ECBThinkal.ttf', // optional: bold font
'I' => 'ECBThinkal.ttf', // optional: italic font
'BI' => 'ECBThinkal.ttf', // optional: bold-italic font
'useOTL' => 0xFF,
'useKashida' => 75,
]
]
];
view.blade.php
<html>
<?php header('Content-Type: text/html; charset=utf-8');?>
<head>
<style>
body {
font-family: 'malayalam', sans-serif;
}
</style>
我没有粘贴完整代码。当我尝试创建PDF时,它会返回错误无法设置字体“ d:\ xampp \ htdocs \ xxxxx \ resources/fonts/fonts/ecbthinkal.ttf”以使用otl”,因为它不包括OTL表(或至少不包括OTL表) GDEF表)。
也尝试了其他一些字体,但此错误仍显示。
I am using mPDF in my Laravel application. My pdf file comes with both English and Malayalam languages. But Malayalam content not loading properly. I tried to add new font, but it's always showing missing OTL table
error. Here is my code.
config/pdf.php
return [
'mode' => 'utf-8',
'format' => 'A4',
'author' => '',
'subject' => '',
'keywords' => '',
'creator' => 'Laravel Pdf',
'display_mode' => 'fullpage',
//'tempDir' => base_path('../temp/'),
'tempDir' => __DIR__.'/../temp/',
//'tempDir' => __DIR__.'/../storage/framework/pdf/',
'pdf_a' => false,
'pdf_a_auto' => false,
'icc_profile_path' => '',
'font_path' => base_path('resources/fonts/'),
'font_data' => [
'malayalam' => [
'R' => 'ECBThinkal.ttf', // regular font
'B' => 'ECBThinkal.ttf', // optional: bold font
'I' => 'ECBThinkal.ttf', // optional: italic font
'BI' => 'ECBThinkal.ttf', // optional: bold-italic font
'useOTL' => 0xFF,
'useKashida' => 75,
]
]
];
view.blade.php
<html>
<?php header('Content-Type: text/html; charset=utf-8');?>
<head>
<style>
body {
font-family: 'malayalam', sans-serif;
}
</style>
I am not pasting full code. When I try to create pdf it returns error Unable to set font "D:\xampp\htdocs\xxxxx\resources/fonts//ECBThinkal.ttf" to use OTL as it does not include OTL tables (or at least not a GDEF table).
Tried some other fonts also, but still this error is showing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想这就是您在配置中所缺少的。
参考: https://mpdf.github.io/fonts-languages/自动font-selection.html
I guess this is what you are missing in your config.
Reference: https://mpdf.github.io/fonts-languages/automatic-font-selection.html