How to use a custom font family in a custom Print format

I want to change the font family used in my custom Print format. The font family I want to use is on my Windows machine, it is exactly XXIINeueNorm-CndBlack and it is in TrueType format.

My question is: how can I load that font into ERPNext and use it in my custom Print format?

I have been trying to do this several times, following these links, but I have not been able:

I think something was missed to me, there is no way to change it and I need to be able to do this.

1 Like

I need to know how to implement that font in the Print Format.

This is a preview of the font:

Have you tried including the relevant Google Font in the Print Format CSS ?

1 Like

I used the import method in this way:

    @import url('');

    .print-format {
        font-family: "My Font" !important;

But the font I want to use is not part of Google Fonts.

I do not know if there is a way to convert a Desktop Font to a Web Font.


How can I do it?

I just figured out.

  1. Put font file in app_name/public/font folder.
    Your font should be accessible from http://localhost:8000/assets/app_name/font/Laksaman.ttf or or something like that.

  2. Use these css. (Mine use Laksaman font, you should change it to XXIINeueNorm-CndBlack)


{% set site_url = frappe.utils.get_url() %}

@font-face {
	font-family: 'Laksaman';
	font-style: normal;
	font-weight: 400;
	src: local('Laksaman Regular'), local('Laksaman-Regular'), url('{{ site_url }}/assets/app_name/font/Laksaman.ttf') format('truetype');

.print-format {
	font-family: 'Laksaman';


Odd thing is frappe.utils.get_url() will return http instead of https and will ending with :8000 (atleast for me, I might config something wrong) Which won’t work in production setup.

But this won’t work with wkhtmltopdf.
If printing pdf is more important you could install font on your server and simply use


.print-format {
	font-family: 'Laksaman';




Thanks for your response @pipech.
My font is accesible from http://ipv4_address:8080/assets/app_name/font/XXIINeueNorm-CndBlack.ttf, but, I received the error net::ERR_CONNECTION_REFUSED when I load the custom Doctype and see Print format.

Does error net::ERR_CONNECTION_REFUSED occur when you tried to get PDF print format?

What about html print format does it render with XXIINeueNorm-CndBlack font?

This error occurs only when the HTML print format is going to be displayed.

Finally, I could solve it @pipech.
The problem is that the frappe.utils.get_url() function only returns the host name or IPv4 address, not the port used, so it received the error net :: ERR_CONNECTION_REFUSED.





will make it work perfectly.

Many thanks for your help. :blush:

1 Like

That seems like a bad idea, it will cause error in production environment.
Because it’ll tried to access which did not exist and will cause the same error.

Exactly, unless you use an IP address to access your site, will not work correctly, but, by now, I am using an IP address.

That works. Thank you!