Stickers - Interactive works - others dont

Post Reply
JHoke
Newbie
Newbie
Posts: 8
Joined: Thu Mar 22, 2018 3:56 pm
Location: Albrightsville, PA
Station model: Davis Pro 2
Software: weeWX
Contact:

Stickers - Interactive works - others dont

Post by JHoke » Mon Apr 16, 2018 10:17 am

I am running the current version of Meteotemplate and Stickers plugin, and interactive banners work perfectly, but the 'static' stickers are not showing any text, just icons

Here are some of the examples from the sticker plugin config/info page

Image

Image

And as you can see in my sig below the interactive stickers (both static and animated) is just fine

Server Info:
  • Ubuntu 16.04 (Hosted on Amazon Lightsail)
  • Apache Server version: Apache/2.4.18 (Ubuntu) Server built: 2017-09-18T15:09:02
  • php Version: 7.0.28-0ubuntu0.16.04.1 (Latest version in Ubuntu Canonical)
When I try to access those stickers above with errors=1 set, I get the following in my apache error log for this virtualhost:

Code: Select all

[Mon Apr 16 05:59:45.932945 2018] [:error] [pid 25532] [client 75.97.234.87:53906] PHP Warning:  imagettfbbox(): Could not find/open font in /var/www/weather/public_html/plugins/stickers/sticker800_170.php on line 289
[Mon Apr 16 05:59:45.932959 2018] [:error] [pid 25532] [client 75.97.234.87:53906] PHP Warning:  imagettftext(): Could not find/open font in /var/www/weather/public_html/plugins/stickers/sticker800_170.php on line 292
I do see the font called on those lines, with proper permissions, in /plugins/stickers/fonts

GD Support is enabled for FreeType (from phpinfo();)
  • GD Support enabled
  • GD headers Version 2.1.1
  • GD library Version 2.1.1
  • FreeType Support enabled
  • FreeType Linkage with freetype
  • FreeType Version 2.6.1
Is this a limitation of the PHP Version, something else?
========


EDIT:
Ok, I just did the following:
Copied sticker800_170.php to stickerTest.php
Changed lines 289 & 292 to prefix the font name with the 'fonts/' directory so that it now looks like:

Code: Select all

        function textCenter($img, $x, $y, $text, $size, $ttfsize, $color, $angle) {
                $gsSupport = gd_info();
                if ($gsSupport["FreeType Support"] == 0){
                   $x -= (imagefontwidth($size) * strlen($text)) / 2;
                   $y -= (imagefontheight($size)) / 2;
                   imagestring($img, $size, $x, $y - 3, $text, $color);
                }
                else {
                        $box = imagettfbbox ($ttfsize, $angle, 'fonts/Roboto-Bold.ttf', $text);
                        $x -= ($box[2] - $box[0]) / 2;
                        $y -= ($box[3] - $box[1]) / 2;
                        imagettftext ($img, $ttfsize, $angle, $x, $y, $color, 'fonts/Roboto-Bold.ttf', $text);
And it works ....
Image

Not sure why this was needed on this install, but it seems to be working for other people out of the box ...

Jachym - if you have any thoughts/ideas I'm all ears and if you need any other info just let me know.
Image
Station: Davis Vantage Pro 2
Software: weeWX
Hardware: Raspberry Pi 3
WebSite: https://nepaweather.com/

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: Stickers - Interactive works - others dont

Post by Jachym » Mon Apr 16, 2018 11:27 am

Strange, but some servers behave very oddly. It works for me in the original state as well

JHoke
Newbie
Newbie
Posts: 8
Joined: Thu Mar 22, 2018 3:56 pm
Location: Albrightsville, PA
Station model: Davis Pro 2
Software: weeWX
Contact:

Re: Stickers - Interactive works - others dont

Post by JHoke » Mon Apr 16, 2018 5:40 pm

Yeah ... but if you have the proper path to the fonts does it break others? If not, would it be feasible to fix in next release?

Otherwise I'll just keep some notes that I need to edit in future updates as it is not pathing properly

The main difference I see between the interactive and non-interactive versions is that in the interactive scripts you set a variable $fontFace as follows

Code: Select all

	$fontFace = "fonts/".$_GET['font'].".ttf";
Then you call it in the script as

Code: Select all

imagettftext ($img, $ttfsize, $angle, $x, $y, $color, $fontFace, $text);
But in the non-interactive scripts you just place

Code: Select all

imagettftext ($img, $ttfsize, $angle, $x, $y, $color, 'Roboto-Bold.ttf', $text);
Which is missing the path to the ttf file "fonts/" ... I fixed this by simply changing the calls to Roboto-Bold.ttf to fonts/Roboto-Bold.ttf ... but I wonder if $fontFace being set to that would not be better ... will need to test

Also, found an issue with the 800x150 script - its missing mph as a windspeed

Code: Select all

 if($displayWindUnits=="kmh"){
                $windUnits = "km/h";
        }
        if($displayWindUnits=="ms"){
                $windUnits = "m/s";
        }
so until I added

Code: Select all

        if($displayWindUnits=="mph"){
                $windUnits = "mph";
        }
It would not put the 'mph' units under the windspeed
Image
Station: Davis Vantage Pro 2
Software: weeWX
Hardware: Raspberry Pi 3
WebSite: https://nepaweather.com/

andyk1
Professional
Professional
Posts: 433
Joined: Tue Feb 27, 2018 10:56 pm
Location: OKLAHOMA, USA
Station model: Ecowitt WS90
Software: Meteobridge/GW2000B
Contact:

Re: Stickers - Interactive works - others dont

Post by andyk1 » Tue Apr 24, 2018 10:26 pm

Sorry if this post is a week late and a dollar short but I ran across a similar problem in another part of my site changing from one host to another.

My problem started when all worked fine at original host with massive problems and thanks to the help and suggestions of many offering different clues as to what my problem was. I'm by no means a php expert. Anyway changing hosts totally ruined my working copy. The way I ended up getting it solved and again with the suggestion of one person from this site my php version was lowered till it finally worked. I wasn't to thrilled going from ver 7 something but am stuck at php ver 5.7 and without checking my host am fairly certain that is what I am using. All for the most part seems to work fine on my site and reading through these post I see it working for some out of the box and not for others. As I said... not wanting to open a can of worms but it's a though.

This line of code reminded me of my problem and was fairly similar to mine. The pid xxxxx and PHP Warning is what reminded me.
Mon Apr 16 05:59:45.932945 2018] [:error] [pid 25532] [client 75.97.234.87:53906] PHP Warning: imagettfbbox(): Could

Just a suggestion to think about.

Andy
Image

Post Reply