reportbro-designer
reportbro-designer copied to clipboard
Custom font (Khmer Unicode) render not correct
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.
Found that Thai Font has similar issue based on pyfpdf. https://pyfpdf.readthedocs.io/en/latest/Unicode/index.html
found similar issue in pyfpdf. https://github.com/reingart/pyfpdf/issues/109
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?
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.
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.
I got similar issue for Arabic text and the solution for Arabic is to use arabic_reshaper from python side
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?
I really didn't try this out because my application to it uses only Arabic and English
@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.