Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <code>imagettftext()</code> to write text onto images as long as your host supports GD2 and FreeType (as most servers do). You can find its detailed syntax and comments here:</p> <p><a href="http://php.net/manual/en/function.imagettftext.php" rel="nofollow">http://php.net/manual/en/function.imagettftext.php</a></p> <p>Find a font (*.ttf or *.otf) that supports Hindi characters. Put the font file in the same directory as your script, and then try this code -- substituting "yourhindifont.ttf" for your own font filename:</p> <pre><code> &lt;?php // your string, preferably read from a source elsewhere $utf8str = "पुलिसवाला आमिर खान"; // buffer output in case there are errors ob_start(); // create blank image $im = imagecreatetruecolor(400,40); $white = imagecolorallocate($im,255,255,255); imagefilledrectangle($im,0,0,imagesx($im),imagesy($im),$white); // write the text to image $font = "yourhindifont.ttf"; $color = imagecolorallocatealpha($im, 50, 50, 50, 0); // dark gray $size = 20; $angle = 0; $x = 5; $y = imagesy($im) - 5; imagettftext($im, $size, $angle, $x, $y , $color, $font, $utf8str); // display the image, if no errors $err = ob_get_clean(); if( !$err ) { header("Content-type: image/png"); imagepng($im); } else { header("Content-type: text/html;charset=utf-8"); echo $err; } ?&gt; </code></pre> <p>If you plan to input Hindi directly into your source, be sure to set the document encoding of your source to UTF-8 (without BOM) in your editor beforehand. Otherwise the string will not be stored as expected.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload