Title: Dynamic Font Loading
Last modified: June 15, 2022

---

# Dynamic Font Loading

 *  [Malcolm Wooden](https://wordpress.org/support/users/malcolm-wooden/)
 * (@malcolm-wooden)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/)
 * 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](https://wordpress.org/support/users/kontur/)
 * (@kontur)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15739025)
 * 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](https://wordpress.org/support/users/kontur/)
 * (@kontur)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15739034)
 * 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](https://wordpress.org/support/users/malcolm-wooden/)
 * (@malcolm-wooden)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15743215)
 * 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](https://dtptypes.com/atestpage)
 * Malcolm
    -  This reply was modified 3 years, 11 months ago by [Malcolm Wooden](https://wordpress.org/support/users/malcolm-wooden/).
 *  Plugin Author [kontur](https://wordpress.org/support/users/kontur/)
 * (@kontur)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15745724)
 * 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
    -  This reply was modified 3 years, 11 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [Malcolm Wooden](https://wordpress.org/support/users/malcolm-wooden/)
 * (@malcolm-wooden)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15759856)
 * 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](https://wordpress.org/support/users/kontur/)
 * (@kontur)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15761843)
 * Hey, you can check the output on [my site]([https://underscoretype.com/fonts/constant/](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](https://dtptypes.com/wp-content/uploads/2021/03/HastricoDT-Bold.woff&#8221);
 *  Thread Starter [Malcolm Wooden](https://wordpress.org/support/users/malcolm-wooden/)
 * (@malcolm-wooden)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15764129)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/fontsampler_e1c3c0.svg)
 * [Fontsampler](https://wordpress.org/plugins/fontsampler/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fontsampler/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fontsampler/)
 * [Active Topics](https://wordpress.org/support/plugin/fontsampler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fontsampler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fontsampler/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Malcolm Wooden](https://wordpress.org/support/users/malcolm-wooden/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/dynamic-font-loading/#post-15764129)
 * Status: not resolved