laravolt/avatar

Arabic (utf8) not working

Closed this issue · 6 comments

The package work with English only same problem #69 and #58 i try to set custom Arabic font i used setFont method and i changed path in avatar.php but it doesn't work any help pls
I used the last version 4.1.4

uyab commented

@balin09 could you provide some sample code?

And also, how is your current output? Does it still display text in latin?

@uyab here some code
avatar.php:

`
'driver' => env('IMAGE_DRIVER', 'gd'),

// Initial generator class
'generator' => \Laravolt\Avatar\Generator\DefaultGenerator::class,

// Whether all characters supplied must be replaced with their closest ASCII counterparts
'ascii'    => false,

// Image shape: circle or square
'shape' => 'square',

// Image width, in pixel
'width'    => 100,

// Image height, in pixel
'height'   => 70,

// Number of characters used as initials. If name consists of single word, the first N character will be used
'chars'    => 2,

// font size
'fontSize' => 38,

// convert initial letter in uppercase
'uppercase' => true,

'rtl' => false,

// Fonts used to render text.
// If contains more than one fonts, randomly selected based on name supplied
'fonts' => [__DIR__ . '/../fonts/Tajawal-Medium.ttf'],

// List of foreground colors to be used, randomly selected based on name supplied
'foregrounds' => [
    '#FFFFFF',
],

...
`
call avatar

img class="rounded-full" src="{{ Avatar::create($user['fname'].$user['lname'])->toBase64() }}" alt="User image"

and here the ouptput:

Capture d’écran 2021-09-02 131057

anyone try this plugin and worked with Arabic language ?

uyab commented

I downloaded (hopefully) the same font from https://www.fontpalace.com/font-download/tajawal-medium/ and its just works as expected.
image

Can you validate if you have setup the fonts path correctly? Something like dd(config('laravolt.avatar.fonts')) and see if the output was correct.

@uyab
So sorry for late response
my bad i get confused with font path in avatar.php i thought it was correct ..., now it worked fine when i change it.
but now i have an other problem: with arabic name it take 2 initial from first name only, exp for ( Imad Abd ) i expect [I A] but i get [Im].
here is the output

image

even with english sometimes the same probleme happen:

image

and also the output for rtl=>true or false ar the same for english and arabic here is my config

image

uyab commented

You can create your own InitialGenerator class. Please check the configuration file.