[FIX] point_of_sale: html2canvas letterRendering is configurable

The `letterRendering` option from the html2canvas broke the receipt's characters of some localizations/languages such as the arabic one.

With this commit, we can simply override the `htmlToImgLetterRendering()` method from the `PosModel` when needed.

closes odoo/odoo#75870

X-original-commit: 8b2c9bd026c0b7296c7be819a992ccac24b9b2e3
Related: odoo/enterprise#20559
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Jacky (trj)
2021-09-02 12:57:51 +00:00
parent 334fb8533f
commit dc7050ccef
4 changed files with 8 additions and 3 deletions
@@ -1211,7 +1211,7 @@
textNode.nodeValue = textTransform(textNode.nodeValue, getCSS(el, "textTransform"));
textAlign = textAlign.replace(["-webkit-auto"],["auto"]);
textList = (!options.letterRendering && /^(left|right|justify|auto)$/.test(textAlign) && noLetterSpacing(getCSS(el, "letterSpacing"))) ?
textList = (!options.letterRendering && /^(left|right|justify|auto|center)$/.test(textAlign) && noLetterSpacing(getCSS(el, "letterSpacing"))) ?
textNode.nodeValue.split(/(\b| )/)
: textNode.nodeValue.split("");
@@ -98,7 +98,7 @@ odoo.define('point_of_sale.ReceiptScreen', function (require) {
return this.env.pos.proxy.printer && this.env.pos.config.iface_print_skip_screen && invoiced_finalized;
}
async _sendReceiptToCustomer() {
const printer = new Printer();
const printer = new Printer(null, this.env.pos);
const receiptString = this.orderReceipt.comp.el.outerHTML;
const ticketImage = await printer.htmlToImg(receiptString);
const order = this.currentOrder;
@@ -1437,6 +1437,9 @@ exports.PosModel = Backbone.Model.extend({
});
product_model.loaded(this, product);
},
htmlToImgLetterRendering() {
return false;
},
});
/**
@@ -45,6 +45,7 @@ var PrinterMixin = {
init: function() {
this.receipt_queue = [];
this.printResultGenerator = new PrintResultGenerator();
this.htmlToImgLetterRendering = false; // Whether to render each letter seperately. Necessary if letter-spacing is used.
},
/**
@@ -103,7 +104,7 @@ var PrinterMixin = {
$('.pos-receipt-print').empty();
resolve(self.process_canvas(canvas));
},
letterRendering: true,
letterRendering: self.htmlToImgLetterRendering,
})
});
return promise;
@@ -132,6 +133,7 @@ var Printer = core.Class.extend(PrinterMixin, {
init: function (url, pos) {
PrinterMixin.init.call(this, arguments);
this.pos = pos;
this.htmlToImgLetterRendering = pos.htmlToImgLetterRendering();
this.connection = new Session(undefined, url || 'http://localhost:8069', { use_cors: true});
},