[reportlab-users] Issues rendering Burmese/Myanmar in PDFs

Bobby Hagen bobby.hagen at nextthought.com
Thu Jan 7 10:52:50 EST 2021


Previously posted on the google group, but missing images.  Hopefully those
come through this time. Also clarified a couple steps and wanted to follow
up on this via the list, just in case, as we're still seeing this, even
using the latest reportlab-3.5.59 available via pypi:

We're encountering some problems attempting to build PDFs using Burmese.
The problem doesn't seem restricted to a specific font, as at least
NotoSansMyanmar (https://www.google.com/get/noto/#sans-mymr) and Padauk (
https://fonts.google.com/specimen/Padauk) both have these issues.  Although
independent characters seem to be represented correctly, some of the vowels
and medials (and perhaps other items as well) seem to have some rendering
issues.

The issue we originally ran into was that the  U+103C MYANMAR CONSONANT
SIGN MEDIAL RA was misplaced, seeming to be placed following the consonant
instead of decorating it, as per http://unicode.org/notes/tn11/UTN11_3.pdf.
As a simple example, the string "ကြ" (represented by code points U+1000
U+103c), would appear as two separate characters "က ြ" instead of being
combined. If there was a character following that first "က", " ြ" would
incorrectly decorate the second character instead.

An example snippet, showing this behavior, which should show "ကြေး", but
seems to place the medial and vowel incorrectly:

# coding=utf-8
def main():
    from reportlab.pdfgen.canvas import Canvas
    from reportlab.pdfbase.ttfonts import TTFont
    from reportlab.pdfbase.pdfmetrics import registerFont
    from reportlab.lib.pagesizes import A10

    canv = Canvas('text-on-image.pdf',pagesize=A10)
    registerFont(TTFont('notosans','NotoSansMyanmar-Regular.ttf'))

    canv.setFont('notosans',14)
    canv.setFillColor((1,0,0)) #change the text color
    text = u"\u1000\u103C\u1031\u1038"
    canv.drawString(25,50,text)
    canv.save()

if __name__=='__main__':
    main()

This yields the following:
[image: image.png]

I've used the code points for it in the snippet, but you can see from
http://zawgyi-unicode-test.appspot.com/convertui/ how that should render:
[image: image.png]

And replacing with the actual characters in the code snippet doesn't
fix the issue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20210107/e0ea82b5/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 2001 bytes
Desc: not available
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20210107/e0ea82b5/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 2259 bytes
Desc: not available
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20210107/e0ea82b5/attachment-0005.png>


More information about the reportlab-users mailing list