@syncfusion/ej2-pdf-export 29.2.4 → 30.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1017,6 +1017,11 @@ var DictionaryProperties = /** @__PURE__ @class */ (function () {
1017
1017
  * @private
1018
1018
  */
1019
1019
  this.cIDToGIDMap = 'CIDToGIDMap';
1020
+ /**
1021
+ * Specifies the value of 'cIDFontType0C'.
1022
+ * @private
1023
+ */
1024
+ this.cIDFontType0C = 'CIDFontType0C';
1020
1025
  /**
1021
1026
  * Specifies the value of 'identity'.
1022
1027
  * @private
@@ -1037,6 +1042,11 @@ var DictionaryProperties = /** @__PURE__ @class */ (function () {
1037
1042
  * @private
1038
1043
  */
1039
1044
  this.cIDSystemInfo = 'CIDSystemInfo';
1045
+ /**
1046
+ * Specifies the value of 'CIDFontType0'.
1047
+ * @private
1048
+ */
1049
+ this.cIDFontType0 = 'CIDFontType0';
1040
1050
  /**
1041
1051
  * Specifies the value of 'fontName'.
1042
1052
  * @private
@@ -1097,6 +1107,11 @@ var DictionaryProperties = /** @__PURE__ @class */ (function () {
1097
1107
  * @private
1098
1108
  */
1099
1109
  this.fontFile2 = 'FontFile2';
1110
+ /**
1111
+ * Specifies the value of 'fontFile3'.
1112
+ * @private
1113
+ */
1114
+ this.fontFile3 = 'FontFile3';
1100
1115
  /**
1101
1116
  * Specifies the value of 'maxWidth'.
1102
1117
  * @private
@@ -11913,6 +11928,7 @@ var TtfReader = /** @__PURE__ @class */ (function () {
11913
11928
  this.missedGlyphs = 0;
11914
11929
  this.tableNames = ['cvt ', 'fpgm', 'glyf', 'head', 'hhea', 'hmtx', 'loca', 'maxp', 'prep'];
11915
11930
  this.entrySelectors = [0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4];
11931
+ this._isOpenTypeFont = false;
11916
11932
  this.fontData = fontData;
11917
11933
  this.initialize();
11918
11934
  }
@@ -12048,6 +12064,9 @@ var TtfReader = /** @__PURE__ @class */ (function () {
12048
12064
  this.offset = this.readInt32(this.offset);
12049
12065
  version = this.readInt32(this.offset);
12050
12066
  }
12067
+ if (version === 0x4f54544f) {
12068
+ this._isOpenTypeFont = true;
12069
+ }
12051
12070
  return version;
12052
12071
  };
12053
12072
  TtfReader.prototype.readNameTable = function () {
@@ -12466,7 +12485,7 @@ var TtfReader = /** @__PURE__ @class */ (function () {
12466
12485
  // NOTE: Strange!
12467
12486
  this.metrics.stemV = 80;
12468
12487
  this.metrics.widthTable = this.updateWidth();
12469
- this.metrics.contains = this.tableDirectory.containsKey('CFF');
12488
+ this.metrics.contains = this.tableDirectory.containsKey('CFF ');
12470
12489
  this.metrics.subScriptSizeFactor = headTable.unitsPerEm / os2Table.ySubscriptYSize;
12471
12490
  this.metrics.superscriptSizeFactor = headTable.unitsPerEm / os2Table.ySuperscriptYSize;
12472
12491
  };
@@ -12985,6 +13004,15 @@ var TtfReader = /** @__PURE__ @class */ (function () {
12985
13004
  var fontProgram = this.getFontProgram(newLocaUpdated, newGlyphTable, glyphTableSize, newLocaSize);
12986
13005
  return fontProgram;
12987
13006
  };
13007
+ TtfReader.prototype._readCompactFontFormatTable = function () {
13008
+ var tableInfo = this.getTable('CFF ');
13009
+ var length = tableInfo.length;
13010
+ var offset = tableInfo.offset;
13011
+ var cffData = new Array(length);
13012
+ this.setOffset(offset);
13013
+ var result = this.read(cffData, 0, length);
13014
+ return result.buffer;
13015
+ };
12988
13016
  /**
12989
13017
  * Reconverts string to be in proper format saved into PDF file.
12990
13018
  */
@@ -13488,7 +13516,12 @@ var UnicodeTrueTypeFont = /** @__PURE__ @class */ (function () {
13488
13516
  this.descendantFont.isResource = true;
13489
13517
  this.descendantFont.descendantFontBeginSave = new SaveDescendantFontEventHandler(this);
13490
13518
  this.descendantFont.items.setValue(this.dictionaryProperties.type, new PdfName(this.dictionaryProperties.font));
13491
- this.descendantFont.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType2));
13519
+ if (this.ttfReader && this.ttfReader._isOpenTypeFont) {
13520
+ this.descendantFont.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType0));
13521
+ }
13522
+ else {
13523
+ this.descendantFont.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType2));
13524
+ }
13492
13525
  this.descendantFont.items.setValue(this.dictionaryProperties.baseFont, new PdfName(this.subsetName));
13493
13526
  this.descendantFont.items.setValue(this.dictionaryProperties.cIDToGIDMap, new PdfName(this.dictionaryProperties.identity));
13494
13527
  this.descendantFont.items.setValue(this.dictionaryProperties.dw, new PdfNumber(1000));
@@ -13517,7 +13550,13 @@ var UnicodeTrueTypeFont = /** @__PURE__ @class */ (function () {
13517
13550
  descriptor.items.setValue(this.dictionaryProperties.descent, new PdfNumber(metrics.winDescent));
13518
13551
  descriptor.items.setValue(this.dictionaryProperties.leading, new PdfNumber(metrics.leading));
13519
13552
  descriptor.items.setValue(this.dictionaryProperties.avgWidth, new PdfNumber(metrics.widthTable[32]));
13520
- descriptor.items.setValue(this.dictionaryProperties.fontFile2, new PdfReferenceHolder(this.fontProgram));
13553
+ if (this.ttfReader.metrics.contains) {
13554
+ descriptor.items.setValue(this.dictionaryProperties.fontFile3, new PdfReferenceHolder(this.fontProgram));
13555
+ this.fontProgram.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType0C));
13556
+ }
13557
+ else {
13558
+ descriptor.items.setValue(this.dictionaryProperties.fontFile2, new PdfReferenceHolder(this.fontProgram));
13559
+ }
13521
13560
  descriptor.items.setValue(this.dictionaryProperties.maxWidth, new PdfNumber(metrics.widthTable[32]));
13522
13561
  descriptor.items.setValue(this.dictionaryProperties.xHeight, new PdfNumber(0));
13523
13562
  descriptor.items.setValue(this.dictionaryProperties.stemH, new PdfNumber(0));
@@ -13713,13 +13752,20 @@ var UnicodeTrueTypeFont = /** @__PURE__ @class */ (function () {
13713
13752
  * Generates font program.
13714
13753
  */
13715
13754
  UnicodeTrueTypeFont.prototype.generateFontProgram = function () {
13716
- var fontProgram = null;
13717
13755
  this.usedChars = (this.usedChars === null || this.usedChars === undefined) ? new Dictionary() : this.usedChars;
13718
13756
  this.ttfReader.setOffset(0);
13719
- fontProgram = this.ttfReader.readFontProgram(this.usedChars);
13720
- this.fontProgram.clearStream();
13721
- this.fontProgram.isResource = true;
13722
- this.fontProgram.writeBytes(fontProgram);
13757
+ if (this.ttfReader.metrics.contains && this.ttfReader._isOpenTypeFont) {
13758
+ var cffData = this.ttfReader._readCompactFontFormatTable();
13759
+ this.fontProgram.clearStream();
13760
+ this.fontProgram.isResource = true;
13761
+ this.fontProgram.writeBytes(cffData);
13762
+ }
13763
+ else {
13764
+ var fontProgram = this.ttfReader.readFontProgram(this.usedChars);
13765
+ this.fontProgram.clearStream();
13766
+ this.fontProgram.isResource = true;
13767
+ this.fontProgram.writeBytes(fontProgram);
13768
+ }
13723
13769
  };
13724
13770
  /**
13725
13771
  * Calculates flags for the font descriptor.