| 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 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 4× 1× 1× 1× 539× 539× 539× 539× 539× 3130× 3130× 3130× 539× 539× 539× 539× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 3130× 3130× 3130× 3130× 3130× 3130× 3130× 3130× 3130× 3130× 1× 539× 1× 1× 1× | /* 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", "./enum", "./pdf-font", "./../../document/pdf-document", "./pdf-standard-font-metrics-factory", "./../../primitives/pdf-dictionary", "./../../input-output/pdf-dictionary-properties", "./../../primitives/pdf-name"], function (require, exports, enum_1, pdf_font_1, pdf_document_1, pdf_standard_font_metrics_factory_1, pdf_dictionary_1, pdf_dictionary_properties_1, pdf_name_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var PdfStandardFont = (function (_super) { __extends(PdfStandardFont, _super); function PdfStandardFont(fontFamilyPrototype, size, style) { var _this = _super.call(this, size, (typeof style === 'undefined') ? ((fontFamilyPrototype instanceof PdfStandardFont) ? fontFamilyPrototype.style : enum_1.PdfFontStyle.Regular) : style) || this; _this.dictionaryProperties = new pdf_dictionary_properties_1.DictionaryProperties(); _this.encodings = ['Unknown', 'StandardEncoding', 'MacRomanEncoding', 'MacExpertEncoding', 'WinAnsiEncoding', 'PDFDocEncoding', 'IdentityH']; Iif (typeof fontFamilyPrototype === 'undefined') { _this.pdfFontFamily = enum_1.PdfFontFamily.Helvetica; } else Iif ((fontFamilyPrototype instanceof PdfStandardFont)) { _this.pdfFontFamily = fontFamilyPrototype.fontFamily; } else { _this.pdfFontFamily = fontFamilyPrototype; } _this.checkStyle(); _this.initializeInternals(); return _this; } Object.defineProperty(PdfStandardFont.prototype, "fontFamily", { get: function () { return this.pdfFontFamily; }, enumerable: true, configurable: true }); PdfStandardFont.prototype.checkStyle = function () { Iif (this.fontFamily === enum_1.PdfFontFamily.Symbol || this.fontFamily === enum_1.PdfFontFamily.ZapfDingbats) { var style = this.style; style &= ~(enum_1.PdfFontStyle.Bold | enum_1.PdfFontStyle.Italic); this.setStyle(style); } }; PdfStandardFont.prototype.getLineWidth = function (line, format) { Iif (line == null) { throw new Error('ArgumentNullException:line'); } var width = 0; var name = this.name; line = PdfStandardFont.convert(line); for (var i = 0, len = line.length; i < len; i++) { var ch = line[i]; var charWidth = this.getCharWidthInternal(ch, format); width += charWidth; } var size = this.metrics.getSize(format); width *= (pdf_font_1.PdfFont.charSizeMultiplier * size); width = this.applyFormatSettings(line, format, width); return width; }; PdfStandardFont.prototype.equalsToFont = function (font) { var equal = false; var stFont = font; if (stFont != null) { var fontFamilyEqual = (this.fontFamily === stFont.fontFamily); var lineReducer = (~(enum_1.PdfFontStyle.Underline | enum_1.PdfFontStyle.Strikeout)); var styleEqual = (this.style & lineReducer) === (stFont.style & lineReducer); equal = (fontFamilyEqual && styleEqual); } return equal; }; PdfStandardFont.prototype.initializeInternals = function () { var equalFont = null; equalFont = pdf_document_1.PdfDocument.cache.search(this); var internals = null; var metrics = pdf_standard_font_metrics_factory_1.PdfStandardFontMetricsFactory.getMetrics(this.pdfFontFamily, this.style, this.size); this.metrics = metrics; internals = this.createInternals(); this.setInternals(internals); }; PdfStandardFont.prototype.createInternals = function () { var dictionary = new pdf_dictionary_1.PdfDictionary(); dictionary.items.setValue(this.dictionaryProperties.type, new pdf_name_1.PdfName(this.dictionaryProperties.font)); dictionary.items.setValue(this.dictionaryProperties.subtype, new pdf_name_1.PdfName(this.dictionaryProperties.type1)); dictionary.items.setValue(this.dictionaryProperties.baseFont, new pdf_name_1.PdfName(this.metrics.postScriptName)); Eif (this.fontFamily !== enum_1.PdfFontFamily.Symbol && this.fontFamily !== enum_1.PdfFontFamily.ZapfDingbats) { var encoding = this.encodings[enum_1.FontEncoding.WinAnsiEncoding]; dictionary.items.setValue(this.dictionaryProperties.encoding, new pdf_name_1.PdfName(encoding)); } return dictionary; }; PdfStandardFont.prototype.getCharWidthInternal = function (charCode, format) { var width = 0; var code = 0; code = charCode.charCodeAt(0); Eif (this.name === '0' || this.name === '1' || this.name === '2' || this.name === '3' || this.name === '4') { code = code - PdfStandardFont.charOffset; } code = (code >= 0 && code !== 128) ? code : 0; var metrics = this.metrics; var widthTable = metrics.widthTable; width = widthTable.items(code); return width; }; PdfStandardFont.convert = function (text) { return text; }; PdfStandardFont.charOffset = 32; return PdfStandardFont; }(pdf_font_1.PdfFont)); exports.PdfStandardFont = PdfStandardFont; }); |