private _renderText()

in client/src/services/image-rendering.ts [165:184]


  private _renderText(context: CanvasRenderingContext2D, text: string, config: ImageRenderingTextConfig,
                      centerX: number, bottomY: number, maxWidth: number): number {
    context.font = config.font;
    let y = bottomY - config.marginBottom;
    const lines = ImageRenderingService._getTextLines(context, text, maxWidth);
    for (let k = lines.length - 1; k >= 0; k--) {
      const line = lines[k];
      const metrics = context.measureText(line);
      const x = centerX - Math.min(metrics.width, maxWidth) * 0.5;
      context.fillStyle = this.config.dropShadowColor;
      context.fillText(line, x + this.config.dropShadowDistance, y + this.config.dropShadowDistance, maxWidth);
      context.fillStyle = this.config.foregroundColor;
      context.fillText(line, x, y, maxWidth);
      y -= config.lineHeight;
      if (k > 0) {
        y -= config.lineSpacing;
      }
    }
    return y;
  }