Cache the fallback font dictionary on the PartialEvaluator (PR 11218 follow-up)
				
					
				
			This way we'll benefit from the existing font caching, and can thus avoid re-creating a fallback font over and over again during parsing. (Thece changes necessitated the previous patch, since otherwise breakage could occur e.g. with fake workers.)
This commit is contained in:
		
							parent
							
								
									090ff116d4
								
							
						
					
					
						commit
						9ab7c280aa
					
				| @ -935,11 +935,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { | |||||||
| 
 | 
 | ||||||
|         // Falling back to a default font to avoid completely broken rendering,
 |         // Falling back to a default font to avoid completely broken rendering,
 | ||||||
|         // but note that there're no guarantees that things will look "correct".
 |         // but note that there're no guarantees that things will look "correct".
 | ||||||
|         fontRef = new Dict(); |         fontRef = PartialEvaluator.getFallbackFontDict(); | ||||||
|         fontRef.set("BaseFont", Name.get("PDFJS-FallbackFont")); |  | ||||||
|         fontRef.set("Type", Name.get("FallbackType")); |  | ||||||
|         fontRef.set("Subtype", Name.get("FallbackType")); |  | ||||||
|         fontRef.set("Encoding", Name.get("WinAnsiEncoding")); |  | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (this.fontCache.has(fontRef)) { |       if (this.fontCache.has(fontRef)) { | ||||||
| @ -3134,6 +3130,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { | |||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  |   // TODO: Change this to a `static` getter, using shadowing, once
 | ||||||
|  |   //       `PartialEvaluator` is converted to a proper class.
 | ||||||
|  |   PartialEvaluator.getFallbackFontDict = function() { | ||||||
|  |     if (this._fallbackFontDict) { | ||||||
|  |       return this._fallbackFontDict; | ||||||
|  |     } | ||||||
|  |     const dict = new Dict(); | ||||||
|  |     dict.set("BaseFont", Name.get("PDFJS-FallbackFont")); | ||||||
|  |     dict.set("Type", Name.get("FallbackType")); | ||||||
|  |     dict.set("Subtype", Name.get("FallbackType")); | ||||||
|  |     dict.set("Encoding", Name.get("WinAnsiEncoding")); | ||||||
|  | 
 | ||||||
|  |     return (this._fallbackFontDict = dict); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|   return PartialEvaluator; |   return PartialEvaluator; | ||||||
| })(); | })(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user