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

My text starts from bottom and ends to top #21

Open
mohamedshuaau opened this issue Aug 12, 2018 · 3 comments
Open

My text starts from bottom and ends to top #21

mohamedshuaau opened this issue Aug 12, 2018 · 3 comments

Comments

@mohamedshuaau
Copy link

When the image is saved and rendered out, my text starts from the bottom and end at top of the bounding box. How can I solve this? Here is the code:

$image->textBox($ascii, array(
                    'width' => 500,
                    'fontSize' => 24,
                    'alignHorizontal' => 'center',
                    'alignVertical' => 'center',
                ));

I am not using height as I do not want to auto scale the font/text. Also I am using a RTL font/language here. Is that the reason why it is behaving so? I have text which is supposed to be aligned RTL.

@kus
Copy link
Owner

kus commented Aug 13, 2018 via email

@mohamedshuaau
Copy link
Author

Here is the full code and I will attach the links as well. This was created in Laravel and this is a fresh sample I made this morning.

Route::get('/', function () {


    // I am using a class to convert the language to ascii and outputing the variable $ascii as text to your lib.
   // Git link to this class: https://github.com/jawish/thaana_conversions_php
    $thaana = new ThaanaConversions;

    //As you can see here, the text here and the image output is completely different. It starts from the last line?
    $ascii = $thaana->convertUtf8ToAscii('އަންނަ މަހު ބާއްވާ މި އަހަރުގެ ރިޔާސީ އިންތިޚާބުގައި ވޯޓު ލުމަށް ވޯޓު ފޮއްޓާއި ވޯޓިން ބޫތު އިލެކްޝަންސް ކޮމިޝަނުން ރަށްރަށަށް ފޮނުވައިފި އެވެ');
    //Sorry I had to remove the period at the end of the text because of the git's editor. 

    $bg = public_path('foo.jpg');
    $image = new PHPImage();
    $image->setDimensionsFromImage($bg);
    $image->draw($bg);
    $image->setFont(public_path('avas3_.ttf'));

    //Font download link: https://fonts2u.com/download/a-waheed.font

    $image->setTextColor(array(255, 255, 255));
    $image->setStrokeColor(array(0, 0, 0));

    //Using the converted variable
    $image->textBox($ascii, array(
        'width' => 500,
        'fontSize' => 24,
        'alignHorizontal' => 'center',
        'alignVertical' => 'center',
    ));

    $image->save('output.jpg');

});

As you can see, the text starts from right to left. Not left to right. And I think that is the issue. The text is rendered out as ltr as well. Here is the output image:

https://ibb.co/ddmrqp

It is not as it is on the text above. As in, when the text goes out of bound (500px), it starts the line as is as on the editor above. But it is RTL language. Hope this makes sense.

Let me know if you need more details.

@mohamedshuaau
Copy link
Author

Any updates on this issue?

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