Results 1 to 2 of 2

Thread: Title to image convert problem !!!

  1. #1
    Join Date
    Nov 2006
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Title to image convert problem !!!

    When I convert title to image site character broken.My language turkish(ISO-8859-9).Problem characters are ş-ı-ğ.The font is turkish.How am I solved this problem?


    system_function_title.php
    PHP Code:
    <?


        header
    ("Content-type: image/png");
        
    header("Content-Disposition: inline; filename=" $file);    
          
    header("Content-Type: text/xml; charset =ISO-8859-9"); 



          
    // create the test to get width first ...
        
    $test             imagecreate($image_width$image_height);
        
    $back             imagecolorallocate($test$back_color[0]    , $back_color[1]    , $back_color[2]    );
        
    $front             imagecolorallocate($test$front_color[0]    , $front_color[1]    , $front_color[2]    );
        
    $image_text        imagettftext($test$font_size0$position_left$position_top$front$font_file$text);
        
    $image_width    $image_text[2] - $image_text[0] + 20;                  
        
    imagedestroy($test);




          
    // now this is the serious image ... 
        
    $im             imagecreate($image_width $position_left$image_height);
        
    $back             imagecolorallocate($im$back_color[0]    , $back_color[1]    , $back_color[2]    );
        
    $front             imagecolorallocate($im$front_color[0]    , $front_color[1]    , $front_color[2]    );

           
    imagefilledrectangle($im00$image_width$image_height$back );
        
    imagecolortransparent($im$back);

        
    $image_text        imagettftext($im$font_size0$position_left$position_top$front$font_file$text);
        
    $image_width    $image_text[2] - $image_text[0];                  
        
        
    imagepng($im);
        
    imagedestroy($im);



    ?>

    File
    PHP Code:
    <?

        
    include("setting.php");

        
    $title            str_replace("\'""'"$title);

        
    $file            "$title.png";
        
    $text            html_entity_decode($titleENT_QUOTES);
        
    $back_color        = array(255255255);    // (red, green, blue)
        
    $front_color    = array(193 0);    // (red, green, blue)

        
    $font_file         'files/font/1.ttf';
        
    $font_size         18;
        
        
    $image_width    = (strlen($text)) * ($font_size 1) + 20;
        
    $image_height    30;
        
        
        
    $position_left    0;
        
    $position_top    20;
        
        include(
    "system_function_title.php");



    ?>

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Here's how you can tell PHP about your encoding: mb_internal_encoding('ISO 8859-9')

    See also http://en.wikipedia.org/wiki/Help:Turkish_characters for an alternative solution.
    Last edited by Jesdisciple; 10-20-2008 at 07:10 PM.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •