• Has anyone been able to get dynamic font loading to work. I’ve tried every which way to get Fontsampler to see the font file but to no avail.

    My last effort was something like:

    [fontsampler id=252 fonts="{"woff":"types.com/uploads/HastricoDT-BoldItalic.woff", "name":"HastricoDT BoldItalic", "initial":true}"]
    

    Any suggestions appreciated.
    thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author kontur

    (@kontur)

    Hey Malcom,

    the syntax looks right. Could you try make either the outer-most quotes for the fonts attribute single quotes, or all the inner ones double ones? I think WP might not be able to parse the fonts attribute correctly if both the outer quotes and the quotes inside the fonts-string are the same.

    J

    Plugin Author kontur

    (@kontur)

    Also the URL for the woff needs to resolve to a file on your server. So if you try “types.com/uploads/HastricoDT-BoldItalic.woff” in the browser it should find a file, and probably prompt a download. If you see anything else, like a 404 page, it likely means the file path is not correct or the file does not exist. Revise the URL ??

    Thread Starter Malcolm Wooden

    (@malcolm-wooden)

    Hey Johannes,

    Many thanks for the suggestions, but no luck I’m afraid. I can download the font file by putting the path in the browser address bar, but the same path syntax will not work in Fontsampler.

    I also tried to change the quotes as you suggested.

    This is a page that should have a Fontsampler with dynamic font replacement, but the original sans font is still showing and not the replacement script font.
    https://dtptypes.com/atestpage

    Malcolm

    Plugin Author kontur

    (@kontur)

    Hey Malcom,

    on that page, the sampler html receives these font paths from the shortcode: data-fonts=”//dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff”

    could you try with and extra “:” in front, or give the full “https://...“, e.g.: “://dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff

    Cheers,
    Johannes

    Thread Starter Malcolm Wooden

    (@malcolm-wooden)

    Hey Johannes,

    I still not been able to get this to work on my site. Perhaps it’s something in the way my site is configured.

    Do you know of a site that’s using this feature so I can see how it’s working there?

    thanks
    Malcolm

    Plugin Author kontur

    (@kontur)

    Hey, you can check the output on [my site](https://underscoretype.com/fonts/constant/), the sampler at the top. The PHP code of this looks like this:

    
    <?php 
    echo do_shortcode("[fontsampler text='Try out " . $post->post_title . " for yourself, type here...' fonts='" . $files . "']"); 
    ?>
    

    $files is a string which holds the output as you can see it when inspecting the page.

    On your above linked testpage I still see:

    ...data-fonts="//dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff"...

    “//dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff” is not a valid URL, either “://dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff” or give the full “https://dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff&#8221;

    Thread Starter Malcolm Wooden

    (@malcolm-wooden)

    Okay, so I have been looking at this all wrong!

    I was thinking that the dynamic font code was an argument added to an existing Fontsampler shortcode that would change the original font set.

    I’ll have to re-asses how I’ll do this.

    thanks
    Malcolm

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Dynamic Font Loading’ is closed to new replies.