Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ewout

    (@pomegranate)

    Hi ggore,
    That sounds odd, but it could just be that the font is not loading properly. How do you load them? It could be that you haven’t loaded the bold/italic/bold italic version of the plugin, and that for example an H2 or H3 is not displaying correctly because of that (it will fall back to one of the default fonts).

    If you are using remote fonts; here’s a rundown of everything you need to know when working with remote fonts. I wish it was easier, but unfortunately it’s not.
    I highly recommend to download the fonts to your server instead!

    Hey Ewout,

    thanks for your answer. I downloaded the fonts on my server. This is how I am loading them: @font-face {
    font-family: ‘regencielight’;
    src: url(‘fonts/regencielight-webfont.eot’);
    src: url(‘fonts/regencielight-webfont.eot?#iefix’) format(’embedded-opentype’),
    url(‘fonts/regencielight-webfont.woff’) format(‘woff’),
    url(‘fonts/regencielight-webfont.ttf’) format(‘truetype’),
    url(‘fonts/regencielight-webfont.svg#regencielight’) format(‘svg’);
    font-weight: normal;
    font-style: normal;
    }

    I dont use an italic or bold version of my font. I changed h2 to my purposes.

    I dont know what to do 🙁

    Plugin Author Ewout

    (@pomegranate)

    Hi Ggore,
    That won’t work because the pdf engine doesn’t know where the template is located – it only processes the resulting HTML/CSS. It is possible to use the server path instead of a url, but then you need a slightly different code (assuming you put them in your template folder under fonts/):

    @font-face {
    	font-family: 'Your font';
    	font-style: normal;
    	font-weight: normal;
    	src: local('Your font'), local('Your-font'), url(<?php echo $wpo_wcpdf->export->template_path. '/fonts/'; ?>yourfont.ttf) format('truetype');
    }
    @font-face {
    	font-family: 'Your font';
    	font-style: normal;
    	font-weight: bold;
    	src: local('Your font Bold'), local('Your-font-Bold'), url(<?php echo $wpo_wcpdf->export->template_path. '/fonts/'; ?>yourfont-bold.ttf) format('truetype');
    }

    You only need the ttf/truetype version, all other versions don’t work in the PDF engine.

    Also, as noted in the thread that I linked to: if you loaded the font in a wrong way once, you have to clear the PDF engine’s font cache, the easiest way to do that is to simply reinstall the plugin… If you don’t do this, it won’t display the correct font even if you load it the proper way, as it will have (broken) references to those fonts already.

    Can you send a PDF to support@wpovernight.com, with annotations to point out what is wrong so I can take a look at it?

    Ewout

    Hey Ewout, thank you. First I will try to reinstall the plugin and changing the font-face code. If I still have problems, then I will send you the PDF.

    Thanks for your help!

    This should also be in the FAQ, took me hours to find out.

    How to install the Corporate Identity fonts on the local server within a child theme, is what you really want/need to do when customizing the invoice pdf template.

    Plugin Author Ewout

    (@pomegranate)

    Thanks for the suggestion!
    I just noticed that the above code is not referencing the $wpo_wcpdf object, so it will not work.
    You can fix this by adding the following at the top of your css file:

    <?php global $wpo_wcpdf; ?>

    I have noticed that sometimes the path becomes too long, the most reliable way is to put the fonts in your site root and then link to the URL:

    src: local('Your font'), local('Your-font'), url(http://yoursite.com/fonts/yourfont.ttf) format('truetype');

    Moreover, a much better/more complete reference can be found here (as linked in the first reply):
    http://wordpress.org/support/topic/webfonts-within-a-custom-template-not-rendering-in-pdf?replies=4#post-5395442
    This will help to troubleshoot any issue that you run into. I have not included this in the FAQ yet because unfortunately the procedure is very sensitive to all sorts of errors and quirks… I wish it there was an easier way, but currently there isn’t.

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