Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.16k stars 1.17k forks source link

Shifted font vowels for Khmer #968

Open jflaflamme opened 7 years ago

jflaflamme commented 7 years ago

Issue

Hello guys, first thanks for the awesome work. I have an issue with Khmer font, with or without a custom font (font is unicode and available on Google fonts Hanuman-Regular.ttf)

The top and bottom vowels are all shifted to the left as the screen shot below.

image

Hope you can help.

Steps to Reproduce

ctx.fillText('Khmer: សូមអរគុណពីហ្គីកូខេមបូឌ', 10, 90)

Above, the fillText is displaying the vowels correctly (សូមអរគុណពីហ្គីកូខេមបូឌ) on github as utf-8, my file is encoded as utf-8, the output from fillText seems to have an issue aligning them.

Your Environment

tomhero commented 7 years ago

I have the same problem with khmer language :(

chearon commented 7 years ago

Looks like an issue with Pango (or maybe HarfBuzz), not node-canvas ☹️.

I did a test in C: x

However, I think it might be the mixed Roman letters that are making it difficult to do the right shaping. If you take out the English, is this more correct? never mind, still looks wrong.

x

If so you could do the English and Khmer in two separate calls to fillText.

ejaytkm commented 6 years ago

Most likely it has to do with your environment. If you're using Ubuntu, check for your language supports. You can do that by typing: locale -a

In my case, my font was Thai. So I decided to install the basic language supports.

sudo apt-get install language-pack-{{language}} language-pack-gnome-{{language}} language-pack-{{language}}-base language-pack-gnome-{{language}}-base

Once that is done, you should had a new list of language support. So recheck you list, then add it by executing the command below.

locale -a sudo locale-gen {{locale language}}

My local language was th_TH.utf8. Hope this solves your issue as it did mine.