Releases: diegomura/react-pdf
@react-pdf/types@2.9.2
Patch Changes
- Updated dependencies []:
- @react-pdf/font@4.0.4
- @react-pdf/stylesheet@6.1.2
@react-pdf/textkit@6.1.0
Minor Changes
-
#3188
f034491bThanks @carlobeltrame! - Fix and rework the hyphenation algorithm, and allow custom word hyphenation algorithms to specify whether a hyphen should be inserted in case the word is wrapped.Caution: If you have been using a custom hyphenation callback - which hasn't been working properly since at least version 2.0.21 - then you will need to change your implementation to leave a soft hyphen character (
'\u00AD') at the end of syllables where you want react-pdf to insert a hyphen when wrapping lines. Syllables without a final soft hyphen character will still be able to break, but will not produce a hyphen character at the end of the line.This allows you to break correctly on normal hyphens or other special characters in your text. For example, to use the default english-language syllable breaking built into react-pdf, but also break after hyphens naturally occurring in your text (such as is often present in hyperlinks), you could use the following hyphenation callback:
import { Font } from "@react-pdf/renderer"; Font.registerHyphenationCallback((word, originalHyphenationCallback) => { return originalHyphenationCallback(word).flatMap((w) => w.split(/(?<=-)/)); });
(
flatMaprequires at least ES2019)
@react-pdf/stylesheet@6.1.2
Patch Changes
- Updated dependencies []:
- @react-pdf/types@2.9.2
@react-pdf/renderer@4.3.2
@react-pdf/render@4.3.2
Patch Changes
- Updated dependencies [
f034491b]:- @react-pdf/textkit@6.1.0
- @react-pdf/types@2.9.2
@react-pdf/reconciler@2.0.0
@react-pdf/pdfkit@4.1.0
Minor Changes
-
#3188
f034491bThanks @carlobeltrame! - Fix and rework the hyphenation algorithm, and allow custom word hyphenation algorithms to specify whether a hyphen should be inserted in case the word is wrapped.Caution: If you have been using a custom hyphenation callback - which hasn't been working properly since at least version 2.0.21 - then you will need to change your implementation to leave a soft hyphen character (
'\u00AD') at the end of syllables where you want react-pdf to insert a hyphen when wrapping lines. Syllables without a final soft hyphen character will still be able to break, but will not produce a hyphen character at the end of the line.This allows you to break correctly on normal hyphens or other special characters in your text. For example, to use the default english-language syllable breaking built into react-pdf, but also break after hyphens naturally occurring in your text (such as is often present in hyperlinks), you could use the following hyphenation callback:
import { Font } from "@react-pdf/renderer"; Font.registerHyphenationCallback((word, originalHyphenationCallback) => { return originalHyphenationCallback(word).flatMap((w) => w.split(/(?<=-)/)); });
(
flatMaprequires at least ES2019)
@react-pdf/layout@4.4.2
@react-pdf/image@3.0.4
@react-pdf/font@4.0.4
Patch Changes
- Updated dependencies [
f034491b]:- @react-pdf/pdfkit@4.1.0
- @react-pdf/types@2.9.2