@mlightcad/data-model
Version:
The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.
112 lines • 4.43 kB
JavaScript
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.");
};
import { AcDbSymbolTable } from './AcDbSymbolTable';
/**
* Symbol table for text style table records.
*
* This class manages text style table records which represent text styles
* within a drawing database. Text styles define the appearance and properties
* of text entities, including font, size, and other formatting options.
*
* @example
* ```typescript
* const textStyleTable = new AcDbTextStyleTable(database);
* const fonts = textStyleTable.fonts;
* console.log('Available fonts:', fonts);
* ```
*/
var AcDbTextStyleTable = /** @class */ (function (_super) {
__extends(AcDbTextStyleTable, _super);
/**
* Creates a new AcDbTextStyleTable instance.
*
* @param db - The database this text style table belongs to
*
* @example
* ```typescript
* const textStyleTable = new AcDbTextStyleTable(database);
* ```
*/
function AcDbTextStyleTable(db) {
return _super.call(this, db) || this;
}
Object.defineProperty(AcDbTextStyleTable.prototype, "fonts", {
/**
* Gets all fonts used in text styles.
*
* This method iterates through all text style table records and extracts
* the font names from both the primary font file and big font file.
* Font names are normalized by removing file extensions and converting to lowercase.
*
* @returns Array of unique font names used in text styles
*
* @example
* ```typescript
* const fonts = textStyleTable.fonts;
* console.log('Available fonts:', fonts);
* // Output: ['arial', 'times', 'calibri', ...]
* ```
*/
get: function () {
var e_1, _a;
var fonts = new Set();
var setFontName = function (fontFileName) {
if (fontFileName) {
var lastDotIndex = fontFileName.lastIndexOf('.');
if (lastDotIndex >= 0) {
var fontName = fontFileName.substring(0, lastDotIndex).toLowerCase();
fonts.add(fontName);
}
else {
fonts.add(fontFileName.toLowerCase());
}
}
};
var iterator = this.newIterator();
try {
for (var iterator_1 = __values(iterator), iterator_1_1 = iterator_1.next(); !iterator_1_1.done; iterator_1_1 = iterator_1.next()) {
var item = iterator_1_1.value;
setFontName(item.fileName);
setFontName(item.bigFontFileName);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (iterator_1_1 && !iterator_1_1.done && (_a = iterator_1.return)) _a.call(iterator_1);
}
finally { if (e_1) throw e_1.error; }
}
return Array.from(fonts);
},
enumerable: false,
configurable: true
});
return AcDbTextStyleTable;
}(AcDbSymbolTable));
export { AcDbTextStyleTable };
//# sourceMappingURL=AcDbTextStyleTable.js.map