imagettftext

imagettftext(): calculate font size to ensure text fits image width

青春壹個敷衍的年華 提交于 2019-11-28 11:34:39
I'm using imagettftext() to write dynamic text on an image and I want it to fit my image width. How can I calculate the font size by the text lenght? You can calculate the bounding box of TTF text before outputting it with the imagettfbbox function. Unfortunately there is no direct way of scaling to fit a width, so you'll have to do it yourself. One way of doing it is to pass the text with a default font size of, say 20, to imagettfbbox and retrieve the width from it. You can then calculate how much smaller or bigger the text should be to fit the size you want by calculating a scale factor:

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/a2424901/public_html/index.php on line 35

感情迁移 提交于 2019-11-27 15:29:51
<?php session_start(); require_once 'facebook.php'; $app_id = "418907881455014"; $app_secret = "36389d2c4caaf6de86982cb87686a494"; $redirect_uri = 'http://gooogle12.comuf.com'; $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true )); $user = $facebook->getUser(); $user_profile = $facebook->api('/me'); $coded = $_REQUEST['code']; $access_token = $facebook->getAccessToken(); $name = "".$user_profile['name'].""; $fbid = "".$user_profile['id'].""; function RandomLine($filename) { $lines = file($filename) ; return $lines[array_rand($lines)] ; } $reason =

Error while writting Arabic to image

喜夏-厌秋 提交于 2019-11-27 04:52:21
My previous related question: php work with images : write complete word in arabic , ttf font My problem was: If I want to write احمد in image it appears as د م ح ا Well, I fixed it and now the output: ا ح م د Using this function: function arab($word){ $w = explode(' ',$word) ; $f = array(array('ا','أ'),'ب','ت','ث','ج','ح','د','ذ','ر','ز','س','ش','ص','ض','ط','ظ','ع','غ','ف','ق','ك','ل','م','ن','ه','و','ى'); $t = array(array('ا_','أ_'),'ب_','ت_','ث_','ج_','ح_','د_','ذ_','ر_','ز_','س_','ش_','ص_','ض_','ط_','ظ_','ع_','غ_','ف_','ق_','ك_','ل_','م_','ن_','ه_','و_','ى_'); $my_arab = '' ; foreach($w as

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/a2424901/public_html/index.php on line 35

淺唱寂寞╮ 提交于 2019-11-26 17:10:26
问题 <?php session_start(); require_once 'facebook.php'; $app_id = "418907881455014"; $app_secret = "36389d2c4caaf6de86982cb87686a494"; $redirect_uri = 'http://gooogle12.comuf.com'; $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true )); $user = $facebook->getUser(); $user_profile = $facebook->api('/me'); $coded = $_REQUEST['code']; $access_token = $facebook->getAccessToken(); $name = "".$user_profile['name'].""; $fbid = "".$user_profile['id'].""; function

Error while writting Arabic to image

女生的网名这么多〃 提交于 2019-11-26 11:22:31
问题 My previous related question: php work with images : write complete word in arabic , ttf font My problem was: If I want to write احمد in image it appears as د م ح ا Well, I fixed it and now the output: ا ح م د Using this function: function arab($word){ $w = explode(\' \',$word) ; $f = array(array(\'ا\',\'أ\'),\'ب\',\'ت\',\'ث\',\'ج\',\'ح\',\'د\',\'ذ\',\'ر\',\'ز\',\'س\',\'ش\',\'ص\',\'ض\',\'ط\',\'ظ\',\'ع\',\'غ\',\'ف\',\'ق\',\'ك\',\'ل\',\'م\',\'ن\',\'ه\',\'و\',\'ى\'); $t = array(array(\'ا_\',\'أ_