* draw a text at the specified coord * @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
(renderer)
| 438 | * @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance |
| 439 | */ |
| 440 | draw(renderer) { |
| 441 | // re-render the canvas texture when dirty (e.g. visibleCharacters changed) |
| 442 | if (this.isDirty) { |
| 443 | this.canvasTexture.invalidate(renderer); |
| 444 | this.canvasTexture.clear(); |
| 445 | this._drawFont( |
| 446 | this.canvasTexture.context, |
| 447 | this._text, |
| 448 | this.pos.x - this.metrics.x, |
| 449 | this.pos.y - this.metrics.y, |
| 450 | ); |
| 451 | } |
| 452 | |
| 453 | // adjust x,y position based on the bounding box |
| 454 | let x = this.metrics.x; |
| 455 | let y = this.metrics.y; |
| 456 | |
| 457 | // clamp to pixel grid if required |
| 458 | if (renderer.settings.subPixel === false) { |
| 459 | x = ~~x; |
| 460 | y = ~~y; |
| 461 | } |
| 462 | |
| 463 | // draw the text |
| 464 | renderer.drawImage(this.canvasTexture.canvas, x, y); |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * @ignore |
nothing calls this directly
no test coverage detected