Add a heuristic to scale even single-char text, when the horizontal/vertical scaling differs significantly (issue 11713)
At this point in time, compared to when the "ignore single-char" code was added, we *should* generally be doing a much better job of combining text into as few chunks as possible. However, there's still bad cases where we're not able to combine text as much as one would like, which is why I'm *not* proposing to simply measure/scale all text. Instead this patch will to only measure/scale single-char text in cases where the horizontal/vertical scale is off significantly, since that's were you'd expect bad text-selection behaviour otherwise. Note that most of the movement caused by this patch is with Type3 fonts, which is a somewhat special font type and one where our current text-selection behaviour is probably the least good.
This commit is contained in:
		
							parent
							
								
									70c54ab9d9
								
							
						
					
					
						commit
						91efde5246
					
				@ -113,7 +113,22 @@ var renderTextLayer = (function renderTextLayerClosure() {
 | 
				
			|||||||
    // We don't bother scaling single-char text divs, because it has very
 | 
					    // We don't bother scaling single-char text divs, because it has very
 | 
				
			||||||
    // little effect on text highlighting. This makes scrolling on docs with
 | 
					    // little effect on text highlighting. This makes scrolling on docs with
 | 
				
			||||||
    // lots of such divs a lot faster.
 | 
					    // lots of such divs a lot faster.
 | 
				
			||||||
 | 
					    let shouldScaleText = false;
 | 
				
			||||||
    if (geom.str.length > 1) {
 | 
					    if (geom.str.length > 1) {
 | 
				
			||||||
 | 
					      shouldScaleText = true;
 | 
				
			||||||
 | 
					    } else if (geom.transform[0] !== geom.transform[3]) {
 | 
				
			||||||
 | 
					      const absScaleX = Math.abs(geom.transform[0]),
 | 
				
			||||||
 | 
					        absScaleY = Math.abs(geom.transform[3]);
 | 
				
			||||||
 | 
					      // When the horizontal/vertical scaling differs significantly, also scale
 | 
				
			||||||
 | 
					      // even single-char text to improve highlighting (fixes issue11713.pdf).
 | 
				
			||||||
 | 
					      if (
 | 
				
			||||||
 | 
					        absScaleX !== absScaleY &&
 | 
				
			||||||
 | 
					        Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5
 | 
				
			||||||
 | 
					      ) {
 | 
				
			||||||
 | 
					        shouldScaleText = true;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (shouldScaleText) {
 | 
				
			||||||
      if (style.vertical) {
 | 
					      if (style.vertical) {
 | 
				
			||||||
        textDivProperties.canvasWidth = geom.height * task._viewport.scale;
 | 
					        textDivProperties.canvasWidth = geom.height * task._viewport.scale;
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								test/pdfs/.gitignore
									
									
									
									
										vendored
									
									
								
							@ -143,6 +143,7 @@
 | 
				
			|||||||
!issue6621.pdf
 | 
					!issue6621.pdf
 | 
				
			||||||
!issue6286.pdf
 | 
					!issue6286.pdf
 | 
				
			||||||
!issue1055r.pdf
 | 
					!issue1055r.pdf
 | 
				
			||||||
 | 
					!issue11713.pdf
 | 
				
			||||||
!issue1293r.pdf
 | 
					!issue1293r.pdf
 | 
				
			||||||
!issue1655r.pdf
 | 
					!issue1655r.pdf
 | 
				
			||||||
!issue6541.pdf
 | 
					!issue6541.pdf
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								test/pdfs/issue11713.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								test/pdfs/issue11713.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -1107,6 +1107,12 @@
 | 
				
			|||||||
       "link": false,
 | 
					       "link": false,
 | 
				
			||||||
       "type": "text"
 | 
					       "type": "text"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    {  "id": "issue11713",
 | 
				
			||||||
 | 
					       "file": "pdfs/issue11713.pdf",
 | 
				
			||||||
 | 
					       "md5": "bafe5801234feeb95969da106f2ce6d8",
 | 
				
			||||||
 | 
					       "rounds": 1,
 | 
				
			||||||
 | 
					       "type": "text"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {  "id": "bug1250079",
 | 
					    {  "id": "bug1250079",
 | 
				
			||||||
       "file": "pdfs/bug1250079.pdf",
 | 
					       "file": "pdfs/bug1250079.pdf",
 | 
				
			||||||
       "md5": "a1dd21a70ae7097d96273e85a80b26ef",
 | 
					       "md5": "a1dd21a70ae7097d96273e85a80b26ef",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user