FontCache.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.FontCache = void 0;
  4. var FontCache = (function () {
  5. function FontCache(jax) {
  6. this.cache = new Map();
  7. this.defs = null;
  8. this.localID = '';
  9. this.nextID = 0;
  10. this.jax = jax;
  11. }
  12. FontCache.prototype.cachePath = function (variant, C, path) {
  13. var id = 'MJX-' + this.localID + (this.jax.font.getVariant(variant).cacheID || '') + '-' + C;
  14. if (!this.cache.has(id)) {
  15. this.cache.set(id, path);
  16. this.jax.adaptor.append(this.defs, this.jax.svg('path', { id: id, d: path }));
  17. }
  18. return id;
  19. };
  20. FontCache.prototype.clearLocalID = function () {
  21. this.localID = '';
  22. };
  23. FontCache.prototype.useLocalID = function (id) {
  24. if (id === void 0) { id = null; }
  25. this.localID = (id == null ? ++this.nextID : id) + (id === '' ? '' : '-');
  26. };
  27. FontCache.prototype.clearCache = function () {
  28. this.cache = new Map();
  29. this.defs = this.jax.svg('defs');
  30. };
  31. FontCache.prototype.getCache = function () {
  32. return this.defs;
  33. };
  34. return FontCache;
  35. }());
  36. exports.FontCache = FontCache;
  37. //# sourceMappingURL=FontCache.js.map