@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.
@@ -990,6 +990,11 @@ class DictionaryProperties {
990
990
  * @private
991
991
  */
992
992
  this.cIDToGIDMap = 'CIDToGIDMap';
993
+ /**
994
+ * Specifies the value of 'cIDFontType0C'.
995
+ * @private
996
+ */
997
+ this.cIDFontType0C = 'CIDFontType0C';
993
998
  /**
994
999
  * Specifies the value of 'identity'.
995
1000
  * @private
@@ -1010,6 +1015,11 @@ class DictionaryProperties {
1010
1015
  * @private
1011
1016
  */
1012
1017
  this.cIDSystemInfo = 'CIDSystemInfo';
1018
+ /**
1019
+ * Specifies the value of 'CIDFontType0'.
1020
+ * @private
1021
+ */
1022
+ this.cIDFontType0 = 'CIDFontType0';
1013
1023
  /**
1014
1024
  * Specifies the value of 'fontName'.
1015
1025
  * @private
@@ -1070,6 +1080,11 @@ class DictionaryProperties {
1070
1080
  * @private
1071
1081
  */
1072
1082
  this.fontFile2 = 'FontFile2';
1083
+ /**
1084
+ * Specifies the value of 'fontFile3'.
1085
+ * @private
1086
+ */
1087
+ this.fontFile3 = 'FontFile3';
1073
1088
  /**
1074
1089
  * Specifies the value of 'maxWidth'.
1075
1090
  * @private
@@ -10836,6 +10851,7 @@ class TtfReader {
10836
10851
  this.missedGlyphs = 0;
10837
10852
  this.tableNames = ['cvt ', 'fpgm', 'glyf', 'head', 'hhea', 'hmtx', 'loca', 'maxp', 'prep'];
10838
10853
  this.entrySelectors = [0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4];
10854
+ this._isOpenTypeFont = false;
10839
10855
  this.fontData = fontData;
10840
10856
  this.initialize();
10841
10857
  }
@@ -10955,6 +10971,9 @@ class TtfReader {
10955
10971
  this.offset = this.readInt32(this.offset);
10956
10972
  version = this.readInt32(this.offset);
10957
10973
  }
10974
+ if (version === 0x4f54544f) {
10975
+ this._isOpenTypeFont = true;
10976
+ }
10958
10977
  return version;
10959
10978
  }
10960
10979
  readNameTable() {
@@ -11373,7 +11392,7 @@ class TtfReader {
11373
11392
  // NOTE: Strange!
11374
11393
  this.metrics.stemV = 80;
11375
11394
  this.metrics.widthTable = this.updateWidth();
11376
- this.metrics.contains = this.tableDirectory.containsKey('CFF');
11395
+ this.metrics.contains = this.tableDirectory.containsKey('CFF ');
11377
11396
  this.metrics.subScriptSizeFactor = headTable.unitsPerEm / os2Table.ySubscriptYSize;
11378
11397
  this.metrics.superscriptSizeFactor = headTable.unitsPerEm / os2Table.ySuperscriptYSize;
11379
11398
  }
@@ -11892,6 +11911,15 @@ class TtfReader {
11892
11911
  let fontProgram = this.getFontProgram(newLocaUpdated, newGlyphTable, glyphTableSize, newLocaSize);
11893
11912
  return fontProgram;
11894
11913
  }
11914
+ _readCompactFontFormatTable() {
11915
+ const tableInfo = this.getTable('CFF ');
11916
+ const length = tableInfo.length;
11917
+ const offset = tableInfo.offset;
11918
+ const cffData = new Array(length);
11919
+ this.setOffset(offset);
11920
+ const result = this.read(cffData, 0, length);
11921
+ return result.buffer;
11922
+ }
11895
11923
  /**
11896
11924
  * Reconverts string to be in proper format saved into PDF file.
11897
11925
  */
@@ -12366,7 +12394,12 @@ class UnicodeTrueTypeFont {
12366
12394
  this.descendantFont.isResource = true;
12367
12395
  this.descendantFont.descendantFontBeginSave = new SaveDescendantFontEventHandler(this);
12368
12396
  this.descendantFont.items.setValue(this.dictionaryProperties.type, new PdfName(this.dictionaryProperties.font));
12369
- this.descendantFont.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType2));
12397
+ if (this.ttfReader && this.ttfReader._isOpenTypeFont) {
12398
+ this.descendantFont.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType0));
12399
+ }
12400
+ else {
12401
+ this.descendantFont.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType2));
12402
+ }
12370
12403
  this.descendantFont.items.setValue(this.dictionaryProperties.baseFont, new PdfName(this.subsetName));
12371
12404
  this.descendantFont.items.setValue(this.dictionaryProperties.cIDToGIDMap, new PdfName(this.dictionaryProperties.identity));
12372
12405
  this.descendantFont.items.setValue(this.dictionaryProperties.dw, new PdfNumber(1000));
@@ -12395,7 +12428,13 @@ class UnicodeTrueTypeFont {
12395
12428
  descriptor.items.setValue(this.dictionaryProperties.descent, new PdfNumber(metrics.winDescent));
12396
12429
  descriptor.items.setValue(this.dictionaryProperties.leading, new PdfNumber(metrics.leading));
12397
12430
  descriptor.items.setValue(this.dictionaryProperties.avgWidth, new PdfNumber(metrics.widthTable[32]));
12398
- descriptor.items.setValue(this.dictionaryProperties.fontFile2, new PdfReferenceHolder(this.fontProgram));
12431
+ if (this.ttfReader.metrics.contains) {
12432
+ descriptor.items.setValue(this.dictionaryProperties.fontFile3, new PdfReferenceHolder(this.fontProgram));
12433
+ this.fontProgram.items.setValue(this.dictionaryProperties.subtype, new PdfName(this.dictionaryProperties.cIDFontType0C));
12434
+ }
12435
+ else {
12436
+ descriptor.items.setValue(this.dictionaryProperties.fontFile2, new PdfReferenceHolder(this.fontProgram));
12437
+ }
12399
12438
  descriptor.items.setValue(this.dictionaryProperties.maxWidth, new PdfNumber(metrics.widthTable[32]));
12400
12439
  descriptor.items.setValue(this.dictionaryProperties.xHeight, new PdfNumber(0));
12401
12440
  descriptor.items.setValue(this.dictionaryProperties.stemH, new PdfNumber(0));
@@ -12591,13 +12630,20 @@ class UnicodeTrueTypeFont {
12591
12630
  * Generates font program.
12592
12631
  */
12593
12632
  generateFontProgram() {
12594
- let fontProgram = null;
12595
12633
  this.usedChars = (this.usedChars === null || this.usedChars === undefined) ? new Dictionary() : this.usedChars;
12596
12634
  this.ttfReader.setOffset(0);
12597
- fontProgram = this.ttfReader.readFontProgram(this.usedChars);
12598
- this.fontProgram.clearStream();
12599
- this.fontProgram.isResource = true;
12600
- this.fontProgram.writeBytes(fontProgram);
12635
+ if (this.ttfReader.metrics.contains && this.ttfReader._isOpenTypeFont) {
12636
+ const cffData = this.ttfReader._readCompactFontFormatTable();
12637
+ this.fontProgram.clearStream();
12638
+ this.fontProgram.isResource = true;
12639
+ this.fontProgram.writeBytes(cffData);
12640
+ }
12641
+ else {
12642
+ const fontProgram = this.ttfReader.readFontProgram(this.usedChars);
12643
+ this.fontProgram.clearStream();
12644
+ this.fontProgram.isResource = true;
12645
+ this.fontProgram.writeBytes(fontProgram);
12646
+ }
12601
12647
  }
12602
12648
  /**
12603
12649
  * Calculates flags for the font descriptor.