【问题标题】:Add malayalam font in mPDF in Laravel application在 Laravel 应用程序的 mPDF 中添加马拉雅拉姆字体
【发布时间】:2022-07-28 18:58:03
【问题描述】:

我在我的 Laravel 应用程序中使用 mPDF。我的 pdf 文件带有英语和马拉雅拉姆语两种语言。但马拉雅拉姆语内容无法正确加载。我尝试添加新字体,但它总是显示missing OTL table 错误。这是我的代码。

配置/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 时,它返回错误 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).

也尝试了一些其他字体,但仍然显示此错误。

【问题讨论】:

    标签: laravel pdf mpdf


    【解决方案1】:

    我猜这就是您的配置中缺少的内容。

    'autoLangToFont'        => true,
    

    参考:https://mpdf.github.io/fonts-languages/automatic-font-selection.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-27
      • 1970-01-01
      • 2012-04-19
      • 1970-01-01
      • 2014-04-25
      • 2023-03-31
      • 2012-07-21
      • 2014-01-26
      相关资源
      最近更新 更多