import type { Fonts } from 'modern-font'; import type { NormalizedFill, NormalizedText, TextContent, Text as TextProperties } from 'modern-idoc'; import type { MeasureResult } from 'modern-text'; import type { RectangleLike } from '../../../core'; import type { CanvasContext, TransformVertex } from '../../main'; import type { Texture2D } from '../../resources'; import type { Element2D } from './Element2D'; import { BoundingBox } from 'modern-path2d'; import { Character, Text } from 'modern-text'; import { CoreObject } from '../../../core'; import { CanvasTexture } from '../../resources'; export type TextDrawMode = 'auto' | 'texture' | 'path'; export declare class Element2DText extends CoreObject implements NormalizedText { protected _parent: Element2D; enabled: NormalizedText['enabled']; content: NormalizedText['content']; style: NormalizedText['style']; effects: NormalizedText['effects']; fill: NormalizedText['fill']; outline: NormalizedText['outline']; deformation: NormalizedText['deformation']; measureDom: HTMLElement; fonts: Fonts; drawMode: TextDrawMode; readonly base: Text; get textContent(): string; set textContent(val: string); protected _textContent: string; protected _autoDrawMode?: TextDrawMode; protected _atlasEligible: boolean; protected _textureStale: boolean; protected _texture: CanvasTexture; protected _tiles: { texture: CanvasTexture; x: number; y: number; w: number; h: number; }[]; protected _textureMap: Map; protected _ownedTextureMap: Map>; protected _textureMapVersion: number; constructor(_parent: Element2D); setProperties(properties?: TextProperties): this; protected _updateProperty(key: string, value: any, oldValue: any): void; load(): Promise; update(): void; /** fragment 颜色的语义色 token(`@token`)→ 当前主题实际色;非 token 原样返回。 */ protected _resolveThemeColor(value: T): T | string; /** * 派生结构上已就地解析过的 token 原值:key = 派生对象,value = { 属性名: '@token' }。 * * 就地写入实际色会丢掉 token 本身,而布局可复用时(内容没变)这些派生对象**不会重建**, * 于是主题切换后再跑本方法只看到实际色、认不出是 token,颜色就永远停在首次解析的那套主题 * (暗色下栅格过的文字,切回亮色仍是白字)。故记下原值,每次栅格都按当前主题重新解析。 */ protected _themeColorOrigins: WeakMap>; protected _resolveBaseThemeColors(): void; protected _rasterTexture(): void; /** 栅格总像素始终不超过预算;普通尺寸仍保持原来的 2 倍超采样。 */ protected _getRasterPixelRatio(width: number, height: number): number; protected _exceedsRasterPixelBudget(width?: number, height?: number): boolean; protected _renderTiles(width: number, height: number, pixelRatio: number, maxTile: number): void; protected _releaseTiles(): void; protected _releaseRasterTextures(): void; protected _releaseTextureMap(): void; protected _updateTextureMap(): void; protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: BoundingBox, version: number): Promise; protected _loadTexture(fill: NormalizedFill, box: any): Promise; setContent(content: TextContent): void; getStringContent(): string; measure(): MeasureResult; isValid(): boolean; protected _createTransformVertex(): TransformVertex | undefined; useTextureDraw(): boolean; protected _pathDraw(ctx: CanvasContext): void; protected _textureDraw(ctx: CanvasContext): void; protected _drawTextureRect(ctx: CanvasContext, texture: Texture2D, rx: number, ry: number, rw: number, rh: number): void; /** * 取得 atlas 能直接绘制的字形颜色。 * * modern-text 的实际填色优先级是 computedFill.color > computedStyle.color。纯色 fill 与 * style.color 一样都能由 glyph atlas 表达,不能仅因为上层配置了 text/paragraph/fragment.fill * 就把整段文字踢回大纹理;否则超长文本会创建数张接近 GPU 上限的 CanvasTexture。 * 渐变、图片、预设以及未来新增的 fill 字段仍保守回退栅格路径,避免丢失视觉语义。 */ protected _getAtlasCharacterColor(character: Character): string | undefined; protected _computeAtlasEligible(): boolean; protected _atlasDraw(ctx: CanvasContext): boolean; draw(): void; process(_delta: number): void; protected _destroy(): void; }