GoogleWebFonts-Talk

Summary: Talk page for GoogleWebFonts.
Maintainer: CarlosAB
Users: (View / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

  • [(approve links) edit diff]
  • [(approve links) edit diff]
  • If you check this script, you may see that it would be very easy to adapt to the Cookbook, and then with an include in config and a proper code, any PmWiki user could use the typewriter effect.
  • If you could hand this to someone, or do it yourself, I am sure it would be much appreciated and widely used.

Jagtig it looks cool, I'll take a look at it later.

CarlosAB April 19, 2018, at 03:46 PM

______________________

20-Mar-2018 : AllanGN - Hi, I'm not sure if I'm missing something or made a mistake somewhere. I tried this recipe but the site would only display a blank screen afterwards. The things I did/tried:

  • copied the googlewebfonts-20180319.php file to /cookbooks and added include_once('cookbook/googlewebfonts.php') to config.php, result: blank screen
  • then, renamed googlewebfonts-20180319.php to googlewebfonts.php in /cookbook: blank screen
  • next, tried changing the include_once line to include_once("$FarmD/cookbook/googlewebfonts.php"); : same, blank screen

I am using an older version of Pmwiki though, could it be a factor? (PHP version below as well)

  • Pmwiki version: "This site is running pmwiki-2.2.36 (VersionNum=2002036). 2002036."
  • Web server: PHP version: 5.6.30

I will check it and see what is going on, please don't load the recipe for while.

CarlosAB March 20, 2018, at 02:09 AM

At first sight, you need to (at least) update the Markup calls for PHP 7.2, see PmWiki:CustomMarkup. --Petko March 20, 2018, at 02:18 AM

It is all done I uploaded an old version, and I am sorry for that. The new version will be available in the recipe page right after this post and also, thanks Petko.

CarlosAB March 20, 2018, at 02:43 AM

Done! Tested it again and found a new problem that has been bugging me for a long time, the fonts returned by google as css include de protocol to access to the font files, and some browsers won't load http when using https to view the page. It will be solved in the next version. Once again sorry for any trouble that my mistake may have caused you. This version works with your pmwiki/php version and also new pmwiki/php versions.

CarlosAB March 20, 2018, at 02:52 AM

Hi, thanks for looking into it, no trouble at all and I really appreciate the effort. I've been looking at it and I believe the reason for my blank screens was my fault: in config.php, I'd forgotten to add the semi-colon at the end of the "include_once('cookbook/googlewebfonts.php')" line. Now the site's appearing ok.

To do more testing, I installed a fresh copy of the latest pmwiki-2.2.107 and installed the googlewebfonts recipe (and remembering to put the semi-colon at the end of the include line this time! I referred to it as "include_once('cookbook/googlewebfonts-20180320.php');" in config.php and uploaded the same file into /cookbook.). Unfortunately, I'm still getting just the same default font when I copy-paste the sample text under Usage of the recipe description. I checked on several browsers (Chrome 41, Palemoon 27.8.1, Firefox 59.0.1) and made sure that the browsers "Allow pages to choose their own fonts" in the Fonts settings (at least for the latter two).

By the way, the filename of the second version of the recipe seems to have a typo. It's named

  • googlewebfonts-201803020.php instead of
  • googlewebfonts-20180320.php

In my testing I renamed my local copy to googlewebfonts-20180320.php.

To make sure I could actually change the font in my Pmwiki test site I had success with this line:

%p font-family=monospace% This paragraph is in monospace. (actually looks monospace)

but not this line trying to access the GoogleWebFont "Butcherman":

%p font-family=butcherman% This is the butcherman webfont!!! (just looks like the default font)

It's like the googlewebfonts aren't loading for my test site?

AllanGN March 25, 2018, at 02:28 PM (GMT+11)

I reported that the script has a small problem, I'm not sure if this is affecting your site, but when using "https:" in some browsers the fonts will not load. Could please test it if that is the case? Also thanks for noticing my typos I will fix that.

Also there is a new type off cache that is being used on shared hosts, and it is distributed for free, so almost all shared host providers using cpanel are using it, and with that cache in place pages take a while to get an updated version in cache, to force update you have to echo somehing to the page or include a string via '$HTMLFooterFmt['random'] = "<pre>".rand(1000,9999)."</pre>";'. This helped me to finally see the fonts loading.

Plus, I found a way to show the fonts both on http and https, you just have to change the protocol for the url on:


#Change this
SDV($GoogleWebFontsUrl, "http://fonts.googleapis.com/css?");

#To this
SDV($GoogleWebFontsUrl, "https://fonts.googleapis.com/css?");

Doing that, fonts will load on both http and https.

For engintron I have found a workaround, like this:


# Just place this somewhere in your config.php
$HTMLFooterFmt['liveonengintron'] = "<pre style='display:none'>".rand()."</pre>";

I like to keep the version on file names, because you can also have access to old versions, compare them and this alone becomes somewhat didactic for newcomers. If you don't like it, please remove and load it on config.php just with the recipe name.

Also, you can check that everything I said I have used on my site, there are some font use examples there and also the hack to bypass engintron cache is active.

CarlosAB March 25, 2018, at 05:17 AM

I tried the changes you suggested but unfortunately, saw no change. Here's a link to my own site where I'm doing my testing http://www.naguit.com.au/pmwiki-2.2.107/pmwiki.php?n=Main.WikiSandbox.

Here's something strange. I went to your sandbox (codex.wiki.br/Main/WikiSandbox) and didn't see the googlewebfonts there either, so I'm thinking there could be something wrong with my setup, hosting or something. Tried several things for both your Sandbox and mine:

  • in a couple of different browsers,
  • under Linux and Windows desktops,
  • with and without VPN running,
  • via my Android phone and using two different ISPs (home cable and a mobile ISP)

Obviously you can see the different fonts so I'm now at a loss to understand why it's not working for me. Can you can see the googlewebfonts in my sandbox ( http://www.naguit.com.au/pmwiki-2.2.107/pmwiki.php?n=Main.WikiSandbox)?

AllanGN March 27, 2018, at 11:46 AM (GMT+11)

Hi AllanGN, you did everything right so far, the recipe is loaded, the GoogleWebFontsUrl uses https just like said, both nginx/engintron bypasses DO show up (look closer at the bottom near the closing body tag), but your server is not using nginx or engintron and it serving straight from an apache server ( I can't see the version), the version of your GoogleWebFont recipe is right and is the latest, all the markup you used for testing is also right but the only thing missing is the GoogleWebFontsUrl with the fonts choosen for the page, showing up in the source code of your page.

I found the first mistake: You have to use this on the page where you want the fonts loaded : (:loadfont AdventProUltraLightLatin , CreepsterNormalLatin, HennyPennyNormalLatin , ButchermanNormalLatin :)

Looking at action=ruleset :

searchresults    directives       B>>>=            
reservewebfonts  directives       B>>>=            
varindex         directives       B>>>=            

The rule is there.

Now, looking at action=diag we have to find three things, the markup loadfont, the recipe GoogleWebFontsUrl clean and another time with fonts to be loaded on $HTMLHeaderFmt['googlewebfonts'] :


# this the proof that the markup is loaded for the page
[reservewebfonts] => Array
                (
                    [cmd] => directives
                    [seq] => B>>>=
                    [pat] => /\(:loadfont\s+?(.*):\)/
                    [rep] => ´┐Żlambda_1
                )

# GoogleWebFontsUrl clean, it shows up on diag
[GoogleWebFontsUrl] => https://fonts.googleapis.com/css?

# but here is where the problem happens, the $HTMLHeaderFmt['googlewebfonts'] does not exist

Still the fonts don't get loaded on your page and also looking at the action=diag, the fonts are not processed and loaded there and the url+fonts do not show up on source code and also not on diag action.

Can you send me your config.php and also the recipe so I can take a look at it and make some tests?

Do you use a shared host with cpanel? Where errors are printed/stored ? Is there a error.log file I can look at?

CarlosAB March 27, 2018, at 01:51 AM

AllanGN, the recipe is fixed and soon enough you will be able to download in the recipe page a new version. Nut cracked ! :-) It was the very first thing Petko said to do, but I cracked it by force and debugging for a few hours. Haha ! That is what happens when you are not a pro developer like Petko and Pm.

CarlosAB March 27, 2018, at 03:31 AM

CarlosAB, it's working! Craaaack! :-) Butcherman and Creepster fonts are now showing on my test site. I think I'm just not invoking the other fonts correctly, but this playground is now open. Thanks so much, Carlos. You rock! (As for Petko and Pm, I've long been in awe of them. Actually, of pretty much every contributor here.) Thanks again.

AllanGN March 28, 2018, at 10:44 AM (GMT+11)

I got most of the other fonts in the recipe to work too. The ones I couldn't get to work were Ewert, Eater and Nosifer. I noticed the recipe specifies them where you see // with this var you can set fonts to be always loaded, could that have something to do with it?

Also, maybe the Cookbook description could include in the instructions how one would need to put on the target wikipage the "loadfont" line (modify to only include the desired fonts as required?), like how I had to in my testing:

(:loadfont AdventProNormalLatin, PlasterNormalLatin, EmblemaOneNormalLatin, HennyPennyNormalLatin, ButchermanNormalLatin, CreepsterNormalLatin, DrSugiyamaNormalLatin, MonotonNormalLatin, EwertNormalLatin, EaterNormalLatin, NosiferNormalLatin:)

AllanGN March 28, 2018, at 12:30 PM (GMT+11)

Ok, I'll put instructions on how to load the fonts with the directive '(:loadfont:)'.

You could not load the fonts, or you just wasn't able to use it. Sometimes the fonts get diferent names to call'em, but they get loaded.

I'll visit your wiki again to take a look ...


Hi, I think there's an issue with the attachment of the latest version of the recipe. Looks like it didn't upload correctly? Cheers

AllanGN Apr 03, 2018, at 12:56 PM (GMT+10)


That is weird, I was sure I had uploaded the script and tested it I also took a screenshot, anyway it is there now.

CarlosAB April 06, 2018, at 12:43 AM


All fonts in my test are now working (including the three I couldn't get working before) after updating to the googlewebfonts-20180329 version! Thanks, looks good!

AllanGN 08-Apr-18, 21:21 (GMT+10)


Good to hear it, have fun.

CarlosAB April 08, 2018, at 11:38 AM

Talk page for the GoogleWebFonts recipe (users).