Support » Requests and Feedback » Google Font Builder

  • alicewondermiscreations

    (@alicewondermiscreations)



    What I’m looking for is a class in core that builds a URL to use with Google Fonts.

    But also has a look that allows a plugin to refine the host from fonts.googleapis.com to something else.

    It wouldn’t be too hard to write a plugin that does it, but it needs to be in core so that themes can use it.

    The problem to be solved: Most themes hard-code fonts.googleapis.com which is a domain that tracks, yet most (virtually all) fonts are SIL OFL and can be hosted anywhere.

    It would be awesome to give blogmasters the option of using an alternate font server that is compatible with the same GET query but does not track.

    With the CLOUD act – which effectively turns third party trackers into a tool for government surveillance here in the United States – many people are rightfully starting to finally get paranoid about third party trackers and are blocking them. Not just with Privacy Badger, FireFox now has a built in setting to block resources that track, and unlike Privacy Badger, it doesn’t have a white list.

    So the ability to use a font server that doesn’t track would be very beneficial to blogmasters, as fonts in a website can have a huge impact on the look and feel of the site.

    Providing a common class / function to build the query and then append it to a host of the blogmaster’s choosing (defaulting to google fonts) would be of tremendous value.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    What I’m looking for is a class in core that builds a URL to use with Google Fonts.

    Why wouldn’t that be in a plugin? Or continue to be theme specific?

    alicewondermiscreations

    (@alicewondermiscreations)

    The only way it could be a plugin would be a must-use plugin, because it would need to load before other plugins and themes in order to ensure that it is available for themes and plugins to use.

    WordPress does not have a dependency structure where Plugin/Theme A can require Plugin B *and* guarantee that Plugin B loads first.

    There is TGMPA (functionality which honestly also should be part of core) but TGMPA does not guarantee a required plugin will load first.

    So the only way to do it would be for every theme to include it in their own source (like they have to do with TGMPA) which means an if (! class_exists()) to load it which means conflicts as different versions load incompatible or modified versions.

    Having it as part of core means any theme that wants to use Google Fonts can use it with a stable API.

    alicewondermiscreations

    (@alicewondermiscreations)

    Being a “must use” plugin would guarantee it loads before themes and other plugins, but the problem with it being a “must use” plugin is that mu plugins must be manually installed and updated and manually removed.

    That’s why it needs to be part of core.

    Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    The only way it could be a plugin would be a must-use plugin, because it would need to load before other plugins and themes in order to ensure that it is available for themes and plugins to use.

    No, I mean why is this a core request? What’s the case for that? Yes, I see why you’d want it but having that as it currently is, is a theme decision.

    Using built in fonts was something that implemented (re-implemented really) in WordPress 4.6.

    https://make.wordpress.org/core/2016/07/07/native-fonts-in-4-6/

    I’m not getting why make a dependency or even support 3rd party fonts from Google. That seems like it it’s theme territory and not a built in. As you’re probably aware there are places where Google fonts often fail such as in China.

    alicewondermiscreations

    (@alicewondermiscreations)

    I am not suggesting making a dependency on third party fonts.

    If you look at actual usage, Google Fonts is what theme developers use.

    And they hard code a domain for them that is both known to track and gets blocked by tracking software.

    What I am suggesting is a tool they can use to create the webfont CSS url that by default uses google fonts but has a hook to allow a blogmaster to change what domain is used for the webfonts.

    Theme developers are going to continue to use Google Fonts.

    This would allow them to do so in such a way that blogmasters can have the same benefit (selection of beautiful fonts) with the ability to change the domain they are served from.

    alicewondermiscreations

    (@alicewondermiscreations)

    $wp_font_builder->setFont(‘Noto+Sans’,array(400,700),’italic’);
    $wp_font_builder->setFont(‘Noto+Serif’,array(400,700),’italic’);
    $wp_font_builder->setFont(‘Libre+Franklin’,array(400,700.900));
    $wp_font_builder->setSubset(array(‘latin’,’ext-latin’));

    That’s all a theme developer should need to do to have WordPress create a link to a CSS file in the head that grabs regular and bold Noto Sans and Noto Serif with the Italic variant, and Libre Franklin in the regular, bold, and book weights but upright only, no italic variant – with latin and ext-latin as the specified character sets.

    The wp_font_builder object would use fonts.googleapis.com by default – but the blogmaster could define a different host in their wordpress preferences.

    That is what I am suggesting.

    alicewondermiscreations

    (@alicewondermiscreations)

    Something like this gist – which is completely untested but I will test/fix.

    https://gist.github.com/AliceWonderMiscreations/b0071e48a27a536142ce38bf6868336b

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.