reportbro-designer icon indicating copy to clipboard operation
reportbro-designer copied to clipboard

Custom font (Khmer Unicode) render not correct

Open CHOMNANP opened this issue 5 years ago • 8 comments

I have follow the additional fonts here. https://www.reportbro.com/support/index

And it does print the custom font. ref: Custom font, https://fonts.google.com/specimen/Khmer?selection.family=Khmer

Yet, the result is recondered not correctly. It look like new line is include to the content.

Source Data "ថ្ងៃនេះជាថ្ងៃល្អ". Output PDF:expense-report (24).pdf

Output Excel: file.xlsx

The content supposed to be print like "ថ្ងៃនេះជាថ្ងៃល្អ". Not sure if there is anything to do with reportbro or the OS of server.

CHOMNANP avatar Feb 05 '20 09:02 CHOMNANP

Found that Thai Font has similar issue based on pyfpdf. https://pyfpdf.readthedocs.io/en/latest/Unicode/index.html

unicode.pdf

CHOMNANP avatar Feb 07 '20 06:02 CHOMNANP

found similar issue in pyfpdf. https://github.com/reingart/pyfpdf/issues/109

CHOMNANP avatar Feb 07 '20 06:02 CHOMNANP

Have you found anything out about this issue? Since ReportBro is based on pyfpdf for text rendering we need to have this issue fixed there.

Can you debug this? We have little knowledge of Khmer fonts - how does rendering work? Are characters rendered differently on their position in a word or depending on previous/next character?

alhman avatar Feb 24 '20 18:02 alhman

I would love to help contribute into this. Yet, I'm not quite sure where to start. Can you give me some hints on this?

If we this fixed, this is going to be the game changing for us.

For rendering, I'm not the subject expert. Yet it seem like Thai language is also having the same problem.

CHOMNANP avatar Feb 27 '20 03:02 CHOMNANP

It seems this is much more complicated than expected and not just a pyfpdf (and thus ReportBro) rendering issue. For Khmer, Thai, arabic languages and others there is no simple mapping between unicode codepoints (text content) and font glyphs. e.g. there can be multiple condpoints rendered as a single glyph. To correctly render texts in these languages a text shaping engine like HarfBuzz is needed because the whole process is very complex.

alhman avatar Mar 02 '20 22:03 alhman

I got similar issue for Arabic text and the solution for Arabic is to use arabic_reshaper from python side

SalemCode8 avatar Nov 13 '21 18:11 SalemCode8

I have not tried it yet but it looks very promising. Do you think there is any chance it could also be used to reshape text in other languages like Thai or Khmer?

alhman avatar Nov 18 '21 22:11 alhman

I really didn't try this out because my application to it uses only Arabic and English

SalemCode8 avatar Nov 20 '21 13:11 SalemCode8

@CHOMNANP the latest version of reportbro uses an updated version of reportbro-fpdf2 that should fix the reported problem. There is also support for text shaping for additional_fonts using harfbuzz (currently only available in reportbro-plus-lib). Closing the issue. If you still encounter problems please re-open the issue or create a new one.

bmiklautz avatar Feb 23 '24 09:02 bmiklautz