How to disable hyphenation?
See original GitHub issueReact-pdf version:
alpha.15
Description: I would like to disable hyphenation, I tried to do it according to docs by passing identity callback, but I get the following error: react-pdf.browser.es.js:1067 Uncaught (in promise) TypeError: word.forEach is not a function at eval (react-pdf.browser.es.js:1067) at Array.forEach (<anonymous>) at eval (react-pdf.browser.es.js:1065) at KPLineBreaker.suggestLineBreak (react-pdf.browser.es.js:1112) at Typesetter.layoutLineFragments (Typesetter.js:82) at LayoutEngine$$1.layoutParagraph (LayoutEngine.js:134) at LayoutEngine$$1.layoutColumn (LayoutEngine.js:92) at LayoutEngine$$1.layout (LayoutEngine.js:80) at TextEngine.layout (react-pdf.browser.es.js:3755) at Text.measureText (react-pdf.browser.es.js:3965)
How to replicate issue including code snippet (if applies):
Font.registerHyphenationCallback(words => words);
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
I resolved with this changes in callback:
Should be like this:
Why?
The hyphenation callback takes as argument the array of words you want to render in the doc (in the format of
GlyphString
), and should return an array of each word splited into pieces where hyphenation can occur. In other words, it should return an array of arrays. If you don’t want to break any word, you basically return each word as it was originally and that’s it.Hope this helped.