Fix handling of multiply-encoded glyphs.
This commit is contained in:
		
							parent
							
								
									79c57dc04e
								
							
						
					
					
						commit
						db591769a4
					
				@ -4128,7 +4128,7 @@ var Font = (function FontClosure() {
 | 
				
			|||||||
        properties.seacMap = seacMap;
 | 
					        properties.seacMap = seacMap;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!properties.hasEncoding && (properties.subtype == 'Type1C' ||
 | 
					      if (properties.overridableEncoding && (properties.subtype == 'Type1C' ||
 | 
				
			||||||
          properties.subtype == 'CIDFontType0C')) {
 | 
					          properties.subtype == 'CIDFontType0C')) {
 | 
				
			||||||
        var encoding = [];
 | 
					        var encoding = [];
 | 
				
			||||||
        for (var i = 0; i < charstrings.length; ++i) {
 | 
					        for (var i = 0; i < charstrings.length; ++i) {
 | 
				
			||||||
@ -5534,8 +5534,20 @@ var CFFFont = (function CFFFontClosure() {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        for (var charcode in encoding)
 | 
					        for (var charcode in encoding) {
 | 
				
			||||||
          inverseEncoding[encoding[charcode]] = charcode | 0;
 | 
					          var gid = encoding[charcode];
 | 
				
			||||||
 | 
					          if (gid in inverseEncoding) {
 | 
				
			||||||
 | 
					            // Glyphs can be multiply-encoded if there was an encoding
 | 
				
			||||||
 | 
					            // supplement. Convert to an array and append the charcode.
 | 
				
			||||||
 | 
					            var previousCharcode = inverseEncoding[gid];
 | 
				
			||||||
 | 
					            if (!isArray(previousCharcode)) {
 | 
				
			||||||
 | 
					              inverseEncoding[gid] = [previousCharcode];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            inverseEncoding[gid].push(charcode | 0);
 | 
				
			||||||
 | 
					          } else {
 | 
				
			||||||
 | 
					            inverseEncoding[gid] = charcode | 0;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (charsets[0] === '.notdef') {
 | 
					        if (charsets[0] === '.notdef') {
 | 
				
			||||||
          gidStart = 1;
 | 
					          gidStart = 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -5544,9 +5556,16 @@ var CFFFont = (function CFFFontClosure() {
 | 
				
			|||||||
      for (var i = gidStart, ii = charsets.length; i < ii; i++) {
 | 
					      for (var i = gidStart, ii = charsets.length; i < ii; i++) {
 | 
				
			||||||
        var glyph = charsets[i];
 | 
					        var glyph = charsets[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var code = inverseEncoding[i];
 | 
					        var codes = inverseEncoding[i];
 | 
				
			||||||
 | 
					        if (!isArray(codes)) {
 | 
				
			||||||
 | 
					          codes = [codes];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (var j = 0; j < codes.length; j++) {
 | 
				
			||||||
 | 
					          var code = codes[j];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (!code || isSpecialUnicode(code)) {
 | 
					          if (!code || isSpecialUnicode(code)) {
 | 
				
			||||||
          unassignedUnicodeItems.push(i);
 | 
					            unassignedUnicodeItems.push(i, code);
 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          charstrings.push({
 | 
					          charstrings.push({
 | 
				
			||||||
@ -5557,9 +5576,10 @@ var CFFFont = (function CFFFontClosure() {
 | 
				
			|||||||
          });
 | 
					          });
 | 
				
			||||||
          unicodeUsed[code] = true;
 | 
					          unicodeUsed[code] = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var nextUnusedUnicode = CMAP_GLYPH_OFFSET;
 | 
					      var nextUnusedUnicode = CMAP_GLYPH_OFFSET;
 | 
				
			||||||
      for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; ++j) {
 | 
					      for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; j += 2) {
 | 
				
			||||||
        var i = unassignedUnicodeItems[j];
 | 
					        var i = unassignedUnicodeItems[j];
 | 
				
			||||||
        // giving unicode value anyway
 | 
					        // giving unicode value anyway
 | 
				
			||||||
        while (nextUnusedUnicode in unicodeUsed)
 | 
					        while (nextUnusedUnicode in unicodeUsed)
 | 
				
			||||||
@ -5567,7 +5587,7 @@ var CFFFont = (function CFFFontClosure() {
 | 
				
			|||||||
        var unicode = nextUnusedUnicode++;
 | 
					        var unicode = nextUnusedUnicode++;
 | 
				
			||||||
        charstrings.push({
 | 
					        charstrings.push({
 | 
				
			||||||
          unicode: unicode,
 | 
					          unicode: unicode,
 | 
				
			||||||
          code: inverseEncoding[i] || 0,
 | 
					          code: unassignedUnicodeItems[j + 1] || 0,
 | 
				
			||||||
          gid: i,
 | 
					          gid: i,
 | 
				
			||||||
          glyph: charsets[i]
 | 
					          glyph: charsets[i]
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -6136,7 +6156,7 @@ var CFFParser = (function CFFParserClosure() {
 | 
				
			|||||||
        for (var i = 0; i < supplementsCount; i++) {
 | 
					        for (var i = 0; i < supplementsCount; i++) {
 | 
				
			||||||
          var code = bytes[pos++];
 | 
					          var code = bytes[pos++];
 | 
				
			||||||
          var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
 | 
					          var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
 | 
				
			||||||
          encoding[code] = properties.differences.indexOf(strings.get(sid));
 | 
					          encoding[code] = charset.indexOf(strings.get(sid));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								test/pdfs/issue3566.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test/pdfs/issue3566.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -990,6 +990,14 @@
 | 
				
			|||||||
      "type": "eq",
 | 
					      "type": "eq",
 | 
				
			||||||
      "about": "CFF CID font with font matrices in main top dict and sub top dict."
 | 
					      "about": "CFF CID font with font matrices in main top dict and sub top dict."
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    {  "id": "issue3566",
 | 
				
			||||||
 | 
					      "file": "pdfs/issue3566.pdf",
 | 
				
			||||||
 | 
					      "md5": "e9ab02aa769f4c040a6fa52f00d6e3f0",
 | 
				
			||||||
 | 
					      "rounds": 1,
 | 
				
			||||||
 | 
					      "type": "eq",
 | 
				
			||||||
 | 
					      "lastPage": 1,
 | 
				
			||||||
 | 
					      "about": "CFF font with multiply-encoded glyph and no pdf encoding dict."
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {  "id": "issue1878",
 | 
					    {  "id": "issue1878",
 | 
				
			||||||
      "file": "pdfs/issue1878.pdf",
 | 
					      "file": "pdfs/issue1878.pdf",
 | 
				
			||||||
      "md5": "b4fb0ce7c19368e7104dce3d0d34bcb3",
 | 
					      "md5": "b4fb0ce7c19368e7104dce3d0d34bcb3",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user