all files / graphics/fonts/ pdf-font-metrics.js

80.23% Statements 69/86
80% Branches 20/25
80.77% Functions 21/26
79.52% Lines 66/83
11 statements, 6 functions, 9 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128            2388× 2388×   4312× 4312×   2156× 2156×   2156× 2156× 2156× 2156× 10780× 10780×   2156× 2156×         2156×   9429× 9429× 765×                 9429×             3130×                             3130×     3130× 3130×                                  
/* istanbul ignore next */ 
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "./pdf-font", "./enum", "./../../primitives/pdf-array"], function (require, exports, pdf_font_1, enum_1, pdf_array_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfFontMetrics = (function () {
        function PdfFontMetrics() {
            this.lineGap = 0;
        }
        PdfFontMetrics.prototype.getAscent = function (format) {
            var returnValue = this.ascent * pdf_font_1.PdfFont.charSizeMultiplier * this.getSize(format);
            return returnValue;
        };
        PdfFontMetrics.prototype.getDescent = function (format) {
            var returnValue = this.descent * pdf_font_1.PdfFont.charSizeMultiplier * this.getSize(format);
            return returnValue;
        };
        PdfFontMetrics.prototype.getLineGap = function (format) {
            var returnValue = this.lineGap * pdf_font_1.PdfFont.charSizeMultiplier * this.getSize(format);
            return returnValue;
        };
        PdfFontMetrics.prototype.getHeight = function (format) {
            var height;
            var clearTypeFonts = ['cambria', 'candara', 'constantia', 'corbel', 'cariadings'];
            var clearTypeFontCollection = [];
            for (var index = 0; index < clearTypeFonts.length; index++) {
                var font = clearTypeFonts[index];
                clearTypeFontCollection.push(font);
            }
            Eif (this.getDescent(format) < 0) {
                height = (this.getAscent(format) - this.getDescent(format) + this.getLineGap(format));
            }
            else {
                height = (this.getAscent(format) + this.getDescent(format) + this.getLineGap(format));
            }
            return height;
        };
        PdfFontMetrics.prototype.getSize = function (format) {
            var size = this.size;
            if (format != null) {
                switch (format.subSuperScript) {
                    case enum_1.PdfSubSuperScript.SubScript:
                        size /= this.subScriptSizeFactor;
                        break;
                    case enum_1.PdfSubSuperScript.SuperScript:
                        size /= this.superscriptSizeFactor;
                        break;
                }
            }
            return size;
        };
        PdfFontMetrics.prototype.clone = function () {
            var metrics = this;
            metrics.widthTable = WidthTable.clone();
            return metrics;
        };
        Object.defineProperty(PdfFontMetrics.prototype, "widthTable", {
            get: function () {
                return this.internalWidthTable;
            },
            set: function (value) {
                this.internalWidthTable = value;
            },
            enumerable: true,
            configurable: true
        });
        return PdfFontMetrics;
    }());
    exports.PdfFontMetrics = PdfFontMetrics;
    var WidthTable = (function () {
        function WidthTable() {
        }
        WidthTable.clone = function () {
            return null;
        };
        return WidthTable;
    }());
    exports.WidthTable = WidthTable;
    var StandardWidthTable = (function (_super) {
        __extends(StandardWidthTable, _super);
        function StandardWidthTable(widths) {
            var _this = _super.call(this) || this;
            Iif (widths == null) {
                throw new Error('ArgumentNullException:widths');
            }
            _this.widths = widths;
            return _this;
        }
        StandardWidthTable.prototype.items = function (index) {
            Iif (index < 0 || index >= this.widths.length) {
                throw new Error('ArgumentOutOfRangeException:index, The character is not supported by the font.');
            }
            var result = this.widths[index];
            return result;
        };
        Object.defineProperty(StandardWidthTable.prototype, "length", {
            get: function () {
                return this.widths.length;
            },
            enumerable: true,
            configurable: true
        });
        StandardWidthTable.prototype.clone = function () {
            var swt = this;
            swt.widths = this.widths;
            return swt;
        };
        StandardWidthTable.prototype.toArray = function () {
            var arr = new pdf_array_1.PdfArray(this.widths);
            return arr;
        };
        return StandardWidthTable;
    }(WidthTable));
    exports.StandardWidthTable = StandardWidthTable;
});