Try to skip mapping of missing glyphs.
This commit is contained in:
		
							parent
							
								
									ccf05c7a41
								
							
						
					
					
						commit
						cb27707277
					
				| @ -2675,17 +2675,12 @@ var Font = (function FontClosure() { | |||||||
|       var fontCharCode = originalCharCode; |       var fontCharCode = originalCharCode; | ||||||
|       // First try to map the value to a unicode position if a non identity map
 |       // First try to map the value to a unicode position if a non identity map
 | ||||||
|       // was created.
 |       // was created.
 | ||||||
|       if (!isIdentityUnicode) { |       // console.log(fontCharCode);
 | ||||||
|         if (toUnicode.get(originalCharCode) !== undefined) { |       if (!isIdentityUnicode && toUnicode.get(originalCharCode) !== undefined) { | ||||||
|           var unicode = toUnicode.get(fontCharCode); |         var unicode = toUnicode.get(fontCharCode); | ||||||
|           // TODO: Try to map ligatures to the correct spot.
 |         // TODO: Try to map ligatures to the correct spot.
 | ||||||
|           if (unicode.length === 1) { |         if (unicode.length === 1) { | ||||||
|             fontCharCode = unicode.charCodeAt(0); |           fontCharCode = unicode.charCodeAt(0); | ||||||
|           } |  | ||||||
|         } else if (isCidFontType2) { |  | ||||||
|           // For CIDFontType2, move characters not present in toUnicode
 |  | ||||||
|           // to the private use area (fixes bug 1028735 and issue 4881).
 |  | ||||||
|           fontCharCode = nextAvailableFontCharCode; |  | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       // Try to move control characters, special characters and already mapped
 |       // Try to move control characters, special characters and already mapped
 | ||||||
| @ -3526,6 +3521,7 @@ var Font = (function FontClosure() { | |||||||
|         var newGlyfData = new Uint8Array(oldGlyfDataLength); |         var newGlyfData = new Uint8Array(oldGlyfDataLength); | ||||||
|         var startOffset = itemDecode(locaData, 0); |         var startOffset = itemDecode(locaData, 0); | ||||||
|         var writeOffset = 0; |         var writeOffset = 0; | ||||||
|  |         var missingGlyphData = {}; | ||||||
|         itemEncode(locaData, 0, writeOffset); |         itemEncode(locaData, 0, writeOffset); | ||||||
|         var i, j; |         var i, j; | ||||||
|         for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { |         for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { | ||||||
| @ -3543,6 +3539,10 @@ var Font = (function FontClosure() { | |||||||
|             continue; |             continue; | ||||||
|           } |           } | ||||||
| 
 | 
 | ||||||
|  |           if (startOffset === endOffset) { | ||||||
|  |             missingGlyphData[i] = true; | ||||||
|  |           } | ||||||
|  | 
 | ||||||
|           var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, |           var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, | ||||||
|                                         newGlyfData, writeOffset, hintsValid); |                                         newGlyfData, writeOffset, hintsValid); | ||||||
|           writeOffset += newLength; |           writeOffset += newLength; | ||||||
| @ -3559,7 +3559,7 @@ var Font = (function FontClosure() { | |||||||
|             itemEncode(locaData, j, simpleGlyph.length); |             itemEncode(locaData, j, simpleGlyph.length); | ||||||
|           } |           } | ||||||
|           glyf.data = simpleGlyph; |           glyf.data = simpleGlyph; | ||||||
|           return; |           return missingGlyphData; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (dupFirstEntry) { |         if (dupFirstEntry) { | ||||||
| @ -3576,6 +3576,7 @@ var Font = (function FontClosure() { | |||||||
|         } else { |         } else { | ||||||
|           glyf.data = newGlyfData.subarray(0, writeOffset); |           glyf.data = newGlyfData.subarray(0, writeOffset); | ||||||
|         } |         } | ||||||
|  |         return missingGlyphData; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       function readPostScriptTable(post, properties, maxpNumGlyphs) { |       function readPostScriptTable(post, properties, maxpNumGlyphs) { | ||||||
| @ -4035,10 +4036,11 @@ var Font = (function FontClosure() { | |||||||
| 
 | 
 | ||||||
|       sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0); |       sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0); | ||||||
| 
 | 
 | ||||||
|  |       var missingGlyphs = {}; | ||||||
|       if (isTrueType) { |       if (isTrueType) { | ||||||
|         var isGlyphLocationsLong = int16(tables.head.data[50], |         var isGlyphLocationsLong = int16(tables.head.data[50], | ||||||
|                                          tables.head.data[51]); |                                          tables.head.data[51]); | ||||||
|         sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, |         missingGlyphs = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, | ||||||
|                                isGlyphLocationsLong, hintsValid, dupFirstEntry); |                                isGlyphLocationsLong, hintsValid, dupFirstEntry); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
| @ -4073,7 +4075,8 @@ var Font = (function FontClosure() { | |||||||
|           } else if (cidToGidMap[cid] !== undefined) { |           } else if (cidToGidMap[cid] !== undefined) { | ||||||
|             glyphId = cidToGidMap[cid]; |             glyphId = cidToGidMap[cid]; | ||||||
|           } |           } | ||||||
|           if (glyphId >= 0 && glyphId < numGlyphs) { | 
 | ||||||
|  |           if (glyphId >= 0 && glyphId < numGlyphs && !missingGlyphs[charCode]) { | ||||||
|             charCodeToGlyphId[charCode] = glyphId; |             charCodeToGlyphId[charCode] = glyphId; | ||||||
|           } |           } | ||||||
|         }); |         }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user