foliojs / fontkit

An advanced font engine for Node and the browser
1.46k stars 219 forks source link

Changed sinh's shaper into IndicShaper #233

Closed wxmahen closed 2 years ago

wxmahen commented 4 years ago

Solved the "Type Error: Cannot read property 'syllable' of null" when a pdfmake document contains certain the characters \u0dda and \u0ddd.

Reference: https://stackoverflow.com/questions/60056226/is-there-anyway-to-bypass-this-error-on-pdfmake-type-error-cannot-read-proper

devongovett commented 4 years ago

Thanks. Looks like there's some logic in Harfbuzz to change the shaper that's used depending on the script that's available in the font. Wondering if we need to replicate that as well. https://github.com/harfbuzz/harfbuzz/blob/c15146448b534479de08b6aa8e6b1795221a2e1e/src/hb-ot-shape-complex.hh#L259

t-margheim commented 2 years ago

Sorry to jump in to an old pull request, but I've been trying to render Sinhala text as well and ran into this same issue. I've been looking to see if I can find a font that works with the current universal shaper. All of the unicode fonts that I have tried (a list here, Google's Noto for Sinhala, and Microsoft's Iskpota) have required the Indic shaper or else generate the error reported solved by @wxmahen. The only fonts that I can get to render with the Universal shaper selected are the ANSI fonts available at the first link above.

I'm not sure if you'd like to support ANSI input as well as Unicode input in this library; I will say that the ANSI fonts rendered correctly (to my eye, as a non-reader of the language) even with the Indic shaper in place, so I'm not sure that there is a risk to breaking current functionality.