/**
 * Text Renderer
 *
 * Handles rendering of text content including:
 * - Text with letter spacing
 * - Text decorations (underline, overline, line-through)
 * - Text shadows
 * - Webkit line clamp
 * - Text overflow ellipsis
 * - Paint order (fill/stroke)
 * - Font styles
 */
import { Context } from '../../core/context';
import { TextContainer } from '../../dom/text-container';
import { CSSParsedDeclaration } from '../../css';
import { Bounds } from '../../css/layout/bounds';
import { TextBounds } from '../../css/layout/text';
import { WRITING_MODE } from '../../css/property-descriptors/writing-mode';
/**
 * Dependencies required for TextRenderer
 */
export interface TextRendererDependencies {
    ctx: CanvasRenderingContext2D;
    context: Context;
    options: {
        scale: number;
    };
}
export declare const hasCJKCharacters: (text: string) => boolean;
/**
 * Text Renderer
 *
 * Specialized renderer for text content.
 * Extracted from CanvasRenderer to improve code organization and maintainability.
 */
export declare class TextRenderer {
    private readonly ctx;
    private readonly options;
    private readonly decorationRenderer;
    /**
     * Per-render glyph width cache. Keyed by glyph + font string,
     * avoids redundant `measureText` calls when letter-spacing is non-zero.
     * Cleared at the start of each renderTextNode call.
     */
    private glyphWidthCache;
    constructor(deps: TextRendererDependencies);
    /**
     * Returns the cached width for a glyph+font pair, measuring via
     * measureText if not yet cached. Only used when letterSpacing !== 0
     * (the `canRenderWholeText` fast path handles the zero-spacing case).
     */
    private cachedMeasureText;
    /**
     * Iterate grapheme clusters one-by-one, applying correct letter-spacing and
     * per-script baseline for each character.
     *
     * Issue #73: When letter-spacing is non-zero, text must be rendered character by
     * character. This helper centralises two fixes applied during that iteration:
     *   1. Add `letterSpacing` to each character's advance width (was previously
     *      omitted, causing characters to render without any spacing).
     *   2. Switch to the ideographic baseline for CJK glyphs so their vertical
     *      position matches how browsers lay them out in the DOM.
     *
     * The `renderFn` callback receives (letter, x, y) and performs the actual draw
     * call (fillText or strokeText), allowing fill and stroke paths to share one
     * implementation.
     */
    private iterateLettersWithLetterSpacing;
    private iterateVerticalGlyphs;
    /**
     * Render text with letter-spacing applied (fill pass).
     * When letterSpacing is 0 the whole string is drawn in one call; otherwise each
     * grapheme is drawn individually so spacing and CJK baseline are applied correctly.
     */
    renderTextWithLetterSpacing(text: TextBounds, letterSpacing: number, baseline: number, writingMode?: WRITING_MODE): void;
    private canRenderWholeText;
    private renderFillText;
    private renderStrokeText;
    private renderTextStrokeWithStyle;
    private renderTextFillWithShadows;
    /**
     * Helper method to render text with paint order support
     * Reduces code duplication in line-clamp and normal rendering
     */
    private renderTextBoundWithPaintOrder;
    private renderTextDecoration;
    private truncateTextWithEllipsis;
    /**
     * Create font style array
     * Public method used by list rendering
     */
    createFontStyle(styles: CSSParsedDeclaration): string[];
    /**
     * Render text with -webkit-line-clamp truncation.
     * Groups text bounds by their Y position into visual lines, then renders
     * only the first N-1 complete lines followed by an ellipsis on the Nth line.
     */
    private renderLineClampedText;
    /**
     * Render single-line text with text-overflow: ellipsis.
     * Returns true if ellipsis was applied (caller should skip normal rendering).
     */
    private renderEllipsisText;
    renderTextNode(text: TextContainer, styles: CSSParsedDeclaration, containerBounds?: Bounds): Promise<void>;
}
