• Resolved hs777it

    (@hs777it)


    I want to change font in invoice and packing slip
    i tried this function code

    
    /* Change Packing Slip Font / Appearance */
    add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
    function wpo_wcpdf_custom_styles ( $document_type, $document ) {
        ?>
    	*[dir="rtl"],@page,body {
    	font-family: Arial;
      }
        <?php
    }
    
    

    also tried with css

    
    *[dir="rtl"] {
    	font-family: Arial;
      }
    
    @page {
    	font-family: Arial, Helvetica, sans-serif !important;
    }
    body {
    	font-family: Arial, Helvetica, sans-serif !important;
    }
    

    please help me

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @hs777it

    Please refer the documentation page: Using custom fonts

    Thread Starter hs777it

    (@hs777it)

    if i want to use google fonts ?

    Plugin Contributor alexmigf

    (@alexmigf)

    Same procedure, you download them and follow the steps. Don’t forget that only TTF fonts are supported and you can’t use numeric font weights (like 700 instead of bold).

    Thread Starter hs777it

    (@hs777it)

    when i put code to style.css i get error in phpurl(<?php echo $this->get_template_path(); ?>/fonts/myfont.ttf) format('truetype');

    
    /* Load font */
    @font-face {
        font-family: 'MyFont';
        font-style: normal;
        font-weight: normal;
        src: local('MyFont'), local('MyFont'), url(<?php echo $this->get_template_path(); ?>/fonts/myfont.ttf) format('truetype');
    }
    Plugin Contributor alexmigf

    (@alexmigf)

    Which php error do you see?

    Thread Starter hs777it

    (@hs777it)

    nothing just error apear in IDE and font not work

    could you give code to applay any font ?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @hs777it

    The code needed is supplied in the documentation page, if you follow all the steps it should work without any errors.

    Thread Starter hs777it

    (@hs777it)

    I follow all the steps and try to copy font folder to website root but not work
    https://ibb.co/zRtJtNw

    • This reply was modified 4 years, 2 months ago by hs777it.
    Plugin Contributor Ewout

    (@pomegranate)

    wrong folder. Your CSS points to /fonts in your custom template folder, not the site root.

    Thread Starter hs777it

    (@hs777it)

    I tried to copy /fonts to custom template folder but not working

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @hs777it

    Can you show me your current directory structure for the custom template?

    Did you added this?

    body {
        font-family: 'Arial';
    }
    Thread Starter hs777it

    (@hs777it)

    current directory structure for the custom template
    https://ibb.co/82Tf6TL

    Thread Starter hs777it

    (@hs777it)

    and this is css code

    /* Load font */
    @font-face {
        font-family: 'Arial';
        font-style: normal;
        font-weight: normal;
        src: local('Arial'), local('Arial'), url(<?php echo $this->get_template_path(); ?>/fonts/arial.ttf) format('truetype');
    }
    @font-face {
        font-family: 'Arial';
        font-style: normal;
        font-weight: bold;
        src: local('Arial Bold'), local('Arial-Bold'), url(<?php echo $this->get_template_path(); ?>/fonts/arial-bold.ttf) format('truetype');
    }
    @font-face {
        font-family: 'Arial';
        font-style: italic;
        font-weight: normal;
        src: local('Arial Italic'), local('Arial-Italic'), url(<?php echo $this->get_template_path(); ?>/fonts/arial-italic.ttf) format('truetype');
    }
    @font-face {
        font-family: 'Arial';
        font-style: italic;
        font-weight: bold;
        src: local('Arial Bold Italic'), local('Arial-BoldItalic'), url(<?php echo $this->get_template_path(); ?>/fonts/arial-bolditalic.ttf) format('truetype');
    }
    
    /* Main Body */
    
    *[dir="rtl"] {
    	font-family: 'Arial';
      }
    
    @page {
    	font-family: 'Arial';
    	margin-top: 0.7cm;
    	margin-bottom: 0.7cm;
    	margin-left: 0.7cm;
    	margin-right: 0.7cm;
    }
    body {
    	font-family: 'Arial';
    	direction: rtl;
    	background: #fff;
    	color: #000;
    	margin: 0cm;
    	font-size: 9pt;
    	line-height: 100%; /* fixes inherit dompdf bug */
    }
    Thread Starter hs777it

    (@hs777it)

    please help me

    Plugin Contributor Ewout

    (@pomegranate)

    Thanks for sharing that extra information. If I understand correctly, you are not using the default PDF engine (dompdf) but the mpdf extension. This works differently, check out this forum post: custom fonts with mpdf.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘change font in invoice’ is closed to new replies.