healthysustainablecities / global-indicators

An open-source tool for calculating spatial indicators for healthy, sustainable cities worldwide using open or custom data.
MIT License
83 stars 34 forks source link

Thai text does not correctly wrap (words should wrap on zero width space) #441

Open carlhiggs opened 3 months ago

carlhiggs commented 3 months ago

I have lodged an issue describing this upstream at fpdf2: https://github.com/py-pdf/fpdf2/issues/1190

In short, instead of Thai text wrapping correctly like it does in browser

นโยบาย​สาธารณะ​มี​ความ​สำคัญ​ต่อ​การ​สนับสนุน​การ​ออก​แบบ​และ​การ​สร้าง​ชุมชน​และ​เมือง​สุขภาพ​ดี​และ​ยั่งยืน รายการ​ตรวจ​สอบนโยบาย​ความ​ท้าทาย 1,000 เมือง​สำหรับ​ใช้​เพื่อ​ประเมิน​การ​มี​อยู่​และ​คุณภาพ​ของ​นโยบาย​ที่​สอด​คล้อง​กับ​หลัก​ฐาน​และ​หลัก​การ​สำหรับ​เมือง​ที่​มี​สุขภาพ​ดี​และ​ยั่งยืน

it doesn't break on zero-width spaces and instead only breaks on visible spaces when rendered as a pdf, e.g.: image.

Thai uses spaces like punctuation, not to seperate words, and so inserting spaces to manually induce word wrapping isn't a viable solution as it would impact meaning.

I think it might be a simple fix (allow wrapping on zero-width spaces), or its possible I have misunderstood the problem. I'll wait to hear if anyone has any advice, and if not, i'll attempt to fix in code.

carlhiggs commented 2 months ago

It took a while, but with guidance of the package maintainers I was finally able to implement this feature in the upstream FPDF software we use (https://github.com/py-pdf/fpdf2/pull/1191). I believe a new release of the software will be made soon, and once availabel on conda-forge, I will update things to make use of it. This will help city teams from countries with the languages and scripts that use spaces or symbols other than " " to break words generate reports for their local audiences (e.g. Thai, Lao, Burmese and other languages).

Once this has been incorporated into our Docker software image and used within an updated version of our software, I'll close this issue.