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

issue: fix square characters being printed when printing tickets that's using languages like Thai #6684

Open
wants to merge 2 commits into
base: 1.17.x
Choose a base branch
from

Conversation

amiraiman
Copy link

Tested on a fresh install of osTicket version 1.18.1

Before adding the mpdf init options, the Thai characters are printed as square brackets:
image

After:
image

@JediKev
Copy link
Contributor

JediKev commented Apr 12, 2024

@amiraiman

Thank you for the pull request. I like this approach better as traditionally we've been updating the core mPDF config directly which obviously gets overwritten during mPDF upgrade and forgotten about. The way you are doing it will persist across mPDF upgrades.

With this being said, in this pull you are removing the $this->autoScriptToLang; line (further below your main changes) which is not necessary. Also, you are setting allow_charset_conversion to false whereas when it's true it allows the system to change the character set with charset=xxx in the HTML headers. Additionally, you are forgetting about the poor Tasks! Lastly, since this issue is present in both 1.17.x and 1.18.x you'd make the pull against the 1.17.x branch. That way it gets merged into 1.17.x and then into 1.18.x; addressing the issue in both series.

TLDR;
In order for this pull to be accepted, you will need to do the following:

  • Rebase the entire pull on top of 1.17.x instead of develop. If you don't know how, please close this pull and make a new one.
  • Rebase your initial commit to add the $this->autoScriptToLang; line back. We don't like extra commits so consolidate your commits as much as possible instead of adding another needless/useless commit.
  • Rebase your initial commit to remove the , 'allow_charset_conversion' => false part.
  • Rebase your initial commit to add , 'autoLangToFont' => true, 'autoScriptToLang' => true to the parent::__construct() call in the Task2PDF class so that Tasks work as well.

Cheers.

@amiraiman amiraiman force-pushed the hotfix/fix-square-brackets-when-print branch from a091d27 to dfc0240 Compare April 13, 2024 09:16
@amiraiman amiraiman changed the base branch from develop to 1.17.x April 13, 2024 09:17
@amiraiman amiraiman force-pushed the hotfix/fix-square-brackets-when-print branch from dfc0240 to fd82f0f Compare April 13, 2024 09:21
@amiraiman amiraiman force-pushed the hotfix/fix-square-brackets-when-print branch from fd82f0f to 872a649 Compare April 13, 2024 09:22
@amiraiman
Copy link
Author

amiraiman commented Apr 13, 2024

Hi @JediKev,

I've rebase the PR to target 1.17.x instead of the develop branch as suggested. I've also added the line $this->autoScriptToLang; back, remove allow_charset_conversion option as well as added the same mPDF init config to Task2PDF Class. I've tested this new changes for both ticket printing & task printing on 1.17 and 1.18, and both works as intended.

For some context, I added the allow_charset_conversion because the rendering of Thai characters still does not work when I tested them initially. However, I did another fresh install of osTicket v1.18 and only add autoScriptToLang and autoLangToFont and the PDF renders correctly.

With that, I'm wondering why you would want the $this->autoScriptToLang; line back since we already set it to true during the initialization? Does it do different things? I only found this on mPDF docs and can't find any usage info on it.

Lastly, would it be better to move mPDF construct to mPDFWithLocalImages class since both Ticket2PDF and Task2PDF extends from it?

@JediKev
Copy link
Contributor

JediKev commented Apr 14, 2024

@amiraiman

Thank you for the updates. So after some research I found that that line was needed to replace a deprecated or, quote "redundant" function SetAutoFont() (search for SetAutoFont) when upgrading from 5.x to 6.x. But, alas, there is a twist. The line really needs to be $mpdf->autoScriptToLang = true; in both places (as recommended in the link above). If you want to update those lines that'd be swell.

Also, you have weird extra spaces on the Ticket2PDF change. If you could rebase to remove those spaces that'd be great as well.

Oh, to answer your question about moving it to the parent class; it doesn’t currently have a __construct method and since we already define things in each class in the parent::__construct call you can just add it there like you already have it. This codebase is in maintenance mode so it’s fine; all of this is currently being rewritten with v2.0.

Cheers.

@amiraiman amiraiman force-pushed the hotfix/fix-square-brackets-when-print branch from 82d6ac1 to 2584403 Compare April 14, 2024 09:07
@amiraiman
Copy link
Author

Hi @JediKev

I've updated $this->autoScriptToLang to be set to true instead of merely calling the property as suggested.

Sorry for the extra two spaces, I disabled my IDE PHP auto formatter (Pint) because it would reformat the entire file, so I missed the extra spaces. Instead of removing all spaces, I removed two to ensure that the construct call is at the same indentation level as the rest of the method body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants