• Resolved Md Fathi Rahman

    (@fathi1999)


    Hi, I have created a custom tempalte and created fonts folder inside pdf folder. And added this CSS inside the /pdf/style.css file

    /* Load font */
    
    @font-face {
    
    ? ? font-family: 'Hind Siliguri';
    
    ? ? font-style: normal;
    
    ? ? font-weight: normal;
    
    ? ? src: local('Hind Siliguri Regular'), local('HindSiliguri-Regular'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-Regular.ttf) format('truetype');
    
    }
    
    @font-face {
    
    ? ? font-family: 'Hind Siliguri';
    
    ? ? font-style: normal;
    
    ? ? font-weight: bold;
    
    ? ? src: local('Hind Siliguri Bold'), local('HindSiliguri-Bold'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-Bold.ttf) format('truetype');
    
    }
    
    @font-face {
    
    ? ? font-family: 'Hind Siliguri';
    
    ? ? font-style: italic;
    
    ? ? font-weight: normal;
    
    ? ? src: local('Hind Siliguri Light Italic'), local('HindSiliguri-LightItalic'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-Light.ttf) format('truetype');
    
    }
    
    @font-face {
    
    ? ? font-family: 'Hind Siliguri';
    
    ? ? font-style: italic;
    
    ? ? font-weight: bold;
    
    ? ? src: local('Hind Siliguri SemiBold Italic'), local('HindSiliguri-SemiBoldItalic'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-SemiBold.ttf) format('truetype');
    
    }
    body {
    	background: #fff;
    	color: #000;
    	margin: 0cm;
    	font-family: 'Open Sans', sans-serif;
    	/* want to use custom fonts? https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-custom-fonts/ */
    	font-size: 9pt;
    	line-height: 100%; /* fixes inherit dompdf bug */
    	overflow-wrap: anywhere;
    	font-family: 'Hind Siliguri';
    }

    and changed font family inside body css.

    But the font is breaking, I have choosed my custom template and selected Extended currency symbol support and Enable font subsetting .

    The font is showing like this

    It should be ? ?????? ???????? ?????? How can I fix this? Even woocommerce is showing the font correctly.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Md Fathi Rahman

    (@fathi1999)

    Also tried mpdf version wpovernight/woocommerce-pdf-ips-mpdf: mPDF library for WooCommerce PDF Invoices & Packing Slips (github.com) Doesn’t work.

    As from previous year’s post I found this topic Unicode Font not Showing – page 2 | www.remarpro.com and Ewout?claimed that mpdf is fully compatible with unicode ?? . And I have also removed my custom template to make sure it works. mpdf and RTL is not working.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @fathi1999

    You have 2 font-family properties in body, you must have only 1. Is the style.css file well loaded in the HTML? What are the contents of your custom template directory?

    Thread Starter Md Fathi Rahman

    (@fathi1999)

    I used only one font family. And other variation, please take a loot at custom templates style.css

    /* Main Body */
    
    @page {
    
        margin-top: 1cm;
    
        margin-bottom: 3cm;
    
        margin-left: 2cm;
    
        margin-right: 2cm;
    
    }
    
    body {
    
        background: #fff;
    
        color: #000;
    
        margin: 0cm;
    
        font-family: 'Open Sans', sans-serif;
    
        /* want to use custom fonts? https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-custom-fonts/ */
    
        font-size: 9pt;
    
        line-height: 100%; /* fixes inherit dompdf bug */
    
        overflow-wrap: anywhere;
    
        font-family: 'Kalpurush';
    
    }
    
    h1, h2, h3, h4 {
    
        font-weight: bold;
    
        margin: 0;
    
    }
    
    h1 {
    
        font-size: 16pt;
    
        margin: 5mm 0;
    
    }
    
    h2 {
    
        font-size: 14pt;
    
    }
    
    h3, h4 {
    
        font-size: 9pt;
    
    }
    
    ol,
    
    ul {
    
        list-style: none;
    
        margin: 0;
    
        padding: 0;
    
    }
    
    li,
    
    ul {
    
        margin-bottom: 0.75em;
    
    }
    
    p {
    
        margin: 0;
    
        padding: 0;
    
    }
    
    p + p {
    
        margin-top: 1.25em;
    
    }
    
    a {
    
        border-bottom: 1px solid;
    
        text-decoration: none;
    
    }
    
    /* Basic Table Styling */
    
    table {
    
        border-collapse: collapse;
    
        border-spacing: 0;
    
        page-break-inside: always;
    
        border: 0;
    
        margin: 0;
    
        padding: 0;
    
    }
    
    th, td {
    
        vertical-align: top;
    
        text-align: left;
    
    }
    
    table.container {
    
        width:100%;
    
        border: 0;
    
    }
    
    tr.no-borders,
    
    td.no-borders {
    
        border: 0 !important;
    
        border-top: 0 !important;
    
        border-bottom: 0 !important;
    
        padding: 0 !important;
    
        width: auto;
    
    }
    
    div.bottom-spacer {
    
        clear: both;
    
        height: 8mm;
    
    }
    
    /* Header */
    
    table.head {
    
        margin-bottom: 12mm;
    
    }
    
    td.header img {
    
        max-height: 3cm; /* may be overriden by the settings */
    
        width: auto;
    
    }
    
    td.header {
    
        font-size: 16pt;
    
        font-weight: 700;
    
    }
    
    td.shop-info {
    
        width: 40%;
    
    }
    
    .document-type-label {
    
        text-transform: uppercase;
    
    }
    
    /* Recipient addressses & order data */
    
    table.order-data-addresses {
    
        width: 100%;
    
        margin-bottom: 10mm;
    
    }
    
    table.order-data-addresses td.address,
    
    table.order-data-addresses td.order-data {
    
        overflow-wrap: anywhere;
    
    }
    
    td.order-data {
    
        width: 40%;
    
    }
    
    td.order-data table {
    
        width: 100%;
    
    }
    
    td.order-data table th {
    
        font-weight: normal;
    
        padding-right: 2mm;
    
        width: 50%;
    
    }
    
    .invoice .shipping-address {
    
        width: 30%;
    
    }
    
    .packing-slip .billing-address {
    
        width: 30%;
    
    }
    
    /* Order details */
    
    table.order-details {
    
        width:100%;
    
        margin-bottom: 8mm;
    
        page-break-before: avoid;
    
    }
    
    .quantity,
    
    .price {
    
        width: 20%;
    
    }
    
    .order-details tr {
    
        page-break-inside: always;
    
        page-break-after: auto;
    
    }
    
    .order-details td,
    
    .order-details th {
    
        border-bottom: 1px #ccc solid;
    
        border-top: 1px #ccc solid;
    
        padding: 0.375em;
    
    }
    
    .order-details th {
    
        font-weight: bold;
    
        text-align: left;
    
    }
    
    .order-details thead th {
    
        color: white;
    
        background-color: black;
    
        border-color: black;
    
    }
    
    /* product bundles compatibility */
    
    .order-details tr.bundled-item td.product {
    
        padding-left: 5mm;
    
    }
    
    .order-details tr.product-bundle td,
    
    .order-details tr.bundled-item td {
    
        border: 0;
    
    }
    
    .order-details tr.bundled-item.hidden {
    
        display: none;
    
    }
    
    /* item meta formatting for WC2.6 and older */
    
    dl {
    
        margin: 4px 0;
    
    }
    
    dt, dd, dd p {
    
        display: inline;
    
        font-size: 7pt;
    
        line-height: 7pt;
    
    }
    
    dd {
    
        margin-left: 5px;
    
    }
    
    dd:after {
    
        content: "\A";
    
        white-space: pre;
    
    }
    
    /* item-meta formatting for WC3.0+ */
    
    .wc-item-meta {
    
        margin: 4px 0;
    
        font-size: 7pt;
    
        line-height: 7pt;
    
        overflow-wrap: anywhere;
    
    }
    
    .wc-item-meta p {
    
        display: inline;
    
    }
    
    .wc-item-meta li {
    
        margin: 0;
    
        margin-left: 5px;
    
    }
    
    /* Notes & Totals */
    
    .document-notes,
    
    .customer-notes {
    
        margin-top: 5mm;
    
        overflow-wrap: anywhere;
    
    }
    
    table.totals {
    
        width: 100%;
    
        margin-top: 5mm;
    
        table-layout: fixed;
    
    }
    
    table.totals th,
    
    table.totals td {
    
        border: 0;
    
        border-top: 1px solid #ccc;
    
        border-bottom: 1px solid #ccc;
    
    }
    
    table.totals th.description,
    
    table.totals td.price {
    
        width: 50%;
    
    }
    
    table.totals tr.order_total td,
    
    table.totals tr.order_total th {
    
        border-top: 2px solid #000;
    
        border-bottom: 2px solid #000;
    
        font-weight: bold;
    
    }
    
    table.totals tr.payment_method {
    
        display: none;
    
    }
    
    /* Footer Imprint */
    
    #footer {
    
        position: absolute;
    
        bottom: -2cm;
    
        left: 0;
    
        right: 0;
    
        height: 2cm; /* if you change the footer height, don't forget to change the bottom (=negative height) and the @page margin-bottom as well! */
    
        text-align: center;
    
        border-top: 0.1mm solid gray;
    
        margin-bottom: 0;
    
        padding-top: 2mm;
    
    }
    
    /* page numbers */
    
    .pagenum:before {
    
        content: counter(page);
    
    }
    
    .pagenum,.pagecount {
    
        font-family: sans-serif;
    
    }
    
    /* Load font */
    
    @font-face {
    
        font-family: 'Kalpurush';
    
        font-style: normal;
    
        font-weight: normal;
    
        src: local('Kalpurush'), local('Kalpurush'), url(<?php echo $this->get_template_path(); ?>/fonts/kalpurush.ttf) format('truetype');
    
    }
    
    @font-face {
    
        font-family: 'Kalpurush';
    
        font-style: normal;
    
        font-weight: bold;
    
        src: local('Kalpurush Bold'), local('Kalpurush-Bold'), url(<?php echo $this->get_template_path(); ?>/fonts/kalpurush.ttf) format('truetype');
    
    }
    
    @font-face {
    
        font-family: 'Kalpurush';
    
        font-style: italic;
    
        font-weight: normal;
    
        src: local('Kalpurush Italic'), local('Kalpurush-Italic'), url(<?php echo $this->get_template_path(); ?>/fonts/kalpurush.ttf) format('truetype');
    
    }
    
    @font-face {
    
        font-family: 'Kalpurush';
    
        font-style: italic;
    
        font-weight: bold;
    
        src: local('Kalpurush Bold Italic'), local('Kalpurush-BoldItalic'), url(<?php echo $this->get_template_path(); ?>/fonts/kalpurush.ttf) format('truetype');
    
    }
    Thread Starter Md Fathi Rahman

    (@fathi1999)

    *Update I used only one font family. And other variation, please take a loot at custom templates?style.css

    /* Main Body */
    
    @page {
    
        margin-top: 1cm;
    
        margin-bottom: 3cm;
    
        margin-left: 2cm;
    
        margin-right: 2cm;
    
    }
    
    body {
    
        background: #fff;
    
        color: #000;
    
        margin: 0cm;
    
        font-family: 'Hind Siliguri';
    
        /* want to use custom fonts? https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-custom-fonts/ */
    
        font-size: 9pt;
    
        line-height: 100%; /* fixes inherit dompdf bug */
    
        overflow-wrap: anywhere;
    
    }
    
    h1, h2, h3, h4 {
    
        font-weight: bold;
    
        margin: 0;
    
    }
    
    h1 {
    
        font-size: 16pt;
    
        margin: 5mm 0;
    
    }
    
    h2 {
    
        font-size: 14pt;
    
    }
    
    h3, h4 {
    
        font-size: 9pt;
    
    }
    
    ol,
    
    ul {
    
        list-style: none;
    
        margin: 0;
    
        padding: 0;
    
    }
    
    li,
    
    ul {
    
        margin-bottom: 0.75em;
    
    }
    
    p {
    
        margin: 0;
    
        padding: 0;
    
    }
    
    p + p {
    
        margin-top: 1.25em;
    
    }
    
    a {
    
        border-bottom: 1px solid;
    
        text-decoration: none;
    
    }
    
    /* Basic Table Styling */
    
    table {
    
        border-collapse: collapse;
    
        border-spacing: 0;
    
        page-break-inside: always;
    
        border: 0;
    
        margin: 0;
    
        padding: 0;
    
    }
    
    th, td {
    
        vertical-align: top;
    
        text-align: left;
    
    }
    
    table.container {
    
        width:100%;
    
        border: 0;
    
    }
    
    tr.no-borders,
    
    td.no-borders {
    
        border: 0 !important;
    
        border-top: 0 !important;
    
        border-bottom: 0 !important;
    
        padding: 0 !important;
    
        width: auto;
    
    }
    
    div.bottom-spacer {
    
        clear: both;
    
        height: 8mm;
    
    }
    
    /* Header */
    
    table.head {
    
        margin-bottom: 12mm;
    
    }
    
    td.header img {
    
        max-height: 3cm; /* may be overriden by the settings */
    
        width: auto;
    
    }
    
    td.header {
    
        font-size: 16pt;
    
        font-weight: 700;
    
    }
    
    td.shop-info {
    
        width: 40%;
    
    }
    
    .document-type-label {
    
        text-transform: uppercase;
    
    }
    
    /* Recipient addressses & order data */
    
    table.order-data-addresses {
    
        width: 100%;
    
        margin-bottom: 10mm;
    
    }
    
    table.order-data-addresses td.address,
    
    table.order-data-addresses td.order-data {
    
        overflow-wrap: anywhere;
    
    }
    
    td.order-data {
    
        width: 40%;
    
    }
    
    td.order-data table {
    
        width: 100%;
    
    }
    
    td.order-data table th {
    
        font-weight: normal;
    
        padding-right: 2mm;
    
        width: 50%;
    
    }
    
    .invoice .shipping-address {
    
        width: 30%;
    
    }
    
    .packing-slip .billing-address {
    
        width: 30%;
    
    }
    
    /* Order details */
    
    table.order-details {
    
        width:100%;
    
        margin-bottom: 8mm;
    
        page-break-before: avoid;
    
    }
    
    .quantity,
    
    .price {
    
        width: 20%;
    
    }
    
    .order-details tr {
    
        page-break-inside: always;
    
        page-break-after: auto;
    
    }
    
    .order-details td,
    
    .order-details th {
    
        border-bottom: 1px #ccc solid;
    
        border-top: 1px #ccc solid;
    
        padding: 0.375em;
    
    }
    
    .order-details th {
    
        font-weight: bold;
    
        text-align: left;
    
    }
    
    .order-details thead th {
    
        color: white;
    
        background-color: black;
    
        border-color: black;
    
    }
    
    /* product bundles compatibility */
    
    .order-details tr.bundled-item td.product {
    
        padding-left: 5mm;
    
    }
    
    .order-details tr.product-bundle td,
    
    .order-details tr.bundled-item td {
    
        border: 0;
    
    }
    
    .order-details tr.bundled-item.hidden {
    
        display: none;
    
    }
    
    /* item meta formatting for WC2.6 and older */
    
    dl {
    
        margin: 4px 0;
    
    }
    
    dt, dd, dd p {
    
        display: inline;
    
        font-size: 7pt;
    
        line-height: 7pt;
    
    }
    
    dd {
    
        margin-left: 5px;
    
    }
    
    dd:after {
    
        content: "\A";
    
        white-space: pre;
    
    }
    
    /* item-meta formatting for WC3.0+ */
    
    .wc-item-meta {
    
        margin: 4px 0;
    
        font-size: 7pt;
    
        line-height: 7pt;
    
        overflow-wrap: anywhere;
    
    }
    
    .wc-item-meta p {
    
        display: inline;
    
    }
    
    .wc-item-meta li {
    
        margin: 0;
    
        margin-left: 5px;
    
    }
    
    /* Notes & Totals */
    
    .document-notes,
    
    .customer-notes {
    
        margin-top: 5mm;
    
        overflow-wrap: anywhere;
    
    }
    
    table.totals {
    
        width: 100%;
    
        margin-top: 5mm;
    
        table-layout: fixed;
    
    }
    
    table.totals th,
    
    table.totals td {
    
        border: 0;
    
        border-top: 1px solid #ccc;
    
        border-bottom: 1px solid #ccc;
    
    }
    
    table.totals th.description,
    
    table.totals td.price {
    
        width: 50%;
    
    }
    
    table.totals tr.order_total td,
    
    table.totals tr.order_total th {
    
        border-top: 2px solid #000;
    
        border-bottom: 2px solid #000;
    
        font-weight: bold;
    
    }
    
    table.totals tr.payment_method {
    
        display: none;
    
    }
    
    /* Footer Imprint */
    
    #footer {
    
        position: absolute;
    
        bottom: -2cm;
    
        left: 0;
    
        right: 0;
    
        height: 2cm; /* if you change the footer height, don't forget to change the bottom (=negative height) and the @page margin-bottom as well! */
    
        text-align: center;
    
        border-top: 0.1mm solid gray;
    
        margin-bottom: 0;
    
        padding-top: 2mm;
    
    }
    
    /* page numbers */
    
    .pagenum:before {
    
        content: counter(page);
    
    }
    
    .pagenum,.pagecount {
    
        font-family: 'Hind Siliguri';
    
    }
    
    /* Load font */
    
    @font-face {
    
        font-family: 'Hind Siliguri';
    
        font-style: normal;
    
        font-weight: normal;
    
        src: local('Hind Siliguri Regular'), local('HindSiliguri-Regular'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-Regular.ttf) format('truetype');
    
    }
    
    @font-face {
    
        font-family: 'Hind Siliguri';
    
        font-style: normal;
    
        font-weight: bold;
    
        src: local('Hind Siliguri Bold'), local('HindSiliguri-Bold'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-Bold.ttf) format('truetype');
    
    }
    
    @font-face {
    
        font-family: 'Hind Siliguri';
    
        font-style: italic;
    
        font-weight: normal;
    
        src: local('Hind Siliguri Light Italic'), local('HindSiliguri-LightItalic'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-Light.ttf) format('truetype');
    
    }
    
    @font-face {
    
        font-family: 'Hind Siliguri';
    
        font-style: italic;
    
        font-weight: bold;
    
        src: local('Hind Siliguri SemiBold Italic'), local('HindSiliguri-SemiBoldItalic'), url(<?php echo $this->get_template_path(); ?>/fonts/HindSiliguri-SemiBold.ttf) format('truetype');
    
    }
    Thread Starter Md Fathi Rahman

    (@fathi1999)

    Update 2

    I have set the output to HTML output and the font is coming in correct way. But customer’s are getting broken pdf.

    Here the view from admin

    https://ibb.co/hVs4Mct

    Here the view of the Customer Invoice

    https://ibb.co/MZThZkK

    Plugin Contributor dwpriv

    (@dwpriv)

    @fathi1999

    could you share a screenshot of the items in your custom template directory?

    Thread Starter Md Fathi Rahman

    (@fathi1999)

    Here is the screenshot: https://ibb.co/qM6TTCK

    Located in Woocommerce/pdf/templatename

    Plugin Contributor dwpriv

    (@dwpriv)

    @fathi1999

    In your body CSS, could you comment out the Sans serif font-family line and see if that fixes it?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @fathi1999,

    Since we haven’t heard back from you in the last two weeks, we’re assuming you solved this issue, so I’ll go ahead and mark this ticket as Resolved.

    Feel free to reply to this topic is you still need help with this, or open a new topic if you have any other questions!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Bangla Font Breaking After Creating New Template’ is closed to new replies.