Skip to content

Bidi issue with RTL languages (Hebrew, Arabic) #2900

@matangot

Description

@matangot

Describe the bug
After the bidi support integrated everything is much easier for RTL languages.
At the same time, an issue (glitch) occurs when you try to add a <Text> element inside another <Text> element.

To Reproduce

  1. Create a basic environment of react-pdf with a font supported by RTL (e.g: Rubik)
  2. Add a <Text> element and add style={{direction: 'rtl'}} to it so RTL will work properly (so far so good - everything should be fine)
  3. Add a <Text style={{ color: 'red' }}> element with text inside
<View style={{ fontFamily: 'Rubik', textAlign: 'center', width: '100%' }}>
  <Text style={{direction: 'rtl'}}>עברית <Text style={{ color: 'red'}}>קשה</Text> שפה</Text>
</View>

<View style={{ fontFamily: 'Rubik', textAlign: 'center', width: '100%' }}>
  <Text style={{direction: 'rtl'}}>ولما كان <Text style={{ color: 'red'}}>تناسي</Text> حقوق الإنسان وازدراؤها قد أفضيا إلى أعمال همجية</Text>
</View>

Expected behavior
Expected the text in the inner <Text> element to be colored in red.

Screenshots
CleanShot 2024-10-09 at 17 16 40

CleanShot 2024-10-09 at 17 15 47

Desktop (please complete the following information):

  • OS: MacOS, Linux
  • Browser: Chrome. Firefox
  • React-pdf version: v4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions