Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(ui): TextInput gains a renderMode selector (Auto / Bitmap / SDF)

yhh6d6c4e06461b
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index ac056b715..2467e5271 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -6183,6 +6183,7 @@ password: boolean
placeholder: string
placeholderColor: Color
readOnly: boolean
+renderMode: TextRenderMode
value: string
```
@@ -6213,6 +6214,7 @@ password: boolean | undefined
placeholder: string | undefined
placeholderColor: Color | undefined
readOnly: boolean | undefined
+renderMode: TextRenderMode | undefined
tabIndex: number | undefined
value: string | undefined
world: World
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 6ec8038ec..0f20fb361 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -6178,6 +6178,7 @@ password: boolean
placeholder: string
placeholderColor: Color
readOnly: boolean
+renderMode: TextRenderMode
value: string
```
@@ -6208,6 +6209,7 @@ password: boolean | undefined
placeholder: string | undefined
placeholderColor: Color | undefined
readOnly: boolean | undefined
+renderMode: TextRenderMode | undefined
tabIndex: number | undefined
value: string | undefined
world: World
diff --git a/sdk/src/ui/text/text-input-plugin.ts b/sdk/src/ui/text/text-input-plugin.ts
index 307da09d9..40377080e 100644
--- a/sdk/src/ui/text/text-input-plugin.ts
+++ b/sdk/src/ui/text/text-input-plugin.ts
@@ -334,6 +334,7 @@ export class TextInputPlugin implements Plugin {
text: {
content: '', fontFamily: ti.fontFamily, fontSize: ti.fontSize,
align: TextAlign.Left, verticalAlign: TextVerticalAlign.Middle, wordWrap: ti.multiline,
+ renderMode: ti.renderMode,
},
});
const caret = spawnUIEntity({
@@ -351,12 +352,13 @@ export class TextInputPlugin implements Plugin {
const show = displayString(ti);
const col = ti.value.length === 0 ? ti.placeholderColor : ti.color;
if (t.content !== show || t.fontFamily !== ti.fontFamily || t.fontSize !== ti.fontSize
- || t.wordWrap !== ti.multiline
+ || t.wordWrap !== ti.multiline || t.renderMode !== ti.renderMode
|| t.color.r !== col.r || t.color.g !== col.g || t.color.b !== col.b || t.color.a !== col.a) {
t.content = show;
t.fontFamily = ti.fontFamily;
t.fontSize = ti.fontSize;
t.wordWrap = ti.multiline;
+ t.renderMode = ti.renderMode;
t.color = { ...col };
world.insert(textEntity, Text, t);
}
diff --git a/sdk/src/ui/text/text-input.ts b/sdk/src/ui/text/text-input.ts
index 94f244025..e537afbae 100644
--- a/sdk/src/ui/text/text-input.ts
+++ b/sdk/src/ui/text/text-input.ts
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
-import { defineComponent } from '../../component';
+import { defineComponent, enumOptions } from '../../component';
import type { Color } from '../../types';
+import { TextRenderMode } from '../core/text';
export interface TextInputData {
value: string;
@@ -19,6 +20,9 @@ export interface TextInputData {
focused: boolean;
cursorPos: number;
dirty: boolean;
+ /** Glyph pipeline for the field text — mirrors Text.renderMode, propagated to
+ * the child Text the input plugin renders through (Auto / Bitmap / Sdf). */
+ renderMode: TextRenderMode;
}
export const TextInput = defineComponent<TextInputData>('TextInput', {
@@ -37,4 +41,12 @@ export const TextInput = defineComponent<TextInputData>('TextInput', {
focused: false,
cursorPos: 0,
dirty: true,
+ renderMode: TextRenderMode.Auto,
+}, {
+ fields: {
+ renderMode: {
+ enum: enumOptions(TextRenderMode),
+ tooltip: 'Glyph pipeline for the field text — Auto (hinted bitmap when unscaled, SDF once scaled), always Bitmap, or always SDF.',
+ },
+ },
});
diff --git a/sdk/src/ui/widgets/prefabs/TextInput.esprefab b/sdk/src/ui/widgets/prefabs/TextInput.esprefab
index 5bdbc5f80..2752bf2cd 100644
--- a/sdk/src/ui/widgets/prefabs/TextInput.esprefab
+++ b/sdk/src/ui/widgets/prefabs/TextInput.esprefab
@@ -163,7 +163,8 @@
"readOnly": false,
"focused": false,
"cursorPos": 0,
- "dirty": true
+ "dirty": true,
+ "renderMode": 0
}
},
{
diff --git a/sdk/src/ui/widgets/prefabs/generated.ts b/sdk/src/ui/widgets/prefabs/generated.ts
index fba4c8753..5e3055868 100644
--- a/sdk/src/ui/widgets/prefabs/generated.ts
+++ b/sdk/src/ui/widgets/prefabs/generated.ts
@@ -1853,7 +1853,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {
"readOnly": false,
"focused": false,
"cursorPos": 0,
- "dirty": true
+ "dirty": true,
+ "renderMode": 0
}
},
{
diff --git a/sdk/src/ui/widgets/text-input.ts b/sdk/src/ui/widgets/text-input.ts
index afa375514..90f339fcc 100644
--- a/sdk/src/ui/widgets/text-input.ts
+++ b/sdk/src/ui/widgets/text-input.ts
@@ -6,6 +6,7 @@ import type { World } from '../../world';
import { px } from '../core/dimension';
import { type UIEventQueue } from '../core/events';
import { TextInput, type TextInputData } from '../text/text-input';
+import { TextRenderMode } from '../core/text';
import { spawnUIEntity, type UINodeInit } from '../core/compose';
import { makeWidgetInteractable } from '../input/interactable';
@@ -31,6 +32,8 @@ export interface TextInputOptions {
readOnly?: boolean;
/** Inner horizontal padding in px. Default 6. */
padding?: number;
+ /** Glyph pipeline for the field text. Default Auto (bitmap unscaled, SDF scaled). */
+ renderMode?: TextRenderMode;
/** Text / background / placeholder color overrides (theme roles otherwise). */
color?: Color;
@@ -86,6 +89,7 @@ export function createTextInput(opts: TextInputOptions): TextInputHandle {
focused: false,
cursorPos: (opts.value ?? '').length,
dirty: true,
+ renderMode: opts.renderMode ?? TextRenderMode.Auto,
});
markThemed(world, entity, {
input: {