Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forced hyphenation for {expression} #3038

Open
Geod24 opened this issue Jan 15, 2025 · 0 comments
Open

Forced hyphenation for {expression} #3038

Geod24 opened this issue Jan 15, 2025 · 0 comments

Comments

@Geod24
Copy link

Geod24 commented Jan 15, 2025

Describe the bug

The following (with and without the hyphenationCallback prop) leads to hyphenation:

  <Document>
    <Page style={styles.body}>
      <Text style={styles.text} hyphenationCallback={(word => [word])}>
        This tests that hyphenation doesn't work right in this case and now I need to report it ({word})
      </Text>
    </Page>
  </Document>

Result:
image

While with the word inline, this does not happen.

To Reproduce

const word = "somelongword";

const Quixote = () => (
  <Document>
    <Page style={styles.body}>
      <Text style={styles.text} hyphenationCallback={(word => [word])}>
        This tests that hyphenation doesn't work right in this case and now I need to report it ({word})
      </Text>
    </Page>
  </Document>
);

const styles = StyleSheet.create({
  body: {
    paddingTop: 35,
    paddingBottom: 65,
    paddingHorizontal: 35,
  },
  text: {
    margin: 12,
    fontSize: 14,
    textAlign: 'justify',
    fontFamily: 'Times-Roman'
  },
});

ReactPDF.render(<Quixote />);

Expected behavior
No hyphenation is happening, especially with the provided hyphenationCallback. Note that putting the word variable inline (This tests that hyphenation doesn't work right in this case and now I need to report it (somelongword)) has the correct behaviour.

Screenshots

image

Desktop (please complete the following information):

Windows, Chrome, React-PDF REPL 4.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant