UNPKG

ll-package

Version:

2 lines (1 loc) 1.69 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../../../../_virtual/shared.js");require("../help/merge.js");const d=require("../../../../_virtual/merge.js");Object.defineProperty(a.__exports,"__esModule",{value:!0});a.__exports.getTotalWidthOfEncodings=a.__exports.calculateEncodingAttributes=a.__exports.getBarcodePadding=a.__exports.getEncodingHeight=a.__exports.getMaximumHeightOfEncodings=void 0;var s=d.__exports,o=c(s);function c(t){return t&&t.__esModule?t:{default:t}}function f(t,e){return e.height+(e.displayValue&&t.text.length>0?e.fontSize+e.textMargin:0)+e.marginTop+e.marginBottom}function _(t,e,r){if(r.displayValue&&e<t){if(r.textAlign=="center")return Math.floor((t-e)/2);if(r.textAlign=="left")return 0;if(r.textAlign=="right")return Math.floor(t-e)}return 0}function h(t,e,r){for(var n=0;n<t.length;n++){var u=t[n],g=(0,o.default)(e,u.options),l;g.displayValue?l=v(u.text,g,r):l=0;var i=u.data.length*g.width;u.width=Math.ceil(Math.max(l,i)),u.height=f(u,g),u.barcodePadding=_(l,i,g)}}function x(t){for(var e=0,r=0;r<t.length;r++)e+=t[r].width;return e}function m(t){for(var e=0,r=0;r<t.length;r++)t[r].height>e&&(e=t[r].height);return e}function v(t,e,r){var n;if(r)n=r;else if(typeof document<"u")n=document.createElement("canvas").getContext("2d");else return 0;n.font=e.fontOptions+" "+e.fontSize+"px "+e.font;var u=n.measureText(t);if(!u)return 0;var g=u.width;return g}a.__exports.getMaximumHeightOfEncodings=m;a.__exports.getEncodingHeight=f;a.__exports.getBarcodePadding=_;a.__exports.calculateEncodingAttributes=h;a.__exports.getTotalWidthOfEncodings=x;exports.default=a.__exports;