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

Support for Hebrew / RTL #3419

Closed
vraja-pro opened this issue Mar 17, 2024 · 1 comment
Closed

Support for Hebrew / RTL #3419

vraja-pro opened this issue Mar 17, 2024 · 1 comment

Comments

@vraja-pro
Copy link

vraja-pro commented Mar 17, 2024

Following the discussion in stack overflow, can you please add this code?

To fix hebrew letters direction add code to src/Renderer/Text.php before $this->_canvas->text (line 73).
I added a PR #3420

 if ( strtolower( $style -> direction ) == 'rtl' && preg_match( "/\p{Hebrew}/u", $text ) ){

    preg_match_all('/./us', $text, $ar);

    // reverse the whole line
    $text = join('',array_reverse($ar[0]));

    // flip english back to ltr
    $words = explode( ' ', $text );
    foreach( $words as $i => $word ):
        if( !preg_match( "/\p{Hebrew}/u", $word ) ):
            $words[$i] = implode( '', array_reverse( str_split( $word ) ) );
        endif;
        if( $word === ""){
            $words[$i] = "-";
        }
    endforeach;

    $text = implode( ' ', $words );
    }
@vraja-pro vraja-pro changed the title Support for Hebrew/ RTL Support for Hebrew / RTL Mar 17, 2024
@bsweeney
Copy link
Member

The PR is sufficient. Also, watch #2619 for updates on script support for various languages.

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

2 participants