Login   Register  
PHP Classes
elePHPant
Icontem

File: gd_example/gd_example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Khaled Al-Shamaa  >  ArGlyphs  >  gd_example/gd_example.php  >  Download  
File: gd_example/gd_example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ArGlyphs
Convert Arabic text to Unicode for rendering
Author: By
Last change: Fix font issue
Date: 8 years ago
Size: 882 bytes
 

Contents

Class file image Download
<?php
// Set the content-type
header("Content-type: image/png");

// Create the image
$im = @imagecreatefromgif('images/bg.gif');

// Create some colors
$black imagecolorallocate($im000);
$blue  imagecolorallocate($im00255);

// Replace by your own font full path and name
$font  'trado.ttf';

// UTF-8 charset
$text "بسم الله الرحمن الرحيم";
imagettftext($im2001050$blue$font'UTF-8:');
imagettftext($im20020050$black$font$text);

require(
'ArGlyphs.class.php');
$ArabicGD = new ArGlyphs();
$text "   ";
$text $ArabicGD->convert($text);
imagettftext($im20010100$blue$font'ArGlyphs:');
imagettftext($im200200100$black$font$text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>