Since I can’t figure out this browser and non-proportional fonts, I thought I’d go back to my old version that creates an image and writes the text to the image. This version still runs (http://ykfp.org/php/nwac/whitepasssno.php), but the phone’s browser wants to save the png image rather than display it. I have to go look for the image. I thought rather than figure out how to change the phone browser file handler I could just embed the image on an html page by simply adding html tags around it, but it’s obvious I don’t know what I’m doing (http://ykfp.org/php/nwac/whitepasssno3.php)
Here’s the code for this attempt:
<?php
//header("Content-type: image/png");
//$url = "http://www.nwac.us/products/OSOWPS";
$url = "http://www.nwac.us/weatherdata/whitepass/now/";
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//Trim feed to useful data
$cStartStr = "MM/DD";
$cEndStr= " ";
//$cUsefulContents=stristr($contents,$cStartStr);
$cPageTail = stristr($contents, $cStartStr);
$nUsefulDataEndPos = strpos($cPageTail, $cEndStr);
$cUsefulData = substr($cPageTail, 0, $nUsefulDataEndPos);
// Construct an image file with the data printed in
//$im = imagecreatetruecolor(400, 310);
$im = imagecreatetruecolor(400, 362);
$backgroundcolor = imagecolorallocate($im, 232, 255, 255);
$foregroundcolor = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 359, $backgroundcolor);
$font = '../../fonts/COURBD.TTF';
$fontsize = 7; // size in points
imagettftext($im, $fontsize, 0, 0, 10, $foregroundcolor, $font, $cUsefulData);
imagepng($im);
imagedestroy($im);
?>
This signature line intentionally blank.