"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseFontSizeStr = parseFontSizeStr;
exports.getFontSize = getFontSize;
exports.parseFontSize = parseFontSize;
function parseFontSizeStr(fontSize) {
    const value = Number.parseFloat(fontSize.substring(0, fontSize.length - 2));
    const unit = fontSize.slice(-2);
    return { value, unit };
}
function getFontSize(element, width, height, parentFontSize) {
    if (element instanceof Text) {
        return;
    }
    const { fontSize } = element.style;
    if (fontSize) {
        return parseFontSize(fontSize, width, height, parentFontSize);
    }
}
function parseFontSize(fontSize, width, height, parentFontSize) {
    const { value, unit } = parseFontSizeStr(fontSize);
    let value_ = value;
    if (unit === 'vw') {
        value_ = (value_ * width) / 100;
    }
    else if (unit === 'vh') {
        value_ = (value_ * height) / 100;
    }
    else if (unit === 'em') {
        return value * parentFontSize;
    }
    return value_;
}
//# sourceMappingURL=getFontSize.js.map