I use Verdana font inside my images created by PHP GD library.
imagettftext($image, $fontSize, 0, 70, $y, $color, $font, $username );
Most of the cases imagettftext works very well for strings.
But some of my users use weird characters/symbols inside their names.
So when I try to print their names to images. For example:
This user uses ɦɪɲɣƙƨєʌɾ
symbols. So Verdana can't print them.
I used this:
$username=iconv('UTF-8', 'ASCII//TRANSLIT', $username);
Output is this:
(Current locale changes between English and Deutsch. So maybe current locale can't handle these characters: ɦɪɲɣƙƨєʌɾ
)
It seems like it's not possible to transliterate ɦ
to h
, ɲ
to n
without writing a very big str_replace()
block. Like this.
So I wonder whether is it possible to check whether the font (Verdana) can show these symbols. If one of the character can't be shown inside string, so I can pass an empty string to
imagettftext
method. Can I check the supported characters inside font ? Or create a character map that includes Verdana supported symbols, and check whether my string includes non-supported symbols ?
(I think it is not possible due to this question)Or maybe another solution, is it possible to use multiple fonts in
imagettftext()
?
For example first try Verdana, if Verdana doesn't cover that symbols use Arial sans serif etc.Or any other solution ?
Edit:
It seems like Verdana doesn't support these unicode characters in my text.
Verdana supported characters: http://www.fileformat.info/info/unicode/font/verdana/grid.htm
Verdana unspported characters: http://www.fileformat.info/info/unicode/font/verdana/missing.htm
ɦ
should transliterate toh
in the first place, so maybe this is the expected result.) – Tussah