Merge pull request #13955 from Snuffleupagus/issue-13433
Always prefer the post-table for TrueType fonts with (0, x) cmap-tables (issue 13433)
This commit is contained in:
		
						commit
						0a366dda6a
					
				@ -2606,7 +2606,8 @@ class Font {
 | 
			
		||||
      const cmapEncodingId = cmapTable.encodingId;
 | 
			
		||||
      const cmapMappings = cmapTable.mappings;
 | 
			
		||||
      const cmapMappingsLength = cmapMappings.length;
 | 
			
		||||
      let baseEncoding = [];
 | 
			
		||||
      let baseEncoding = [],
 | 
			
		||||
        forcePostTable = false;
 | 
			
		||||
      if (
 | 
			
		||||
        properties.hasEncoding &&
 | 
			
		||||
        (properties.baseEncodingName === "MacRomanEncoding" ||
 | 
			
		||||
@ -2615,9 +2616,8 @@ class Font {
 | 
			
		||||
        baseEncoding = getEncoding(properties.baseEncodingName);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // If the font has an encoding and is not symbolic then follow the
 | 
			
		||||
      // rules in section 9.6.6.4 of the spec on how to map 3,1 and 1,0
 | 
			
		||||
      // cmaps.
 | 
			
		||||
      // If the font has an encoding and is not symbolic then follow the rules
 | 
			
		||||
      // in section 9.6.6.4 of the spec on how to map 3,1 and 1,0 cmaps.
 | 
			
		||||
      if (
 | 
			
		||||
        properties.hasEncoding &&
 | 
			
		||||
        !this.isSymbolicFont &&
 | 
			
		||||
@ -2664,6 +2664,9 @@ class Font {
 | 
			
		||||
        for (let i = 0; i < cmapMappingsLength; ++i) {
 | 
			
		||||
          charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
 | 
			
		||||
        }
 | 
			
		||||
        // Always prefer the BaseEncoding/Differences arrays, when they exist
 | 
			
		||||
        // (fixes issue13433.pdf).
 | 
			
		||||
        forcePostTable = true;
 | 
			
		||||
      } else {
 | 
			
		||||
        // When there is only a (1, 0) cmap table, the char code is a single
 | 
			
		||||
        // byte and it is used directly as the char code.
 | 
			
		||||
@ -2695,7 +2698,7 @@ class Font {
 | 
			
		||||
        (baseEncoding.length || this.differences.length)
 | 
			
		||||
      ) {
 | 
			
		||||
        for (let i = 0; i < 256; ++i) {
 | 
			
		||||
          if (charCodeToGlyphId[i] !== undefined) {
 | 
			
		||||
          if (!forcePostTable && charCodeToGlyphId[i] !== undefined) {
 | 
			
		||||
            continue;
 | 
			
		||||
          }
 | 
			
		||||
          const glyphName = this.differences[i] || baseEncoding[i];
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								test/pdfs/issue13433.pdf.link
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/pdfs/issue13433.pdf.link
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
https://github.com/mozilla/pdf.js/files/6537699/pos36.pdf
 | 
			
		||||
@ -1303,6 +1303,14 @@
 | 
			
		||||
       "enableXfa": true,
 | 
			
		||||
       "type": "eq"
 | 
			
		||||
    },
 | 
			
		||||
    {  "id": "issue13433",
 | 
			
		||||
       "file": "pdfs/issue13433.pdf",
 | 
			
		||||
       "md5": "4038cd87ff48fd54b3c4a36593d2ba03",
 | 
			
		||||
       "link": true,
 | 
			
		||||
       "rounds": 1,
 | 
			
		||||
       "lastPage": 1,
 | 
			
		||||
       "type": "eq"
 | 
			
		||||
    },
 | 
			
		||||
    {  "id": "xfa_issue13668",
 | 
			
		||||
       "file": "pdfs/xfa_issue13668.pdf",
 | 
			
		||||
       "md5": "8a5ed3c8a58b425b1ec53329334a0f5b",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user