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

Add check useDictionaryLBR before replace word boundary marker #1899

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

BugGolf
Copy link

@BugGolf BugGolf commented Jul 5, 2023

Add Flag useDictionaryLBR check before replace word boundary marker with U+200B

Hello

I want to fix for some Thai font like TH Sarabun New (Standard Fonts for Thai Public Sectors) because it does not support with ZWSP (U+200B).

image

The reason that I have to use OTL because some characters require processing before display.
without useOTL and "useDictionaryLBR" => false

image

with "useOTL" => 0xFF and "useDictionaryLBR" => false

image

When I add flag "useDictionaryLBR" => false and edit Otl.php:351 for check before process $this->seaLineBreaking(); can fix this issue. See output like this picture below

image

Added a pull request as I think this edit might be helpful for other Thai people. and this a pull request can fix for issue #1272

Info

This line is have flag useDictionaryLBR before insert U+200B
In Otl.php: 982
image

But this line isn't have flag useDictionaryLBR before insert U+200B
In Otl.php: 351
image

I want to add flag useDictionaryLBR check before insert U+200B. This can fix some thai font like Sarabun it does not support ZWSP (U+200B)
image

Version Info

  • mpdf/mpdf: "8.1"
  • PHP: "8.2.7"

Font:
THSarabunNew.zip

This is a PHP code

<?php
require __DIR__ . '/../src/vendor/autoload.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',
            'orientation' => 'P',
            'tempDir' => '/tmp',
            'fontDir' => '../src/resources/fonts/',
            'fontdata' => $fontData + [
                    'thsarabunnew' => [
                        'R' => 'THSarabunNew.ttf',
                        'I' => 'THSarabunNew Italic.ttf',
                        'B' => 'THSarabunNew Bold.ttf',
                        'BI' => 'THSarabunNew BoldItalic.ttf',
                        'useOTL' => 0xFF
                    ]
                ],
            'default_font' => 'thsarabunnew',
            'default_font_size' => 16
]);

$html = '
<div>1. ทดสอบ ข้อความ</div>
<div>2. ทดสอบ ข้อความ</div>
<div>3. ทดสอบ ข้อความ</div>
<div>4. ทดสอบ ข้อความ</div>
<div>5. ทดสอบ ข้อความ</div>
<div>123/4 ถ.ทดสอบ ต.ทดสอบ อ.ทดสอบ จ.ทดสอบ 12345</div>
';

$mpdf->useDictionaryLBR = false;
$mpdf->WriteHTML($html);
$mpdf->Output();
?>

Add check useDictionaryLBR before replace word boundary marker with U+200B
@finwe
Copy link
Member

finwe commented Jul 5, 2023

There is no reasoning for this, no tests with example code this should fix, no explanation. Can reopen when all this is added.

@finwe finwe closed this Jul 5, 2023
@BugGolf
Copy link
Author

BugGolf commented Jul 6, 2023

There is no reasoning for this, no tests with example code this should fix, no explanation. Can reopen when all this is added.

Thank you.

@finwe finwe reopened this Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants