React-pdf version: 1.0.0
Description:
@diegomura, sorry found another bug with Japanese. Hyphenation does not turn off. Please check example below.
Hi!
I see that there are lines that get hyphenated, but that's just because there are some lines that does not fit in the page width. You want those lines to overflow the page?
What I did noticed is that Font.registerHyphenationCallback is called with some fragments of lines. That's because the layout algorithm identified that some chars belong to a different unicode script` in the script itemization process
My apologizes that I don't know anything but latin languages 馃槄
Hi @diegomura,
Yeah, as you said, I noticed about how the algorithm identifies the different chars and either considers each character a word depending on which unicode script it is of, too when I was debugging one of the previous problems. Probably the best solution as you suggested would be for all Han scripts ( Chinese/Japanese/Korean, etc..) to just overflow at the end of each line to the next, as hyphenation is not used in those languages.
My workaround is like this:
<View style={{ flexDirection: "row", flexWrap: "wrap" }}>
{Array.from(text).map((char) => <Text>{char}</Text>)}
</View>
I try this code is ok
Font.registerHyphenationCallback(word => word.length === 1 ? [word] : Array.from(word).map(char => char));
Most helpful comment
My workaround is like this:
https://react-pdf.org/repl?code=1887b07602e07404e0a6073025819c271802800607a5c02403780ee4980098825400d880318086112e1400588680beb9a2c9035c00cdc0414b80359c24632140810476003400088802875ea45300b6496804f005cea011006959f2225ad3c025006e2d5a1b834ead09da7028ea00bcea00ca10fe70611c7070d00cf02c7098daba000e4c08701669ba7ae26148005e39ea004c00acaa3af9f6c086c6e656b672e28eba3c4e6e1e5e603ee8001e102156804e4180f60c8040ca801e0c80960c80c6a680510c80360c80d10c80490c80884680320c806872800d51807a0c801c7a80560c80910c80010c8090e6805d0e80760c80a69a808e3a80537280a7a68051b180120c80660c80515b402c83200893500d191800d06400aa26009c1900410c806d064016832393cde1180105d2e951a619c21001f3a930b5000f00045180057031c12004daae94900052c9c17c25383052c18caa597c9100b04887e008a0a0996c8f019f97ca92006a483809065b2b940054e0c302400e440ea120806052260c04054ca293709aed632e5b84572b55b28552a555a00240ba6d230251086101e15a7dcefb63bdd76a678743dead4400900752349acd168a306e331f515ba391ecf86055161510f40141b9290f0062b1c0164b19a48960d088cb0998131d275923b7d2fc9e34af3ba2206260ed9314044668326003ce280183b984c03038a6fc70489a490d1057a6a0f5b33ce2e9abb30eb7686adacecaaaad94860d2e9f1ad0f4b4002538131abccf270160748a06098292588e2b80123d1000