Workaround for UTF-8 issues with PHP's imagestring

Some of you may have expirienced the issue, that php's

imagestring-function doesn't properly show UTF-8 characters.

As workaround you can use the imagettftext-function.

When using imageTTFtext instead of imagestring, you have to know, that you don't use the $font-ids from PHP, instead you use fontfiles.


imagestring ( resource $im, int $font, int $x, int $y, string $s, int $color )

becomes to:

imagettftext ( resource $im, int $size, int $angle, int $x, int $y, int $color, string $fontfile, string $text ) 

Keep $angle=0 if you want just horizontal-text. Hope that helps!

In open source, php, utf-8 by
@ 04 Nov 2007, Comments at Reddit & Hackernews

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files