123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __values = (this && this.__values) || function(o) {
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- var __read = (this && this.__read) || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.CommonTextNodeMixin = void 0;
- function CommonTextNodeMixin(Base) {
- return (function (_super) {
- __extends(class_1, _super);
- function class_1() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- class_1.prototype.computeBBox = function (bbox, _recompute) {
- var e_1, _a;
- if (_recompute === void 0) { _recompute = false; }
- var variant = this.parent.variant;
- var text = this.node.getText();
- if (variant === '-explicitFont') {
- var font = this.jax.getFontData(this.parent.styles);
- var _b = this.jax.measureText(text, variant, font), w = _b.w, h = _b.h, d = _b.d;
- bbox.h = h;
- bbox.d = d;
- bbox.w = w;
- }
- else {
- var chars = this.remappedText(text, variant);
- bbox.empty();
- try {
- for (var chars_1 = __values(chars), chars_1_1 = chars_1.next(); !chars_1_1.done; chars_1_1 = chars_1.next()) {
- var char = chars_1_1.value;
- var _c = __read(this.getVariantChar(variant, char), 4), h = _c[0], d = _c[1], w = _c[2], data = _c[3];
- if (data.unknown) {
- var cbox = this.jax.measureText(String.fromCodePoint(char), variant);
- w = cbox.w;
- h = cbox.h;
- d = cbox.d;
- }
- bbox.w += w;
- if (h > bbox.h)
- bbox.h = h;
- if (d > bbox.d)
- bbox.d = d;
- bbox.ic = data.ic || 0;
- bbox.sk = data.sk || 0;
- bbox.dx = data.dx || 0;
- }
- }
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
- finally {
- try {
- if (chars_1_1 && !chars_1_1.done && (_a = chars_1.return)) _a.call(chars_1);
- }
- finally { if (e_1) throw e_1.error; }
- }
- if (chars.length > 1) {
- bbox.sk = 0;
- }
- bbox.clean();
- }
- };
- class_1.prototype.remappedText = function (text, variant) {
- var c = this.parent.stretch.c;
- return (c ? [c] : this.parent.remapChars(this.unicodeChars(text, variant)));
- };
- class_1.prototype.getStyles = function () { };
- class_1.prototype.getVariant = function () { };
- class_1.prototype.getScale = function () { };
- class_1.prototype.getSpace = function () { };
- return class_1;
- }(Base));
- }
- exports.CommonTextNodeMixin = CommonTextNodeMixin;
- //# sourceMappingURL=TextNode.js.map
|