mtext.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.CommonMtextMixin = void 0;
  19. function CommonMtextMixin(Base) {
  20. var _a;
  21. return _a = (function (_super) {
  22. __extends(class_1, _super);
  23. function class_1() {
  24. return _super !== null && _super.apply(this, arguments) || this;
  25. }
  26. class_1.prototype.getVariant = function () {
  27. var options = this.jax.options;
  28. var data = this.jax.math.outputData;
  29. var merror = ((!!data.merrorFamily || !!options.merrorFont) && this.node.Parent.isKind('merror'));
  30. if (!!data.mtextFamily || !!options.mtextFont || merror) {
  31. var variant = this.node.attributes.get('mathvariant');
  32. var font = this.constructor.INHERITFONTS[variant] || this.jax.font.getCssFont(variant);
  33. var family = font[0] || (merror ? data.merrorFamily || options.merrorFont :
  34. data.mtextFamily || options.mtextFont);
  35. this.variant = this.explicitVariant(family, font[2] ? 'bold' : '', font[1] ? 'italic' : '');
  36. return;
  37. }
  38. _super.prototype.getVariant.call(this);
  39. };
  40. return class_1;
  41. }(Base)),
  42. _a.INHERITFONTS = {
  43. normal: ['', false, false],
  44. bold: ['', false, true],
  45. italic: ['', true, false],
  46. 'bold-italic': ['', true, true]
  47. },
  48. _a;
  49. }
  50. exports.CommonMtextMixin = CommonMtextMixin;
  51. //# sourceMappingURL=mtext.js.map