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

72.5% Statements 58/80
61.36% Branches 27/44
76.19% Functions 16/21
72.5% Lines 58/80
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159             3669×                     2156×           465×                                         232×           232×           9762×               28×         10×     10×           10×       10×           10×     10× 10× 10× 10× 10× 10× 10×                       559× 559× 531×     531×           559×        
define(["require", "exports", "./enum", "./../../drawing/pdf-drawing", "./pdf-string-format", "./string-layouter", "./string-tokenizer"], function (require, exports, enum_1, pdf_drawing_1, pdf_string_format_1, string_layouter_1, string_tokenizer_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfFont = (function () {
        function PdfFont(size, style) {
            this.fontStyle = enum_1.PdfFontStyle.Regular;
            if (typeof size === 'number' && typeof style === 'undefined') {
                this.fontSize = size;
            }
            else {
                this.fontSize = size;
                this.setStyle(style);
            }
        }
        Object.defineProperty(PdfFont.prototype, "name", {
            get: function () {
                return this.metrics.name;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "size", {
            get: function () {
                return this.fontSize;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "height", {
            get: function () {
                return this.metrics.getHeight(null);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "style", {
            get: function () {
                return this.fontStyle;
            },
            set: function (value) {
                this.fontStyle = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "bold", {
            get: function () {
                return ((this.style & enum_1.PdfFontStyle.Bold) > 0);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "italic", {
            get: function () {
                return ((this.style & enum_1.PdfFontStyle.Italic) > 0);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "strikeout", {
            get: function () {
                return ((this.style & enum_1.PdfFontStyle.Strikeout) > 0);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "underline", {
            get: function () {
                return ((this.style & enum_1.PdfFontStyle.Underline) > 0);
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "metrics", {
            get: function () {
                return this.fontMetrics;
            },
            set: function (value) {
                this.fontMetrics = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfFont.prototype, "element", {
            get: function () {
                return this.pdfFontInternals;
            },
            enumerable: true,
            configurable: true
        });
        PdfFont.prototype.measureString = function (text, arg2, arg3, arg4, arg5) {
            Iif (typeof text === 'string' && typeof arg2 === 'undefined') {
                return this.measureString(text, null);
            }
            else Iif (typeof text === 'string' && (arg2 instanceof pdf_string_format_1.PdfStringFormat || arg2 == null) && typeof arg3 === 'undefined' && typeof arg4 === 'undefined') {
                var temparg2 = arg2;
                var charactersFitted = 0;
                var linesFilled = 0;
                return this.measureString(text, temparg2, charactersFitted, linesFilled);
            }
            else Iif (typeof text === 'string' && (arg2 instanceof pdf_string_format_1.PdfStringFormat || arg2 == null) && typeof arg3 === 'number' && typeof arg4 === 'number') {
                var temparg2 = arg2;
                return this.measureString(text, 0, temparg2, arg3, arg4);
            }
            else Iif (typeof text === 'string' && typeof arg2 === 'number' && (arg3 instanceof pdf_string_format_1.PdfStringFormat || arg3 == null) && typeof arg4 === 'number' && typeof arg5 === 'number') {
                var layoutArea = new pdf_drawing_1.SizeF(arg2, 0);
                var temparg3 = arg3;
                return this.measureString(text, layoutArea, temparg3, arg4, arg5);
            }
            else {
                Iif (text == null) {
                    throw Error("ArgumentNullException(\"text\")");
                }
                var temparg2 = arg2;
                var temparg3 = arg3;
                var layouter = new string_layouter_1.PdfStringLayouter();
                var result = layouter.layout(text, this, temparg3, temparg2, false, new pdf_drawing_1.SizeF(0, 0));
                arg4 = text.length;
                arg5 = (result.empty) ? 0 : result.lines.length;
                return result.actualSize;
            }
        };
        PdfFont.prototype.equalsTo = function (obj) {
            var result = this.equalsToFont(obj);
            return result;
        };
        PdfFont.prototype.getInternals = function () {
            return this.pdfFontInternals;
        };
        PdfFont.prototype.setInternals = function (internals) {
            Iif (internals == null) {
                throw new Error('ArgumentNullException:internals');
            }
            this.pdfFontInternals = internals;
        };
        PdfFont.prototype.setStyle = function (style) {
            this.fontStyle = style;
        };
        PdfFont.prototype.applyFormatSettings = function (line, format, width) {
            var realWidth = width;
            if (format != null && width > 0) {
                Iif (format.characterSpacing !== 0) {
                    realWidth += (line.length - 1) * format.characterSpacing;
                }
                Iif (format.wordSpacing !== 0) {
                    var symbols = string_tokenizer_1.StringTokenizer.spaces;
                    var whitespacesCount = string_tokenizer_1.StringTokenizer.getCharsCount(line, symbols);
                    realWidth += whitespacesCount * format.wordSpacing;
                }
            }
            return realWidth;
        };
        PdfFont.charSizeMultiplier = 0.001;
        PdfFont.syncObject = new Object();
        return PdfFont;
    }());
    exports.PdfFont = PdfFont;
});