PHP - Question Regarding Php Fonts
I am working on an existing system. It has the GD library (I think). The system is very hard to understand because of how it was built.
Either way, I am trying to add new fonts. I notice each font the other developer uses has a .php, .ttf, .t18 and .afm. Each one of the font has each one of those files, named the same as the font. I am going crazy, trying to figure out how to add more fonts. The client has requested that I add another 5-15 fonts. Pretty much whatever I can get my hands on. So I was curious, where can I find these kinds of fonts. Since there is a .php file, I assumed this was located somewhere as a php resource. I have search all over, but don't know what I am looking for. Or do I have to use any font, and then custom build the php file for that font, based off how that font works. How would someone learn how the internal workings would work, for a specific font? Similar TutorialsHi guys, Here is what I have so far: http://www.autoshopgarage.com/new-era/generate.php What I am trying to do is instead of having Line 1 and Line 2, I want to just have one big textarea so I don't have to limit the user so much. I did it this way because I want to have two versions of text, the light version and the bold version. Is it possible to have two different fonts with just one textarea of text? Right now I have two functions: Quote ImageTTFText($image, $fontSize, $fontRotation, 435, 80, $color, $font1, wordwrap($first, 18, "\n", true)); ImageTTFText($image, $fontSize, $fontRotation, 485,120, $color_black, $font2, wordwrap($last, 18, "\n", true)); So I would limit that to just 1, and it would automatically wordwrap but what would I put for the $font variable? Is this even possible? I was thinking of just using BBCode so they could type in [b*]Bold Text[/b*] and it would use the Bold version of the font if it sees that. Any help is appreciated. Thanks! Here is the full code: Quote <?php $first = $_GET['first']; $last = $_GET['last']; $font_color = $_GET['color']; header("Content-type: image/png"); $image = imagecreatefrompng ( "banner_blank.png" ); $color_black = imagecolorallocate($image, 0, 0, 0); $color_red = imagecolorallocate($image, 255, 0, 0); if($font_color == "Red") { $color = $color_red; } elseif($font_color == "Black") { $color = $color_black; } $font1 = 'HelveticaNeueLTStd-BdEx.ttf'; $font2 = 'HelveticaNeueLTStd-LtEx.ttf'; $fontSize = "21"; ImageTTFText($image, $fontSize, $fontRotation, 435, 80, $color, $font1, wordwrap($first, 18, "\n", true)); ImageTTFText($image, $fontSize, $fontRotation, 485,120, $color_black, $font2, wordwrap($last, 18, "\n", true)); imagepng ( $image ); imagedestroy ( $image ); ?> I have set this up with a form on another page so that they can generate a runescape stat signature, although there is something wrong, if they do not select a font it comes up with an error. Here is the Code: Code: [Select] <?php header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $user = ""; $img = ""; $fnt = ""; if(isset($_GET['user'])) { if(!empty($_GET['user'])) { $user = $_GET['user']; } } if(isset($_GET['img'])) { if(!empty($_GET['img'])) { $img = $_GET['img']; } else{$img='blue';} } else{$img='blue';} if(isset($_GET['fnt'])) { if(!empty($_GET['fnt'])) { $fnt = $_GET['fnt']; } else{$fnt='arial';} } else{$img='blue';} if(isset($_POST['user'],$_POST['img'],$_POST['fnt'])) { if(!empty($_POST['user'])) { $user=$_POST['user']; } if(!empty($_POST['img'])) { $img = $_POST['img']; } if(!empty($_POST['fnt'])) { $fnt=$_POST['fnt']; } } //Skill Grabs $order = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering"); $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user"); $get = explode("\n", $get); $i = 0; foreach ($order as $key => $value) { $value = strtolower($value); $temp = explode(",", $get[$i]); $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]); $stats[$value] = $temp; $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);"; eval($eval); $i++; } //End Skill Grabs $image = imagecreatefrompng("http://slay2day.x10.mx/highscores/signatures/".$img.".png"); $font = "/fonts/".$fnt.".ttf"; $color = imagecolorallocate($image, 255,255,255); ImageTTFText ($image, "7", 0, 280, 10, $color, "/fonts/arial.ttf","Slay2day"); ImageTTFText ($image, "12", 0, 240, 55, $color, $font,$user); if(is_numeric($overall[0])) { if($overall[0]==-1) { ImageTTFText($image, "11", 0, 230, 105, $color, $font,"2000000+"); } else { ImageTTFText($image, "11", 0, 240, 105, $color, $font,$overall[0]); } } else { ImageTTFText($image, "11", 0, 230, 105, $color, $font,"2000000+"); } ImageTTFText ($image, "10", 0, 27, 20, $color, $font,$attack[1]); ImageTTFText ($image, "10", 0, 27, 42, $color, $font,$strength[1]); ImageTTFText ($image, "10", 0, 27, 64, $color, $font,$defence[1]); ImageTTFText ($image, "10", 0, 27, 88, $color, $font,$hitpoints[1]); ImageTTFText ($image, "10", 0, 27, 114, $color,$font,$ranged[1]); ImageTTFText ($image, "10", 0, 70, 20, $color, $font,$prayer[1]); ImageTTFText ($image, "10", 0, 70, 42, $color, $font,$magic[1]); ImageTTFText ($image, "10", 0, 70, 64, $color, $font,$cooking[1]); ImageTTFText ($image, "10", 0, 70, 88, $color, $font,$woodcutting[1]); ImageTTFText ($image, "10", 0, 70, 114, $color,$font,$fletching[1]); ImageTTFText ($image, "10", 0, 117, 20, $color, $font,$fishing[1]); ImageTTFText ($image, "10", 0, 117, 42, $color, $font,$firemaking[1]); ImageTTFText ($image, "10", 0, 117, 64, $color, $font,$crafting[1]); ImageTTFText ($image, "10", 0, 117, 88, $color, $font,$smithing[1]); ImageTTFText ($image, "10", 0, 117, 114, $color,$font,$mining[1]); ImageTTFText ($image, "10", 0, 162, 20, $color, $font,$herblore[1]); ImageTTFText ($image, "10", 0, 162, 42, $color, $font,$agility[1]); ImageTTFText ($image, "10", 0, 162, 64, $color, $font,$thieving[1]); ImageTTFText ($image, "10", 0, 162, 88, $color, $font,$slayer[1]); ImageTTFText ($image, "10", 0, 162, 114, $color,$font,$farming[1]); ImageTTFText ($image, "10", 0, 212, 20, $color, $font,$runecraft[1]); ImageTTFText ($image, "10", 0, 212, 42, $color, $font,$construction[1]); ImageTTFText ($image, "10", 0, 212, 64, $color, $font,$hunter[1]); ImageTTFText ($image, "10", 0, 212, 88, $color, $font,$summoning[1]); ImageTTFText ($image, "10", 0, 212, 114, $color,$font,$dungeoneering[1]); header("Content-type: image/png"); imagepng($image); imagedestroy($image); //Logging $url = getenv("HTTP_REFERER"); // connect to the database include('connect-db.php'); //variables date_default_timezone_set('Pacific/Auckland'); $datepickerbox = $_POST['datepickerbox']; $datepickerbox = date("Y-m-d H:i:s", time($datepickerbox)); echo $datepickerbox; // save the data to the database mysql_query("INSERT signature SET user='$user', img='$img', time='$datepickerbox', url='$url', font='$fnt'") or die(mysql_error()); //End Logging ?> if they do not have a font i get: Code: [Select] Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/slay2day/public_html/highscores/signatures/signature.php on line 130 but of they dont choose a font i want it to use arial... Hi Not that often I play with these (and normally just a single font I use). However I am trying to generate an image with a ttf bit of text on it. No problem using Tuffy.ttf (the normal one I use), but I want to use some arrow characters which it doesn't support. I have tried using Wingding and Webdings but neither work with GD. Am I missing something (hopefully something obvious)? All the best Keith imagettftext() is used to write text to an image using TrueType fonts. Size being one of the parameters: Quote The font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2). An inch representing 72 points. However how is the point size calculated? Is it based on the servers/clients screen resolution? Hi friends, I need assistance with making russian fonts displayable in the system emails that are being sent to my auction website users. Any reason the russian fonts I have entered below are displayed the way they are. Please also note I am brand new in PHP and simple llingo would be appreciated. Regards, <? ## Email File -> email an auction to a friend ## called only from the $item->auction_friend() function! ## File Version -> v6.10 if ( !defined('INCLUDED') ) { die("Access Denied"); } //$sender_details = $this->get_sql_row("SELECT u.name, u.email FROM " . DB_PREFIX . "users u WHERE u.user_id='" . $user_id . "'"); $send = true; // always sent; ## text message - editable $text_message = 'Dear %1$s, Your friend, %2$s, has forwarded an auction, posted on %3$s for you to look at. To view the details of the auction, please click on the URL below: %4$s Additional comments: %5%s Best regards, The %6$s staff'; ## html message - editable $html_message = 'Дорогой (ая) %1$s, <br> <br> Ваш друг, %2$s, отправил на Ваше рассмотрение Аукцион, выставленный на %3$s. <br> <br> [ <a href="%4$s">Нажмите здесь</a> ] чтобы просмотреть этот Аукцион. <br> <br> Дополнительные комментарии: %5$s <br> <br> С Уважением, <br> %6$s <br> <br> <br> Dorogoy (aya) %1$s, <br> <br> Vash drug, %2$s, otpravil na Vashe rassmotreniye Auktsion, vistavlenniy na %3$s. <br> <br> [ <a href="%4$s">Najmite zdes</a> ] chtobi prosmotret etot Auktsion. <br> <br> Dopolnitelniye kommentarii: %5$s <br> <br> S Uvajeniyem, <br> %6$s'; $auction_link = process_link('auction_details', array('name' => $item_details['name'], 'auction_id' => $item_details['auction_id'])); $text_message = sprintf($text_message, $friend_name, $sender_name, $this->setts['sitename'], $auction_link, $comments, $this->setts['sitename']); $html_message = sprintf($html_message, $friend_name, $sender_name, $this->setts['sitename'], $auction_link, $comments, $this->setts['sitename']); send_mail($friend_email, 'Проверьте этот Аукцион', $text_message, $this->setts['admin_email'], $html_message, $sender_name, $send); ?> when in a form, I wish to build a conditional that if the response to a radio button is a value of 2 (female), it will display an input requesting for users maiden name. If not 2 goes to the next input statement. Here is code I was experimenting with: <html> <body> <form action="" name="test" method='POST'> <input type="radio" id="sex" value=1 checked><label>Male</label> <input type="radio" id="sex" value=2><label>Femaleale</label> <?php $result = "value"; if ($result == 2) echo "<input type='int' id='gradYear' size='3' required>"; else echo "Not a female!" ?> <input type="submit" value="GO"> </form> </body> </html> The code passes debug, however, Not a Female is displayed. My question is - Can I do this and if so, what value do I test against id='sex' or value. I tried each one but gave the same results. I realize that $_POST[sex] would be used after the submit button is clicked. But this has me stumped. Thanks for the assis in advance. say i have a mysql table with the following fileds user_id picture_category picture_title picture_description picture_thumb //small image size picture_normal //large image size. ok what I'm trying to do is this. if( user_id && picture_category == the same name show all the pictures in that category as one section) //show this category and all the images from this user_id and picture_category so if this user_id has a new category name and new images uploaded it would show the images in the right category. my php xml script is in the works and is looking like this so far. <?php include "../../connect.php"; Header('Cache-Control: no-cache'); Header('Pragma: no-cache'); $username = mysql_real_escape_string($_GET['username']); $user_folder = mysql_real_escape_string($_GET['user_folder']); //$password = mysql_real_escape_string($_GET['password']); $friend = (isset($_GET['friend'])) ? ' AND b.friend = \'' . mysql_real_escape_string($_GET['friend']) . '\' ' : NULL; $query = "SELECT * FROM accounts WHERE username = '$username'"; $results = mysql_query($query) or die("Data not found."); //Get the number of results from the query. $rows = mysql_num_rows($results); //If their is a match for the username, echo the the users xml data. if($rows == 1) { $query1 = "SELECT * FROM user_photo_gallery WHERE username = '$username'"; $query2 = "SELECT * FROM user_photo_gallery WHERE username = '$username' AND user_folder = '$user_folder'"; $results1 = mysql_query($query1) or die("Data not found."); $results2 = mysql_query($query2) or die("Data not found."); //$row = mysql_fetch_assoc($results1); $user_xml = "<?xml version=\"1.0\"?>\n"; $user_xml .= "<settings>\n"; $user_xml .= "<sceneHeight>600</sceneHeight>\n"; $user_xml .= "<sceneWidth>1000</sceneWidth>\n"; $user_xml .= "<titleColor>#000000</titleColor>\n"; $user_xml .= "<descriptionBgAlpha>70</descriptionBgAlpha>\n"; $user_xml .= "<showFullscreenBtn>no</showFullscreenBtn>\n"; $user_xml .= "<waterMark useImage=\"no\"><![CDATA[THIS]]></waterMark>\n"; $user_xml .= "</settings>\n"; $user_xml .="<galleries>\n"; //$sql = "SELECT a.username,a.user_folder,a.large_pic,a.small_pic,a.pic_title,a.pic_discription,b.username FROM (user_photo_gallery as a )JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $friend AND b.status = 1) ORDER BY a.user_folder DESC"; //$result2 = mysql_query($sql); //if(mysql_num_rows($result2) > 0) //{ while ($row = mysql_fetch_assoc($results1)) { $user_xml .="<gallery theName=\"". $row['user_folder'] ."\" itemsPerRow=\"3\" autoStart=\"no\" playTime=\"5\" autoResize=\"yes\" xOffset=\"5\" yOffset=\"10\" showTitleOnThumbs=\"yes\" allowDownload=\"yes\">\n"; if($row['user_folder'] =="Demo_Photos") { //select all pictures where this folder name and username maybe? while ($row1 = mysql_fetch_assoc($results2)) { $user_xml .="<picture largePicture=\"". $row1['large_pic'] ."\" smallPicture=\"". $row1['small_pic'] ."\" theTitle=\"". $row1['pic_title'] ."\"><![CDATA[". $row1['pic_discription'] ."]]>\n"; $user_xml .="</picture>\n"; } } else { } $user_xml .="</gallery>\n"; } //} //else //{ //echo "Wiistream Eorror!\n"; //}; $user_xml .="</galleries>\n"; echo $user_xml; } else { echo "Wiistream Eorror!\n"; } ?> the real xml file should look like this. Code: [Select] <?xml version="1.0" encoding="utf-8"?> <settings> <sceneHeight>600</sceneHeight> <sceneWidth>1000</sceneWidth> <titleColor>#000000</titleColor> <descriptionBgAlpha>70</descriptionBgAlpha> <showFullscreenBtn>no</showFullscreenBtn> <waterMark useImage="yes"><![CDATA[<font size="20">Copyright (c) 2010</font> <font color="#000000"><Strong>WiiStream</Strong></font>]]></waterMark> </settings> <galleries> <gallery theName="USERS PERSONAL GALLERY TITLE" itemsPerRow="3" autoStart="no" playTime="5" autoResize="yes" xOffset="5" yOffset="10" showTitleOnThumbs="yes" allowDownload="yes"> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> </gallery> <gallery theName="USERS PERSONAL GALLERY TITLE1" itemsPerRow="3" autoStart="no" playTime="5" autoResize="yes" xOffset="5" yOffset="10" showTitleOnThumbs="yes" allowDownload="yes"> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> </gallery> <gallery theName="USERS PERSONAL GALLERY TITLE2" itemsPerRow="3" autoStart="no" playTime="5" autoResize="yes" xOffset="5" yOffset="10" showTitleOnThumbs="yes" allowDownload="yes"> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> <picture largePicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" smallPicture="http://acadianfury.files.wordpress.com/2007/01/mazda.jpeg" theTitle="USERS TITLE OF PICTURE"><![CDATA[USERS DISCRIPTION OF PICTURE CAN USE TAGS]]></picture> </gallery> </galleries> but using it with mysql it only gets the user_id and the picture_category for this user and pulls back that users data only. I also have a join table included to join if this user has friendship with that user. and then you would see all your pictures upload and category's. and all your friends pictures and category's. hello all, i am having a for each problem. im trying to get two post fields using the foreach function. here is what i have in my form.php: Code: [Select] <?php foreach($_POST['staff'] as $value) { echo "$value - <br />"; } ?> the name of the the fields coming in are Code: [Select] name='staff[]' and the second one is name='descr[]' fields += 1; Code: [Select] /*** a new dom object ***/ $dom = new domDocument; /*** load the html into the object ***/ @$dom->loadHTML($file); /*** discard white space ***/ $dom->preserveWhiteSpace = false; /*** the table by its tag name ***/ $tables = $dom->getElementsByTagName('table'); /*** get all rows from the table ***/ $rows = $tables->item(0)->getElementsByTagName('tr'); /*** loop over the table rows ***/ foreach ($rows as $row) { /*** get each column by tag name ***/ $cols = $row->getElementsByTagName('a'); /*** echo the values ***/ echo $cols->item(0)->nodeValue.'<br />'; } Hi, Is there a way to start to echo from 43? thanks. I am trying to make my database search only search where private = '$priiv'(Usually 0,1, or 2) but it does not work Code: [Select] $query_search = "SELECT * FROM users WHERE username LIKE '%$idea%' OR fname LIKE '%$idea%' OR lname LIKE '%$idea%' OR tags LIKE '%$idea%' AND private = '$priiv'"; What am i doing wrong? Hey, I have a while that shows the rows(duh). What i want to do is: show 3 rows then echo float left or clear both. So basically 3 at a time, but it shows all the rows in a nice order. Can someone do this? Cheers. i have took a test that i think it has some errors: can you please confirm or infirm that A is the right answer? Question: The default value for __FILE__ is _______________________________. A. the complete path of the currently executing script B. the relative path of the currently executing script C. a magical constant; it does not have a default value D. the complete path of the previous executed script E. the relative path of the previous executed script Correct Answer: C User Answer: A Explanation: The PHP engine stores the full path and filename of the currently executing script within the __FILE__ constant. I'm considering getting a VPS, but I'm not entirely sure what this would be able the handle. The specs doesn't look that good to me, but my friend swears it will handle running apache/php/mysql handling large websites and databases without a problem. I want to run multiple databases that just store statistics and I'm a bit worried about the RAM and the company doesn't even mention a cpu. Here's the specs: 256MB RAM 300GB HDD 10Mbps unmetered 1 IP Address My friend runs two counter-strike: source servers off his VPS (same stats).. so I'm actually considering this, but it just seems like it's not powerful enough. Oh.. forgot the most important part.. it's only $9. Hi, I am looking into a way of adding addons to a class I made.. I thought something like this would work, but not sure how to implement it: Code: [Select] <?php class foo { function foobar($text) { $text = $text . 'b'; return $text; } } class bar extends foo { function foobar($text) { $text = $text . 'c'; return $text; } } $var = new bar(); $var->foobar('a'); // this would then return abc ?> Now i want to be able to call up foo, and it calls the foobar of foo, and the foobar of bar. is that possible? hosh Hey, Got 2 row's as defined: No What i want to do is: If the 2 row's still have the value No echo it, but if row 1 have a changed value echo only row 1. Same goes to row 2. And the 2 row's have both a changed value echo both. Can someone help me? Cheers. i am looking for a way to write a php script to pull information from a html table and put that information in to the databases does any one have any idea who to do this Code: [Select] <?php if ($News_1_Status=="Y") echo <div class="newstitle" align="left"><?php echo $News_1_Date;?> <a href="<?php echo $News_1_URL;?>"><?php echo $News_1_Name;?></a></div><br>; else echo "Have a nice day!"; ?> how do i get the above script working any clue? are there any php functions that are best used when testing to see if a server is busy or not? and if the server is busy then display a "server is busy" message in the php script? What does this code do? public function render() { $this->set('users', $this->model->findAll()); } TomTees Im not new to php but I am trying to think if this possible. I want to write a php script that creates a div inside a div until lets say 10 divs are created. I have been trying do while statements but them seem to place them underneth each other not within. I want <div id=one"> <div id=two"> <div id=three"> </div> </div> </div> Only thing I can create is <div id=one"></div> <div id=two"></div> <div id=three"></div> Like I said I dont even know if this is possible or if I am just retarded and can't think of a way to do it but it would be nice to see what others have to say about it. |