Use post table when Encoding has only Differences
Fixes #13107 In the issue, some TrueType glyph names have the format `uniXXXX`. Font's `Encoding` dictionary has the entry `Differences` but no `BaseEncoding`. `uniXXXX` names are converted to glyph indices using font's `post` table but currently that is done only when `BaseEncoding` exists. We must enable the conversion also when only `Differences` exists.
This commit is contained in:
		
							parent
							
								
									84d7cccb1d
								
							
						
					
					
						commit
						0117ee5071
					
				@ -2901,10 +2901,18 @@ var Font = (function FontClosure() {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Last, try to map any missing charcodes using the post table.
 | 
			
		||||
        if (properties.glyphNames && baseEncoding.length) {
 | 
			
		||||
        if (
 | 
			
		||||
          properties.glyphNames &&
 | 
			
		||||
          (baseEncoding.length || this.differences.length)
 | 
			
		||||
        ) {
 | 
			
		||||
          for (let i = 0; i < 256; ++i) {
 | 
			
		||||
            if (charCodeToGlyphId[i] === undefined && baseEncoding[i]) {
 | 
			
		||||
              glyphName = baseEncoding[i];
 | 
			
		||||
            if (charCodeToGlyphId[i] !== undefined) {
 | 
			
		||||
              continue;
 | 
			
		||||
            }
 | 
			
		||||
            glyphName = this.differences[i] || baseEncoding[i];
 | 
			
		||||
            if (!glyphName) {
 | 
			
		||||
              continue;
 | 
			
		||||
            }
 | 
			
		||||
            const glyphId = properties.glyphNames.indexOf(glyphName);
 | 
			
		||||
            if (glyphId > 0 && hasGlyph(glyphId)) {
 | 
			
		||||
              charCodeToGlyphId[i] = glyphId;
 | 
			
		||||
@ -2912,7 +2920,6 @@ var Font = (function FontClosure() {
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (charCodeToGlyphId.length === 0) {
 | 
			
		||||
        // defines at least one glyph
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							@ -158,6 +158,7 @@
 | 
			
		||||
!issue6019.pdf
 | 
			
		||||
!issue6621.pdf
 | 
			
		||||
!issue6286.pdf
 | 
			
		||||
!issue13107_reduced.pdf
 | 
			
		||||
!issue1055r.pdf
 | 
			
		||||
!issue11713.pdf
 | 
			
		||||
!issue1293r.pdf
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								test/pdfs/issue13107_reduced.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test/pdfs/issue13107_reduced.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -595,6 +595,12 @@
 | 
			
		||||
       "link": false,
 | 
			
		||||
       "type": "eq"
 | 
			
		||||
    },
 | 
			
		||||
    {  "id": "issue13107",
 | 
			
		||||
      "file": "pdfs/issue13107_reduced.pdf",
 | 
			
		||||
      "md5": "13c8d12223dec2752d3c90d250db32b7",
 | 
			
		||||
      "rounds": 1,
 | 
			
		||||
      "type": "eq"
 | 
			
		||||
    },
 | 
			
		||||
    {  "id": "bug1186827",
 | 
			
		||||
       "file": "pdfs/bug1186827.pdf",
 | 
			
		||||
       "md5": "6c5526ae1a9d66cb517153001afc196e",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user