Fixes font debugger; text builder api refactoring
This commit is contained in:
		
							parent
							
								
									399463a450
								
							
						
					
					
						commit
						b5f952a63a
					
				@ -646,7 +646,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
      ctx.transform.apply(ctx, fontMatrix);
 | 
			
		||||
      ctx.scale(textHScale, 1);
 | 
			
		||||
    },
 | 
			
		||||
    getTextGeometry: function CanvasGraphics_getTextGeometry() {
 | 
			
		||||
    createTextGeometry: function CanvasGraphics_createTextGeometry() {
 | 
			
		||||
      var geometry = {};
 | 
			
		||||
      var ctx = this.ctx;
 | 
			
		||||
      var font = this.current.font;
 | 
			
		||||
@ -660,6 +660,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
        geometry.vScale = tr[1] - bl[1];
 | 
			
		||||
      }
 | 
			
		||||
      geometry.spaceWidth = font.spaceWidth;
 | 
			
		||||
      geometry.fontName = font.loadedName;
 | 
			
		||||
      geometry.fontFamily = font.fallbackName;
 | 
			
		||||
      geometry.fontSize = this.current.fontSize;
 | 
			
		||||
      return geometry;
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
@ -693,7 +696,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
        if (textSelection) {
 | 
			
		||||
          this.save();
 | 
			
		||||
          ctx.scale(1, -1);
 | 
			
		||||
          geom = this.getTextGeometry();
 | 
			
		||||
          geom = this.createTextGeometry();
 | 
			
		||||
          this.restore();
 | 
			
		||||
        }
 | 
			
		||||
        for (var i = 0; i < glyphsLength; ++i) {
 | 
			
		||||
@ -734,7 +737,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
          lineWidth /= scale;
 | 
			
		||||
 | 
			
		||||
        if (textSelection)
 | 
			
		||||
          geom = this.getTextGeometry();
 | 
			
		||||
          geom = this.createTextGeometry();
 | 
			
		||||
 | 
			
		||||
        if (fontSizeScale != 1.0) {
 | 
			
		||||
          ctx.scale(fontSizeScale, fontSizeScale);
 | 
			
		||||
@ -792,7 +795,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
 | 
			
		||||
      if (textSelection) {
 | 
			
		||||
        geom.canvasWidth = canvasWidth;
 | 
			
		||||
        this.textLayer.appendText(font.fallbackName, fontSize, geom);
 | 
			
		||||
        this.textLayer.appendText(geom);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return canvasWidth;
 | 
			
		||||
@ -821,7 +824,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
          ctx.scale(textHScale, 1);
 | 
			
		||||
        } else
 | 
			
		||||
          this.applyTextTransforms();
 | 
			
		||||
        geom = this.getTextGeometry();
 | 
			
		||||
        geom = this.createTextGeometry();
 | 
			
		||||
        ctx.restore();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -845,7 +848,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 | 
			
		||||
 | 
			
		||||
      if (textSelection) {
 | 
			
		||||
        geom.canvasWidth = canvasWidth;
 | 
			
		||||
        this.textLayer.appendText(font.fallbackName, fontSize, geom);
 | 
			
		||||
        this.textLayer.appendText(geom);
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    nextLineShowText: function CanvasGraphics_nextLineShowText(text) {
 | 
			
		||||
 | 
			
		||||
@ -168,11 +168,10 @@ SimpleTextLayerBuilder.prototype = {
 | 
			
		||||
  endLayout: function SimpleTextLayerBuilder_EndLayout() {
 | 
			
		||||
    this.ctx.restore();
 | 
			
		||||
  },
 | 
			
		||||
  appendText: function SimpleTextLayerBuilder_AppendText(fontName, fontSize,
 | 
			
		||||
                                                          geom) {
 | 
			
		||||
  appendText: function SimpleTextLayerBuilder_AppendText(geom) {
 | 
			
		||||
    var ctx = this.ctx, viewport = this.viewport;
 | 
			
		||||
    // vScale and hScale already contain the scaling to pixel units
 | 
			
		||||
    var fontHeight = fontSize * geom.vScale;
 | 
			
		||||
    var fontHeight = geom.fontSize * geom.vScale;
 | 
			
		||||
    ctx.beginPath();
 | 
			
		||||
    ctx.strokeStyle = 'red';
 | 
			
		||||
    ctx.fillStyle = 'yellow';
 | 
			
		||||
@ -182,7 +181,7 @@ SimpleTextLayerBuilder.prototype = {
 | 
			
		||||
    ctx.fill();
 | 
			
		||||
 | 
			
		||||
    var textContent = this.textContent.bidiTexts[this.textCounter].str;
 | 
			
		||||
    ctx.font = fontHeight + 'px ' + fontName;
 | 
			
		||||
    ctx.font = fontHeight + 'px ' + geom.fontFamily;
 | 
			
		||||
    ctx.fillStyle = 'black';
 | 
			
		||||
    ctx.fillText(textContent, geom.x, geom.y);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2303,17 +2303,16 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  this.appendText = function textLayerBuilderAppendText(fontName, fontSize,
 | 
			
		||||
                                                        geom) {
 | 
			
		||||
  this.appendText = function textLayerBuilderAppendText(geom) {
 | 
			
		||||
    var textDiv = document.createElement('div');
 | 
			
		||||
 | 
			
		||||
    // vScale and hScale already contain the scaling to pixel units
 | 
			
		||||
    var fontHeight = fontSize * geom.vScale;
 | 
			
		||||
    var fontHeight = geom.fontSize * geom.vScale;
 | 
			
		||||
    textDiv.dataset.canvasWidth = geom.canvasWidth * geom.hScale;
 | 
			
		||||
    textDiv.dataset.fontName = fontName;
 | 
			
		||||
    textDiv.dataset.fontName = geom.fontName;
 | 
			
		||||
 | 
			
		||||
    textDiv.style.fontSize = fontHeight + 'px';
 | 
			
		||||
    textDiv.style.fontFamily = fontName;
 | 
			
		||||
    textDiv.style.fontFamily = geom.fontFamily;
 | 
			
		||||
    textDiv.style.left = geom.x + 'px';
 | 
			
		||||
    textDiv.style.top = (geom.y - fontHeight) + 'px';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user