I’m using custom (commercial) fonts in my project. Everything works well in the frontend.
I noticed however that, when trying to add this font to the TinyMCE iframe, I get a 403 for the webfonts. The problem seems to be, that requests from the iframe do not have a referrer. And fonts.com needs a referrer to validate the request.
Any thoughts?
I ran into this issue with Typekit, here’s my solution:
http://www.tomjn.com/150/typekit-wp-editor-styles/
and this js:
It inserts the typekit code inside the iframe, you’ll want to change the code to the fonts.com embed script and test. Unfortunately, I’m unfamiliar with the security safeguards at fonts.com and the exact embed codes they used
If you want add your custom styles to TinyMCE editor in WordPress, you need to create a css file, for instance
editor.css
and put it into your theme folder. After it, add your font face initialization in this css, like this:Then you need to properly enqueue your
editor.css
file. To do it you need to calladd_editor_style
style function:If you have
.ttf
font file only, you need to convert it to.woff
. You can do it here.Use this function in your plugin or theme’s functions.php file:
So we called a customfont.php file to wp editor. This file is a php file but will work as a css file. And this is our customfont.php:
This is an example from Firmasite theme. Maybe this will work for you. If you still getting 403, you can add some php header like
header("Referer: http://example.org");