Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag that can disable replacing word boundary marker on Full-Stop #1272

Open
ichsarut opened this issue Aug 19, 2020 · 0 comments
Open

Flag that can disable replacing word boundary marker on Full-Stop #1272

ichsarut opened this issue Aug 19, 2020 · 0 comments

Comments

@ichsarut
Copy link

ichsarut commented Aug 19, 2020

Please use https://stackoverflow.com/questions/tagged/mpdf for all your general questions or troubleshooting!
For contributing here, please see the guideline: https://github.com/mpdf/mpdf/blob/development/.github/CONTRIBUTING.md

Warning: Failing to provide necessary information may cause the issue to be closed without consideration

I would like to have this new functionality

I add new Thai font and enable using OTL.
There are a lot of errors with my new font because it does not support with ZWSP (U+200B).
Screen Shot 2563-08-19 at 17 33 47

The reason that I have to use OTL because some characters require processing before display.
without useOTL
Screen Shot 2563-08-19 at 18 16 58
with useOTL => 0xFF
Screen Shot 2563-08-19 at 18 16 40

I use an external library for line-breaking so I set "useDictionaryLBR" flag to false to disable adding ZWSP to each word.
I replace ZWSP with Garuda font. But there are still errors after full-stop( . ).
Screen Shot 2563-08-19 at 18 10 05

**I can not replace the full stop with Garuda font because it really differences.

I would like to have a flag that can disable replacing word boundary marker on Full-Stop.
In Thai I think we don't use full stop to end a sentence. so it will be fine to disable this section.
Screen Shot 2563-08-19 at 18 32 05
/mpdf/mpdf/src/Otl.php

This is mPDF and PHP version and environment (server/fpm/cli etc) I am using

mPDF Version : 7.1.6
PHP Version : 7.1.33
Server API : Apache 2.0
Font : TH Sarabun New

This is a PHP code snippet I use

<?php
$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];

$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];

$mpdf = new \Mpdf\Mpdf([
            'mode' => 'utf-8',
            'margin_left' => 15,
            'margin_right' => 15,
            'margin_top' => 32,
            'margin_bottom' => 16,
            'margin_header' => 9,
            'margin_footer' => 5,
            'orientation' => 'P',
            'tempDir' => Yii::getPathOfAlias('application') . DIRECTORY_SEPARATOR . "temp",
            'fontDir' => array_merge($fontDirs, [
                Yii::getPathOfAlias('application') . DIRECTORY_SEPARATOR . "fonts",
            ]),
            'fontdata' => $fontData + [
                    'thsarabun' => [
                        'R' => 'THSarabunNew.ttf',
                        'I' => 'THSarabunNew Italic.ttf',
                        'B' => 'THSarabunNew Bold.ttf',
                        'BI' => 'THSarabunNew BoldItalic.ttf',
                        'useOTL' => 0xFF,
                    ]
                ],
            'default_font' => 'thsarabun',
            'default_font_size' => 16,
]);

$html = $this->renderPartial('testpdf', array(), true);
$mpdf->useDictionaryLBR = false;

$mpdf->WriteHTML($html);
$mpdf->SetTitle('test pdf.pdf');
$mpdf->Output();
?>

This is a HTML/CSS code snippet I use

<html>

<div style="font-family: thsarabun;">
    <!--Full Date-->
    <p>10 กันยายน พ.ศ.............2555</p>
    <p style="text-align: justify">การทำวุฎูอ์ หรือ การอาบน้ำละหมาด คือ การชำระล้างทำความสะอาดโดยใช้น้ำที่สะอาดล้าง อวัยวะทั้งสี่คือใบหน้า มือรวมถึงแขน ศีรษะ และเท้า </p>
    <p style="text-align: justify">
        การละหมาด เป็นการปฏิบัติศาสนกิจอย่างหนึ่งในศาสนาอิสลาม เพื่อเป็นการภักดีต่ออัลลอฮฺ มุสลิมทุกคนจะต้องละหมาด วันละ 5 เวลา เรียกว่า ละหมาดฟัรฎู  ละหมาด หมายถึง การขอพร ความหมายทางศาสนาหมายถึง การกล่าวและการกระทำ ซึ่งเริ่มต้นด้วยตักบีร และ จบลงด้วยสะลาม การละหมาดเป็นการสร้างเอกภาพอย่างหนึ่งของมุสลิม เมื่อละหมาดมุสลิมทั่วโลก หันหน้าไปทางกิบละฮฺ เพื่อเคารพภักดีต่ออัลลอฮฺ การละหมาด ฝึกฝนให้เป็นคนตรงต่อเวลา มีความอดทน และขัดเกลาจิตใจ ให้บริสุทธิ์ผ่องแผ้ว ไม่ประพฤติสิ่งหนึ่งสิ่งใดในทางชั่วร้าย ดังอัลกุรอานระบุไว้ ความว่า
    </p>
    <!--Full name-->
    <p>พ.ต.ต. กกก ดดดด</p>
</div>

</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants