Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Unicode Font not Showing

  • Resolved ninzas

    (@ninzas)


    Hi,
    Peace be upon you. Thanks for the excellent plugin. I am having a simple issue which is
    Unicode Bengali Text Not Showing in Invoice PDF. I tried to embed the custom font using font-face but still no change. Some Unicode Bengali font is SolaimanLipi, Siyam Rupali, Kalpurush etc. (Search on google to find the font download link). How do I solve this issue? Thanks in Advance

    Screenshot: https://prnt.sc/rrd9sh

    The page I need help with: [log in to see the link]

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

    (@pomegranate)

    Hi! Can you share the CSS (/PHP) you used for the font inclusion? Additionally, can you check on the Status tab of the PDF Invoice settings that the MB String extension is installed on your server?

    MBString is enable on Server. I change this code after uploading font in font folder.

    @font-face {
    font-family: ‘SolaimanLipi’;
    font-style: normal;
    font-weight: normal;
    src: url(“wp-content/themes/mediacenter/assets/css/fonts/SolaimanLipi.ttf”) format(‘truetype’);
    src: local(‘SolaimanLipi’), local(‘SolaimanLipi’), url(<?php echo $this->get_template_path(); ?>/wp-content/themes/mediacenter/assets/css/fonts/SolaimanLipi.ttf) format(‘truetype’);
    }

    Plugin Author Ewout

    (@pomegranate)

    it seems you have a duplicate in there:

    
    src: url("wp-content/themes/mediacenter/assets/css/fonts/SolaimanLipi.ttf")
    

    which doesn’t include the full base path. can you try removing that?

    Tried. not fixed yet.

    @font-face {
        font-family: 'SolaimanLipi';
        font-style: normal;
        font-weight: normal;
    	src: local('SolaimanLipi'), url(<?php echo $this->get_template_path(); ?>/wp-content/themes/mediacenter/assets/css/fonts/SolaimanLipi.ttf) format('truetype');
    }
    Plugin Author Ewout

    (@pomegranate)

    that doesn’t seem right to me either. The template path (<?php echo $this->get_template_path(); ?> is where you put your custom template, this probably does not have a wp-content/ subfolder. You seem to be wanting to link to a font in the main theme, but in that case you need to refer that differently.
    I think you either want:

    
    src: local('SolaimanLipi'), url(<?php echo WP_CONTENT_DIR; ?>/themes/mediacenter/assets/css/fonts/SolaimanLipi.ttf) format('truetype');
    

    or (if you put the font in the template folder under /fonts):

    
    src: local('SolaimanLipi'), url(<?php echo $this->get_template_path(); ?>/fonts/SolaimanLipi.ttf) format('truetype');
    

    Don’t forget to also add the bold font (for the titles/headers) and assignt his font to the body selector.

    Documentation is here: Using custom fonts

    asteriaowner

    (@asteriaowner)

    Hi Ewout, I was having similar issue and got the font working. But there is a new problem. We use conjunctive letters in words in Bangla language. Although the single letters are showing fine the conjunctive letters are breaking into single letters. Is there any solution to this problem? Thanks in advance.

    Plugin Support kluver

    (@kluver)

    Hi @asteriaowner,

    That might be an issue. Is your font supporting these conjunctive letters?

    asteriaowner

    (@asteriaowner)

    Hi I am sorry I missed the previous reply. Yes, the font supports conjunctive letters. Words are disrupted only in the pdf invoice. Thank you!

    devceer

    (@devceer)

    I also facing same problem. I have change the font family but it isn’t working. Font’s are disrupted in PDF invoice.
    https://wordpress.org/plugins/woocommerce-delivery-notes/
    this plugin is working fine without any code editing but I want

    WooCommerce PDF Invoices & Packing Slips

    to use.

    Plugin Author Ewout

    (@pomegranate)

    We use conjunctive letters in words in Bangla language. Although the single letters are showing fine the conjunctive letters are breaking into single letters. Is there any solution to this problem?

    I think that this is something that is not fully supported by the default PDF library that we use in this plugin, dompdf.
    However, it is possible to use other PDF libraries with this plugin, for example mpdf. While mpdf has its own quirks, it does offer better support for conjunctive letters and RTL script. You can find the latest releases here:
    https://github.com/wpovernight/woocommerce-pdf-ips-mpdf/releases

    When using this library, I recommend reverting to the default template first because applying both a custom font and using the mpdf library might create more issues. If you pick the .CJK version of the release, it is pretty much unicode complete and may already solve your issues without any custom code at all.

    Let us know if that helps!

    hassy008

    (@hassy008)

    Hey there I think i’m almost there but I don’t find the config_fonts.php inside MPDF in your suggested link. https://prnt.sc/updsrh this might be solve my issue. Can you please tell me where can I add
    “solaimanlipi” => array( ‘R’ => “SolaimanLipi.ttf”, ‘useOTL’ => 0xFF, ),
    line of code?

    Plugin Author Ewout

    (@pomegranate)

    Adding the custom font is not required with mpdf, Bengali is supported out of the box if you take the .CJK version.

    Plugin Author Ewout

    (@pomegranate)

    The custom font method from your screenshot is outdated (mpdf 6.0), with newer versions (we currently use 8.0) it’s much more elegant and can also be done on the fly:
    https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html

    You can add your own fontDir using the wpo_wcpdf_mpdf_options filter (don’t forget to also include the default fontdirs as per the above docs):
    https://github.com/wpovernight/woocommerce-pdf-ips-mpdf/blob/v2.2.0/wcpdf-mpdf.php#L48-L55

    Here’s an example following your code:

    
    add_filter( 'wpo_wcpdf_mpdf_options', function( $options ){
    	// get defaults
    	$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
    	$fontDir = $defaultConfig['fontDir'];
    	$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
    	$fontData = $defaultFontConfig['fontdata'];
    
    	// setup custom font dir & font data
    	$customFontDir = WPO_WCPDF()->settings->get_template_path() . '/fonts';
    	$customFontData = [
    		'solaimanlipi' => [
    			'R' => 'SolaimanLipi.ttf', // use 'B','I','BI' keys for Bold, Italic & Bold Italic respectively
    			'useOTL' => 0xFF,
    		],
    	];
    
    	// merge in options
    	$options['fontDir'] = array_merge( $fontDir, [ $customFontDir ] );
    	$options['fontdata'] = $fontData + $customFontData;
    
    	return $options;
    } );
    

    assuming you have placed SolaimanLipi.ttf inside /fonts in your template folder.

    hassy008

    (@hassy008)

    I already download, installed & activated .CJK file and then remove template folder from WooCommerce PDF Invoices & Packing Slips but nothing happened. That’s why I’m trying to fix another way

    Plugin Author Ewout

    (@pomegranate)

    If nothing happened, something else is wrong in your setup. It might be this:

    and then remove template folder from WooCommerce PDF Invoices & Packing Slip

    You shouldn’t remove anything. Just selecting the ‘Simple mpdf’ template is enough.

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.