Re: [PHP] how to enable ttf support in php 5.2.9
Ashley Sheridan wrote: Great idea in theory, if you can guarantee that they'll *only* be using MS Office to paste from. In my experience, you can only guarantee on the stupidity of the end users, nothing else. I was mostly being facetious :) The only thing that really works is getting the users to cooperate by giving them a button for Word and a button for Text and explaining to them how it *helps them* to use those buttons properly. But that only works while they remember, and they never remember when they're in a hurry (which is always). -- Ross McKay, Toronto, NSW Australia Darwin's rolling over in his coffin, 'cos the fittest are surviving much less often - NOFX -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
On Sat, 2009-05-09 at 11:42 +1000, Ross McKay wrote: On Tue, 5 May 2009 17:27:57 -0400, tedd.sperling wrote: I have one client who no matter how many times I talk to him about gremlins and how he should make sure his entries are plain text, he still cuts and paste things directly from M$ Word and then wonders Where did those come from? They weren't there when I added that text. What did you do? If that's using TinyMCE, enable the Paste From Word button (or the Paste as Plain Text button) and disable the regular Paste button :) -- Ross McKay, Toronto, NSW Australia Pay no attention to that man behind the curtain - Wizard of Oz Great idea in theory, if you can guarantee that they'll *only* be using MS Office to paste from. In my experience, you can only guarantee on the stupidity of the end users, nothing else. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
On Tue, 2009-05-05 at 16:22 -0700, Michael A. Peters wrote: Ashley Sheridan wrote: content coming from MS Office clipboard pastes generally contain characters that are encoded wrong, and do not display correctly in web pages unless they have very relaxed doctypes. The function I generally use is: function removeMSCrap($crap) { $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217), chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149), chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169), chr(174)); $replace = Array(euro;, #133;, #8243;, #039;, #039;, #039;, #039;, #034;, #034;, #034;, #034;, #149;, #149;, #150;, #150;, #151;, #151;, #153;, #153;, copy;, reg;); $roses = str_replace($find, $replace, $crap); return $roses; } Is that something you would suggest be used in any web app that has a textarea for input? It is valid for that also. I've used it on standard input type=text/ tags before as well. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
Ashley Sheridan wrote: On Mon, 2009-05-04 at 18:42 -0400, PJ wrote: Jim Lucas wrote: PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? My port on FreeBSD does not have an option for ttf support under make config . I'm trying to learn understand the following: In file1 : img src=button.php?s=36text=PHP+is+Cool / In file2 (button.php)- originally php3 : ?php Header(Content-type: image/gif); if(!isset($s)) $s=11; The above should be: if ( empty($_GET['s']) ) { $s = 11; } else { $s = (int)$_GET['s']; } $size = imagettfbbox($s,0,times.ttf,$text); and this should be $text = ''; if ( !empty($_GET['text']) ) $text = your_custom_input_cleaner_function($_GET['text']); $size = imagettfbbox($s,0,times.ttf,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $xpad=9; $ypad=9; $im = imagecreate($dx+$xpad,$dy+$ypad); $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, times.ttf, $text); ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, times.ttf, $text); ImageGif($im); ImageDestroy($im); ? ONLY the above nothing else. So far, all I get is a small blue square. Replacing the $text with the text just gives a rectangle a bit wider. gd is installed but ttf is not, so I figure that is the culprit. But how is the text supposed to be assigned to $text from file1? TIA Thank you for that. Now it works. I see, the $s had to come from somewhere... But what's the custom_cleaner_function - I mean, to clean what? Why? What if I use some foreign accents, like eacute; or Agrave; ? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php content coming from MS Office clipboard pastes generally contain characters that are encoded wrong, and do not display correctly in web pages unless they have very relaxed doctypes. The function I generally use is: function removeMSCrap($crap) { $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217), chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149), chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169), chr(174)); $replace = Array(euro;, #133;, #8243;, #039;, #039;, #039;, #039;, #034;, #034;, #034;, #034;, #149;, #149;, #150;, #150;, #151;, #151;, #153;, #153;, copy;, reg;); $roses = str_replace($find, $replace, $crap); return $roses; } Ash www.ashleysheridan.co.uk Uh. Ok. That's cool. Somehow I have managed to never use MS Office for anything else than web applications. Generally I open .doc with OpenOffice. But, who know's? Thanks, anyway. :-) -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
On Tue, 2009-05-05 at 09:57 -0400, PJ wrote: Ashley Sheridan wrote: On Mon, 2009-05-04 at 18:42 -0400, PJ wrote: Jim Lucas wrote: PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? My port on FreeBSD does not have an option for ttf support under make config . I'm trying to learn understand the following: In file1 : img src=button.php?s=36text=PHP+is+Cool / In file2 (button.php)- originally php3 : ?php Header(Content-type: image/gif); if(!isset($s)) $s=11; The above should be: if ( empty($_GET['s']) ) { $s = 11; } else { $s = (int)$_GET['s']; } $size = imagettfbbox($s,0,times.ttf,$text); and this should be $text = ''; if ( !empty($_GET['text']) ) $text = your_custom_input_cleaner_function($_GET['text']); $size = imagettfbbox($s,0,times.ttf,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $xpad=9; $ypad=9; $im = imagecreate($dx+$xpad,$dy+$ypad); $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, times.ttf, $text); ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, times.ttf, $text); ImageGif($im); ImageDestroy($im); ? ONLY the above nothing else. So far, all I get is a small blue square. Replacing the $text with the text just gives a rectangle a bit wider. gd is installed but ttf is not, so I figure that is the culprit. But how is the text supposed to be assigned to $text from file1? TIA Thank you for that. Now it works. I see, the $s had to come from somewhere... But what's the custom_cleaner_function - I mean, to clean what? Why? What if I use some foreign accents, like eacute; or Agrave; ? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php content coming from MS Office clipboard pastes generally contain characters that are encoded wrong, and do not display correctly in web pages unless they have very relaxed doctypes. The function I generally use is: function removeMSCrap($crap) { $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217), chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149), chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169), chr(174)); $replace = Array(euro;, #133;, #8243;, #039;, #039;, #039;, #039;, #034;, #034;, #034;, #034;, #149;, #149;, #150;, #150;, #151;, #151;, #153;, #153;, copy;, reg;); $roses = str_replace($find, $replace, $crap); return $roses; } Ash www.ashleysheridan.co.uk Uh. Ok. That's cool. Somehow I have managed to never use MS Office for anything else than web applications. Generally I open .doc with OpenOffice. But, who know's? Thanks, anyway. :-) -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php It's mainly for the benefit of other people, who do use MS programs and copy and paste things into your web apps and then wonder why things don't work exactly how they expect Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
At 9:17 PM +0100 5/5/09, Ashley Sheridan wrote: It's mainly for the benefit of other people, who do use MS programs and copy and paste things into your web apps and then wonder why things don't work exactly how they expect Ash www.ashleysheridan.co.uk Ash: Ain't that the truth. I have one client who no matter how many times I talk to him about gremlins and how he should make sure his entries are plain text, he still cuts and paste things directly from M$ Word and then wonders Where did those come from? They weren't there when I added that text. What did you do? Oh well, we all stand somewhere between the stupid and smart marks on the scale of intelligence. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
Ashley Sheridan wrote: content coming from MS Office clipboard pastes generally contain characters that are encoded wrong, and do not display correctly in web pages unless they have very relaxed doctypes. The function I generally use is: function removeMSCrap($crap) { $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217), chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149), chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169), chr(174)); $replace = Array(euro;, #133;, #8243;, #039;, #039;, #039;, #039;, #034;, #034;, #034;, #034;, #149;, #149;, #150;, #150;, #151;, #151;, #153;, #153;, copy;, reg;); $roses = str_replace($find, $replace, $crap); return $roses; } Is that something you would suggest be used in any web app that has a textarea for input? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
Jim Lucas wrote: PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? My port on FreeBSD does not have an option for ttf support under make config . I'm trying to learn understand the following: In file1 : img src=button.php?s=36text=PHP+is+Cool / In file2 (button.php)- originally php3 : ?php Header(Content-type: image/gif); if(!isset($s)) $s=11; The above should be: if ( empty($_GET['s']) ) { $s = 11; } else { $s = (int)$_GET['s']; } $size = imagettfbbox($s,0,times.ttf,$text); and this should be $text = ''; if ( !empty($_GET['text']) ) $text = your_custom_input_cleaner_function($_GET['text']); $size = imagettfbbox($s,0,times.ttf,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $xpad=9; $ypad=9; $im = imagecreate($dx+$xpad,$dy+$ypad); $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, times.ttf, $text); ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, times.ttf, $text); ImageGif($im); ImageDestroy($im); ? ONLY the above nothing else. So far, all I get is a small blue square. Replacing the $text with the text just gives a rectangle a bit wider. gd is installed but ttf is not, so I figure that is the culprit. But how is the text supposed to be assigned to $text from file1? TIA Thank you for that. Now it works. I see, the $s had to come from somewhere... But what's the custom_cleaner_function - I mean, to clean what? Why? What if I use some foreign accents, like eacute; or Agrave; ? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
On Mon, 2009-05-04 at 18:42 -0400, PJ wrote: Jim Lucas wrote: PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? My port on FreeBSD does not have an option for ttf support under make config . I'm trying to learn understand the following: In file1 : img src=button.php?s=36text=PHP+is+Cool / In file2 (button.php)- originally php3 : ?php Header(Content-type: image/gif); if(!isset($s)) $s=11; The above should be: if ( empty($_GET['s']) ) { $s = 11; } else { $s = (int)$_GET['s']; } $size = imagettfbbox($s,0,times.ttf,$text); and this should be $text = ''; if ( !empty($_GET['text']) ) $text = your_custom_input_cleaner_function($_GET['text']); $size = imagettfbbox($s,0,times.ttf,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $xpad=9; $ypad=9; $im = imagecreate($dx+$xpad,$dy+$ypad); $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, times.ttf, $text); ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, times.ttf, $text); ImageGif($im); ImageDestroy($im); ? ONLY the above nothing else. So far, all I get is a small blue square. Replacing the $text with the text just gives a rectangle a bit wider. gd is installed but ttf is not, so I figure that is the culprit. But how is the text supposed to be assigned to $text from file1? TIA Thank you for that. Now it works. I see, the $s had to come from somewhere... But what's the custom_cleaner_function - I mean, to clean what? Why? What if I use some foreign accents, like eacute; or Agrave; ? -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php content coming from MS Office clipboard pastes generally contain characters that are encoded wrong, and do not display correctly in web pages unless they have very relaxed doctypes. The function I generally use is: function removeMSCrap($crap) { $find = Array(chr(128), chr(133), chr(8226), chr(145), chr(8217), chr(146), chr(8220), chr(147), chr(8221), chr(148), chr(8226), chr(149), chr(8211), chr(150), chr(8212), chr(151), chr(8282), chr(153), chr(169), chr(174)); $replace = Array(euro;, #133;, #8243;, #039;, #039;, #039;, #039;, #034;, #034;, #034;, #034;, #149;, #149;, #150;, #150;, #151;, #151;, #153;, #153;, copy;, reg;); $roses = str_replace($find, $replace, $crap); return $roses; } Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? My port on FreeBSD does not have an option for ttf support under make config . I'm trying to learn understand the following: In file1 : img src=button.php?s=36text=PHP+is+Cool / In file2 (button.php)- originally php3 : ?php Header(Content-type: image/gif); if(!isset($s)) $s=11; The above should be: if ( empty($_GET['s']) ) { $s = 11; } else { $s = (int)$_GET['s']; } $size = imagettfbbox($s,0,times.ttf,$text); and this should be $text = ''; if ( !empty($_GET['text']) ) $text = your_custom_input_cleaner_function($_GET['text']); $size = imagettfbbox($s,0,times.ttf,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $xpad=9; $ypad=9; $im = imagecreate($dx+$xpad,$dy+$ypad); $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, times.ttf, $text); ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, times.ttf, $text); ImageGif($im); ImageDestroy($im); ? ONLY the above nothing else. So far, all I get is a small blue square. Replacing the $text with the text just gives a rectangle a bit wider. gd is installed but ttf is not, so I figure that is the culprit. But how is the text supposed to be assigned to $text from file1? TIA -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to enable ttf support in php 5.2.9
Is there a module to be activated or what has to be installed to have ttf support in php? My port on FreeBSD does not have an option for ttf support under make config . I'm trying to learn understand the following: In file1 : img src=button.php?s=36text=PHP+is+Cool / In file2 (button.php)- originally php3 : ?php Header(Content-type: image/gif); if(!isset($s)) $s=11; $size = imagettfbbox($s,0,times.ttf,$text); $dx = abs($size[2]-$size[0]); $dy = abs($size[5]-$size[3]); $xpad=9; $ypad=9; $im = imagecreate($dx+$xpad,$dy+$ypad); $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, times.ttf, $text); ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, times.ttf, $text); ImageGif($im); ImageDestroy($im); ? ONLY the above nothing else. So far, all I get is a small blue square. Replacing the $text with the text just gives a rectangle a bit wider. gd is installed but ttf is not, so I figure that is the culprit. But how is the text supposed to be assigned to $text from file1? TIA -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? on unix systems, ttf support should be there with freetype - which supports both ttf and postscript type 1 fonts (and probably also supports .otf though I haven't tried) enable freetype and use the php freetype functions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to enable ttf support in php 5.2.9
PJ wrote: Is there a module to be activated or what has to be installed to have ttf support in php? addendum to my earlier reply - make sure your gd library is built with freetype as well, and make sure it is freetype 2. I'm guessing your gd library already is, but ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php