Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(canvas): redesign the text tool properties pane

Josh Corbett4e7123cd749a
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index a051df0849..dd10333d01 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -1907,6 +1907,7 @@
},
"rows": {
"color": "Color",
+ "fill": "Fill",
"kind": "Kind",
"width": "Width",
"angle": "Angle",
@@ -1915,7 +1916,7 @@
"family": "Family",
"size": "Size",
"weight": "Weight",
- "lineHeight": "Leading",
+ "lineHeight": "Line height",
"align": "Align",
"aspect": "Aspect",
"shape": "Shape",
@@ -2856,7 +2857,6 @@
"textColor": "Text color",
"textEdit": "Edit text",
"textFont": "Font",
- "textFontAxes": "Axes",
"textFontBuiltinGroup": "Built-in",
"textFontCustomGroup": "Custom",
"textFontDefaultPreset": "Default",
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.browser.test.tsx
index df6446da8f..cc0c6a81c5 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.browser.test.tsx
@@ -10,7 +10,7 @@ import { act } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { I18nextProvider, initReactI18next } from 'react-i18next';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { page } from 'vitest/browser';
+import { page, userEvent } from 'vitest/browser';
const mocks = vi.hoisted(() => {
const font: FontRecord = {
@@ -18,6 +18,7 @@ const mocks = vi.hoisted(() => {
{ default: 400, hidden: false, label: 'Weight', maximum: 900, minimum: 100, tag: 'wght' },
{ default: 0, hidden: false, label: 'Italic', maximum: 1, minimum: 0, tag: 'ital' },
{ default: 100, hidden: true, label: 'Width', maximum: 125, minimum: 75, tag: 'wdth' },
+ { default: 0, hidden: false, label: 'Flat', maximum: 0, minimum: 0, tag: 'FLAT' },
],
byteSize: 1024,
contentHash: 'a'.repeat(64),
@@ -86,7 +87,6 @@ await i18n.use(initReactI18next).init({
en: {
translation: {
'widgets.canvas.toolOptions.textFont': 'Font',
- 'widgets.canvas.toolOptions.textFontAxes': 'Axes',
'widgets.canvas.toolOptions.textFontCustomGroup': 'Custom fonts',
'widgets.canvas.toolOptions.textFontDefaultPreset': 'Default',
'widgets.canvas.toolOptions.textFontHideAdvancedAxes': 'Hide hidden axes',
@@ -185,10 +185,13 @@ describe('custom font controls', () => {
);
});
- await expect.element(page.getByRole('combobox', { name: 'Style' })).toBeDisabled();
- await expect.element(page.getByRole('combobox', { name: 'Weight' })).toBeDisabled();
await expect.element(page.getByRole('slider', { name: 'Weight (wght)' })).toBeVisible();
- await expect.element(page.getByText('Width (wdth)')).not.toBeInTheDocument();
+ // The face's own axes own style and weight: no second control for either.
+ expect(page.getByRole('combobox', { name: 'Style' }).query()).toBeNull();
+ expect(page.getByRole('combobox', { name: 'Weight' }).query()).toBeNull();
+ expect(page.getByRole('slider', { name: 'Width (wdth)' }).query()).toBeNull();
+ // A degenerate axis has nothing to edit and never appears.
+ expect(page.getByRole('slider', { name: 'Flat (FLAT)' }).query()).toBeNull();
await expect.element(page.getByRole('button', { name: 'Show hidden axes' })).toBeVisible();
await act(() => page.getByRole('button', { name: 'Show hidden axes' }).click());
@@ -196,6 +199,37 @@ describe('custom font controls', () => {
await expect.element(page.getByRole('combobox', { name: 'Preset' })).toBeVisible();
});
+ it('keeps a hidden weight axis editable instead of leaving weight with no control', async () => {
+ const hiddenWeight: FontRecord = {
+ ...mocks.font,
+ axes: mocks.font.axes.map((axis) => (axis.tag === 'wght' ? { ...axis, hidden: true } : axis)),
+ };
+ mocks.fontsInfiniteQueryOptions.mockReset().mockImplementation(() => ({
+ getNextPageParam: () => undefined,
+ initialPageParam: 0,
+ queryFn: () => Promise.resolve({ items: [hiddenWeight], limit: 100, offset: 0, total: 1 }),
+ queryKey: ['font-catalog-test', 'hidden-weight'],
+ }));
+ container = document.createElement('div');
+ document.body.appendChild(container);
+ root = createRoot(container);
+ const FontGroup = textForm.groups[0]!.body;
+ await act(() => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <I18nextProvider i18n={i18n}>
+ <QueryClientProvider client={queryClient}>
+ <FontGroup engine={engine} isSurfaceInteractionLocked={false} />
+ </QueryClientProvider>
+ </I18nextProvider>
+ </ChakraProvider>
+ );
+ });
+ await expect.element(page.getByRole('slider', { name: 'Weight (wght)' })).toBeVisible();
+ expect(page.getByRole('combobox', { name: 'Weight' }).query()).toBeNull();
+ expect(page.getByRole('slider', { name: 'Width (wdth)' }).query()).toBeNull();
+ });
+
it('reveals catalog fonts beyond the first page with an explicit load-more action', async () => {
const secondPageFont: FontRecord = {
...mocks.font,
@@ -344,8 +378,10 @@ describe('custom font controls', () => {
await act(() => page.getByRole('combobox', { name: 'Font' }).click());
await expect.element(page.getByRole('option', { name: 'Variable Sans Regular', exact: true })).toBeVisible();
+ await act(() => userEvent.keyboard('{Escape}'));
await act(() => page.getByRole('button', { name: 'Retry' }).click());
+ await act(() => page.getByRole('combobox', { name: 'Font' }).click());
await expect.element(page.getByRole('option', { name: 'Second Page Sans Retry', exact: true })).toBeVisible();
});
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx
index 1e73f63e54..f853a8a678 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx
@@ -1,12 +1,15 @@
import type { SelectValueChangeDetails } from '@chakra-ui/react';
-import type { CanvasLayerSourceContract, CanvasTextFontRef, TextToolOptions } from '@workbench/canvas-engine/api';
-import type { ToolFormProps } from '@workbench/widgets/canvas/tool-presentation/toolFormContracts';
+import type { CanvasTextFontRef, TextToolOptions } from '@workbench/canvas-engine/api';
+import type { TextSource } from '@workbench/widgets/canvas/textFontStyle';
+import type { ToolFormProps, ToolPreviewProps } from '@workbench/widgets/canvas/tool-presentation/toolFormContracts';
+import type { CSSProperties, KeyboardEvent } from 'react';
-import { Box, createListCollection, HStack, Spinner, Text } from '@chakra-ui/react';
+import { Box, createListCollection, HStack, Spinner, Stack, Text } from '@chakra-ui/react';
import { fontsInfiniteQueryOptions, type FontAxis, type FontRecord } from '@features/fonts';
import { Button, IconButton, ToggleIconButton } from '@platform/ui/Button';
import { ColorPicker } from '@platform/ui/ColorPicker';
import { Select } from '@platform/ui/Select';
+import { Tooltip } from '@platform/ui/Tooltip';
import { useInfiniteQuery } from '@tanstack/react-query';
import {
MAX_TEXT_FONT_SIZE,
@@ -17,6 +20,12 @@ import {
} from '@workbench/canvas-engine/api';
import { useActiveColorCommands, useActiveColorPair } from '@workbench/widgets/canvas/color-system/useActiveColors';
import { useTextEditSession, useTextOptions } from '@workbench/widgets/canvas/engineStoreHooks';
+import {
+ TextFontReadiness,
+ textFontKey,
+ textFontVariationSettings,
+ useResolvedTextFontFamily,
+} from '@workbench/widgets/canvas/textFontStyle';
import {
FormNumberField,
FormSlider,
@@ -31,7 +40,6 @@ import { AlignCenterIcon, AlignLeftIcon, AlignRightIcon, RotateCcwIcon, SlidersH
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-type TextSource = Extract<CanvasLayerSourceContract, { type: 'text' }>;
type TextAlign = TextToolOptions['align'];
interface SelectedText {
@@ -59,6 +67,34 @@ const ALIGN_VALUES: readonly TextAlign[] = ['left', 'center', 'right'];
const EMPTY_FONT_VARIATIONS: Readonly<Record<string, number>> = {};
const EMPTY_FONT_RECORDS: readonly FontRecord[] = [];
+/** The slider covers the sizes text is actually set at; the field still reaches the document limits. */
+const SIZE_SLIDER_MIN_PX = 4;
+const SIZE_SLIDER_MAX_PX = 600;
+const SIZE_SLIDER_POSITIONS = 1000;
+const SIZE_LOG_RANGE = Math.log(SIZE_SLIDER_MAX_PX / SIZE_SLIDER_MIN_PX);
+const SPECIMEN_MAX_CHARS = 40;
+const SPECIMEN_FALLBACK = 'Aa';
+/** The canvas surround's checker, so any text color reads the way it does over a transparent document. */
+const SPECIMEN_CHECKER =
+ 'conic-gradient({colors.bg.subtle} 25%, transparent 0 50%, {colors.bg.subtle} 0 75%, transparent 0)';
+
+const clampTextSize = (value: number): number =>
+ Math.min(MAX_TEXT_FONT_SIZE, Math.max(MIN_TEXT_FONT_SIZE, Math.round(value)));
+
+export const textSizeToSliderPosition = (size: number): number => {
+ const clamped = Math.min(SIZE_SLIDER_MAX_PX, Math.max(SIZE_SLIDER_MIN_PX, size));
+ return (Math.log(clamped / SIZE_SLIDER_MIN_PX) / SIZE_LOG_RANGE) * SIZE_SLIDER_POSITIONS;
+};
+
+export const sliderPositionToTextSize = (position: number): number => {
+ const clamped = Math.min(SIZE_SLIDER_POSITIONS, Math.max(0, position));
+ return clampTextSize(SIZE_SLIDER_MIN_PX * Math.exp((clamped / SIZE_SLIDER_POSITIONS) * SIZE_LOG_RANGE));
+};
+
+/** Whole pixels below 100, tens above: a log track's own step is sub-pixel at small sizes. */
+export const textSizeKeyboardStep = (size: number, direction: -1 | 1): number =>
+ size < 100 || (direction < 0 && size === 100) ? 1 : 10;
+
type FontChoiceGroup = 'builtin' | 'custom';
interface FontChoice {
@@ -121,6 +157,13 @@ const fontVariationCoordinates = (
font.axes.map((axis) => [axis.tag, clampFontAxisValue(coordinates[axis.tag] ?? axis.default, axis)])
);
+/** Axes with a range to edit; a degenerate axis owns nothing. */
+const usableAxes = (font: FontRecord | undefined): readonly FontAxis[] =>
+ font?.axes.filter((axis) => axis.maximum > axis.minimum) ?? [];
+
+/** An axis that replaces the plain Style or Weight select stays visible even when the font flags it hidden. */
+const OWNING_AXIS_TAGS = new Set(['ital', 'slnt', 'wght']);
+
const axisStep = (axis: FontAxis): number => {
const span = axis.maximum - axis.minimum;
if (span <= 2) {
@@ -132,6 +175,16 @@ const axisStep = (axis: FontAxis): number => {
return 1;
};
+/** The first line of the text being styled, or a neutral specimen when there is none yet. */
+export const textSpecimen = (content: string | null): string => {
+ const line =
+ content
+ ?.split('\n')
+ .find((candidate) => candidate.trim().length > 0)
+ ?.trim() ?? '';
+ return line.length > 0 ? line.slice(0, SPECIMEN_MAX_CHARS) : SPECIMEN_FALLBACK;
+};
+
const AlignButton = ({
active,
onSelect,
@@ -145,15 +198,17 @@ const AlignButton = ({
const Icon = ALIGN_ICONS[value];
const onClick = useCallback(() => onSelect(value), [onSelect, value]);
return (
- <IconButton
- aria-label={t(ALIGN_LABEL_KEYS[value])}
- aria-pressed={active}
- size="xs"
- variant={active ? 'solid' : 'ghost'}
- onClick={onClick}
- >
- <Icon />
- </IconButton>
+ <Tooltip content={t(ALIGN_LABEL_KEYS[value])}>
+ <IconButton
+ aria-label={t(ALIGN_LABEL_KEYS[value])}
+ aria-pressed={active}
+ size="xs"
+ variant={active ? 'solid' : 'ghost'}
+ onClick={onClick}
+ >
+ <Icon />
+ </IconButton>
+ </Tooltip>
);
};
@@ -194,6 +249,7 @@ const useTextEditor = (engine: ToolFormProps['engine']) => {
: (options.fontVariations ?? EMPTY_FONT_VARIATIONS);
const lineHeight = styleSource?.lineHeight ?? options.lineHeight;
const color = styleSource?.color ?? pair.foreground;
+ const content = styleSource?.content ?? null;
const active = useMemo(
() => ({ align, color, fontFamily, fontRef, fontSize, fontStyle, fontVariations, fontWeight, lineHeight }),
[align, color, fontFamily, fontRef, fontSize, fontStyle, fontVariations, fontWeight, lineHeight]
@@ -258,7 +314,39 @@ const useTextEditor = (engine: ToolFormProps['engine']) => {
return getDocumentLayer(project.canvas.document, session.layerId)?.name ?? null;
});
const targetName = session ? (sessionLayerName ?? t('widgets.properties.target.newText')) : (selected?.name ?? null);
- return { active, applyEdit, targetName };
+ return { active, applyEdit, content, targetName };
+};
+
+/**
+ * A live specimen of the active face — family, style, weight, axes and color —
+ * with the target chip: the one place the form shows what its values add up to.
+ */
+export const TextPreview = ({ engine }: ToolPreviewProps) => {
+ const { active, content, targetName } = useTextEditor(engine);
+ // The instanced face the canvas rasterizes with; the engine keeps the
+ // session's, the document's and the defaults' faces active, so the load is shared.
+ const face = useMemo((): TextSource => ({ ...active, content: '', type: 'text' }), [active]);
+ const fontFamily = useResolvedTextFontFamily(engine.fonts, face);
+ const style = useMemo(
+ (): CSSProperties => ({
+ color: active.color,
+ fontFamily,
+ fontStyle: active.fontStyle,
+ fontVariationSettings: textFontVariationSettings(active) || 'normal',
+ fontWeight: active.fontWeight,
+ textAlign: active.align,
+ }),
+ [active, fontFamily]
+ );
+ return (
+ <Stack bg="bg.inset" bgImage={SPECIMEN_CHECKER} bgSize="1rem 1rem" gap="1" px="3" py="2" rounded="sm">
+ <TextFontReadiness key={textFontKey(face)} fonts={engine.fonts} source={face} />
+ <EditTargetChip layerName={targetName} />
+ <Text aria-hidden fontSize="2rem" lineHeight="1.25" minW="0" style={style} truncate>
+ {textSpecimen(content)}
+ </Text>
+ </Stack>
+ );
};
const AxisControl = ({
@@ -288,7 +376,7 @@ const AxisControl = ({
const ariaLabel = `${axis.label} (${axis.tag})`;
return (
- <PropertyControlRow label={ariaLabel}>
+ <PropertyControlRow label={axis.label}>
<FormSlider
aria-label={ariaLabel}
max={axis.maximum}
@@ -316,6 +404,7 @@ const variationMapsEqual = (
axes: readonly FontAxis[]
): boolean => axes.every((axis) => left[axis.tag] === right[axis.tag]);
+/** A variable face's named instances and axes, as plain rows of the Font group. */
const FontAxisSettings = ({
activeVariations,
applyEdit,
@@ -327,9 +416,12 @@ const FontAxisSettings = ({
}) => {
const { t } = useTranslation();
const [showAdvanced, setShowAdvanced] = useState(false);
- const axes = useMemo(() => font?.axes.filter((axis) => axis.maximum > axis.minimum) ?? [], [font?.axes]);
- const visibleAxes = useMemo(() => axes.filter((axis) => showAdvanced || !axis.hidden), [axes, showAdvanced]);
- const hasHiddenAxes = axes.some((axis) => axis.hidden);
+ const axes = useMemo(() => usableAxes(font), [font]);
+ const visibleAxes = useMemo(
+ () => axes.filter((axis) => showAdvanced || !axis.hidden || OWNING_AXIS_TAGS.has(axis.tag)),
+ [axes, showAdvanced]
+ );
+ const hasHiddenAxes = axes.some((axis) => axis.hidden && !OWNING_AXIS_TAGS.has(axis.tag));
const presetCollection = useMemo(
() =>
createListCollection<{ label: string; value: string }>({
@@ -388,54 +480,120 @@ const FontAxisSettings = ({
);
return (
- <Box borderColor="border.subtle" borderTopWidth="1px" mt="1" pt="1">
- <HStack justifyContent="space-between" minH="7">
- <Text color="fg.muted" fontSize="xs">
- {t('widgets.canvas.toolOptions.textFontAxes')}
- </Text>
- <HStack gap="1">
- <Button
- aria-label={t('widgets.canvas.toolOptions.textFontResetAxes')}
- size="2xs"
- variant="ghost"
- onClick={resetAxes}
- >
- <RotateCcwIcon />
- </Button>
- {hasHiddenAxes ? (
- <ToggleIconButton
- checked={showAdvanced}
- icon={SlidersHorizontalIcon}
- label={advancedLabel}
- onCheckedChange={setShowAdvanced}
- />
- ) : null}
- </HStack>
- </HStack>
+ <>
<PropertyControlRow label={t('widgets.canvas.toolOptions.textFontPreset')}>
<Select
aria-label={t('widgets.canvas.toolOptions.textFontPreset')}
collection={presetCollection}
- gridColumn="2 / -1"
+ minW="0"
positioning={SELECT_POSITIONING}
size="xs"
value={presetValue}
valueText={presetCollection.items.find((item) => item.value === presetValue[0])?.label}
- w="full"
onValueChange={onPreset}
/>
+ <HStack gap="0.5">
+ <Tooltip content={t('widgets.canvas.toolOptions.textFontResetAxes')}>
+ <IconButton
+ aria-label={t('widgets.canvas.toolOptions.textFontResetAxes')}
+ size="2xs"
+ variant="ghost"
+ onClick={resetAxes}
+ >
+ <RotateCcwIcon />
+ </IconButton>
+ </Tooltip>
+ {hasHiddenAxes ? (
+ <ToggleIconButton
+ checked={showAdvanced}
+ icon={SlidersHorizontalIcon}
+ label={advancedLabel}
+ onCheckedChange={setShowAdvanced}
+ />
+ ) : null}
+ </HStack>
</PropertyControlRow>
{visibleAxes.map((axis) => (
<AxisControl key={axis.tag} activeVariations={activeVariations} applyEdit={applyEdit} axis={axis} />
))}
- </Box>
+ </>
);
};
-export const TextFontSettings = ({ engine }: ToolFormProps) => {
+/** One line under the Family row for the catalog's transient states; nothing when it is settled. */
+const FontCatalogStatus = ({
+ hasNextPage,
+ isError,
+ isFetchingNextPage,
+ isPending,
+ onLoadMore,
+ onRetry,
+}: {
+ hasNextPage: boolean;
+ isError: boolean;
+ isFetchingNextPage: boolean;
+ isPending: boolean;
+ onLoadMore: () => void;
+ onRetry: () => void;
+}) => {
const { t } = useTranslation();
const { t: tFonts } = useTranslation('fonts');
- const { active, applyEdit, targetName } = useTextEditor(engine);
+ if (isPending) {
+ return (
+ <PropertyControlRow>
+ <HStack color="fg.muted" gap="1.5" gridColumn="2 / -1" role="status">
+ <Spinner size="xs" />
+ <Text fontSize="2xs">{t('common.loading')}</Text>
+ </HStack>
+ </PropertyControlRow>
+ );
+ }
+ if (isError) {
+ return (
+ <PropertyControlRow>
+ <HStack color="fg.error" gap="1" gridColumn="2 / -1" role="alert">
+ <Text fontSize="2xs" minW="0" truncate>
+ {tFonts('fonts.couldNotLoad')}
+ </Text>
+ <Button
+ aria-label={t('common.retry')}
+ disabled={isFetchingNextPage}
+ flexShrink="0"
+ size="2xs"
+ variant="ghost"
+ onClick={onRetry}
+ >
+ {t('common.retry')}
+ </Button>
+ </HStack>
+ </PropertyControlRow>
+ );
+ }
+ if (hasNextPage) {
+ return (
+ <PropertyControlRow>
+ <Box gridColumn="2 / -1">
+ <Button
+ aria-label={tFonts('fonts.loadMore', { defaultValue: 'Load more fonts' })}
+ disabled={isFetchingNextPage}
+ size="2xs"
+ variant="ghost"
+ onClick={onLoadMore}
+ >
+ {isFetchingNextPage
+ ? tFonts('fonts.loadingMore', { defaultValue: 'Loading more fonts…' })
+ : tFonts('fonts.loadMore', { defaultValue: 'Load more fonts' })}
+ </Button>
+ </Box>
+ </PropertyControlRow>
+ );
+ }
+ return null;
+};
+
+export const TextFontSettings = ({ engine }: ToolFormProps) => {
+ const { t } = useTranslation();
+ const { active, applyEdit } = useTextEditor(engine);
const { data, fetchNextPage, hasNextPage, isError, isFetchNextPageError, isFetchingNextPage, isPending, refetch } =
useInfiniteQuery(fontsInfiniteQueryOptions({ limit: 100, scope: 'all' }));
const loadMoreFonts = useCallback(() => void fetchNextPage(), [fetchNextPage]);
@@ -499,8 +657,10 @@ export const TextFontSettings = ({ engine }: ToolFormProps) => {
);
const familyLabel = activeChoice?.label ?? active.fontRef?.label ?? active.fontFamily;
const activeFont = activeChoice?.font;
- const hasWeightAxis = activeFont?.axes.some((axis) => axis.tag === 'wght') ?? false;
- const hasStyleAxis = activeFont?.axes.some((axis) => axis.tag === 'ital' || axis.tag === 'slnt') ?? false;
+ // An axis owns its property: the plain select for it is not offered alongside.
+ const activeAxes = useMemo(() => usableAxes(activeFont), [activeFont]);
+ const hasWeightAxis = activeAxes.some((axis) => axis.tag === 'wght');
+ const hasStyleAxis = activeAxes.some((axis) => axis.tag === 'ital' || axis.tag === 'slnt');
const onFamily = useCallback(
({ value }: SelectValueChangeDetails<FontChoice>) => {
const choice = familyChoices.find((entry) => entry.value === value[0]);
@@ -579,17 +739,52 @@ export const TextFontSettings = ({ engine }: ToolFormProps) => {
[active.fontWeight, applyEdit]
);
// Ticks preview through the defaults/session; ONE document commit lands on release.
- const previewSize = useCallback(
- (value: number) =>
- applyEdit({ fontSize: Math.min(MAX_TEXT_FONT_SIZE, Math.max(MIN_TEXT_FONT_SIZE, Math.round(value))) }, false),
- [applyEdit]
+ const previewSize = useCallback((value: number) => applyEdit({ fontSize: clampTextSize(value) }, false), [applyEdit]);
+ const setSize = useCallback((value: number) => applyEdit({ fontSize: clampTextSize(value) }, true), [applyEdit]);
+ const sizeGesture = useSliderGesture(Math.round(active.fontSize), setSize, previewSize);
+ const { onChange: onSizeGesture, onChangeEnd: onSizeGestureEnd } = sizeGesture;
+ const onSizeSlider = useCallback(
+ (position: number) => onSizeGesture(sliderPositionToTextSize(position)),
+ [onSizeGesture]
);
- const setSize = useCallback(
- (value: number) =>
- applyEdit({ fontSize: Math.min(MAX_TEXT_FONT_SIZE, Math.max(MIN_TEXT_FONT_SIZE, Math.round(value))) }, true),
- [applyEdit]
+ const onSizeSliderEnd = useCallback(
+ (position: number) => onSizeGestureEnd(sliderPositionToTextSize(position)),
+ [onSizeGestureEnd]
);
- const sizeGesture = useSliderGesture(Math.round(active.fontSize), setSize, previewSize);
+ const onSizeSliderKeyDownCapture = useCallback(
+ (event: KeyboardEvent<HTMLDivElement>) => {
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
+ return;
+ }
+ const increase = event.key === 'ArrowUp' || event.key === 'ArrowRight' || event.key === 'PageUp';
+ const decrease = event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'PageDown';
+ if (!increase && !decrease) {
+ return;
+ }
+ event.preventDefault();
+ event.stopPropagation();
+ const direction = increase ? 1 : -1;
+ const size = Math.round(active.fontSize);
+ if ((size > SIZE_SLIDER_MAX_PX && direction > 0) || (size < SIZE_SLIDER_MIN_PX && direction < 0)) {
+ return;
+ }
+ const multiplier = event.key === 'PageUp' || event.key === 'PageDown' ? 10 : 1;
+ const next =
+ size > SIZE_SLIDER_MAX_PX
+ ? SIZE_SLIDER_MAX_PX
+ : size < SIZE_SLIDER_MIN_PX
+ ? SIZE_SLIDER_MIN_PX
+ : Math.min(
+ SIZE_SLIDER_MAX_PX,
+ Math.max(SIZE_SLIDER_MIN_PX, size + direction * multiplier * textSizeKeyboardStep(size, direction))
+ );
+ if (next !== size) {
+ setSize(next);
+ }
+ },
+ [active.fontSize, setSize]
+ );
+ const formatSize = useCallback(() => `${sizeGesture.value}px`, [sizeGesture.value]);
const onSize = useNumberCommit(setSize);
const previewLineHeight = useCallback(
(value: number) => applyEdit({ lineHeight: Math.max(0.5, Math.round(value * 10) / 10) }, false),
@@ -601,108 +796,89 @@ export const TextFontSettings = ({ engine }: ToolFormProps) => {
);
const lineHeightGesture = useSliderGesture(active.lineHeight, setLineHeight, previewLineHeight);
const onLineHeight = useNumberCommit(setLineHeight);
+ const showStyle = !hasStyleAxis;
+ const showWeight = !hasWeightAxis;
return (
<>
- <EditTargetChip layerName={targetName} />
<PropertyControlRow label={t('widgets.properties.rows.family')}>
- <HStack gap="1" gridColumn="2 / -1" minW="0" w="full">
- <Select
- aria-label={t('widgets.canvas.toolOptions.textFont')}
- collection={familyCollection}
- flex="1"
- groupBy={groupBy}
- itemsMaxH="20rem"
- minW="0"
- positioning={SELECT_POSITIONING}
- renderGroupLabel={renderGroupLabel}
- size="xs"
- value={familyValue}
- valueText={familyLabel}
- onValueChange={onFamily}
- />
- {isPending ? (
- <HStack aria-live="polite" color="fg.muted" flexShrink="0" gap="1" role="status">
- <Spinner size="xs" />
- <Text fontSize="2xs">{t('common.loading')}</Text>
- </HStack>
- ) : isError ? (
- <HStack aria-live="polite" color="fg.error" flexShrink="0" gap="1" role="alert">
- <Text fontSize="2xs">{tFonts('fonts.couldNotLoad')}</Text>
- <Button
- aria-label={t('common.retry')}
- disabled={isFetchingNextPage}
- size="2xs"
- variant="ghost"
- onClick={retryFontCatalog}
- >
- {t('common.retry')}
- </Button>
- </HStack>
- ) : null}
- </HStack>
- </PropertyControlRow>
- {hasNextPage ? (
- <HStack justify="flex-end" minH="7">
- <Button
- aria-label={tFonts('fonts.loadMore', { defaultValue: 'Load more fonts' })}
- disabled={isFetchingNextPage}
- size="2xs"
- variant="ghost"
- onClick={loadMoreFonts}
- >
- {isFetchingNextPage
- ? tFonts('fonts.loadingMore', { defaultValue: 'Loading more fonts…' })
- : tFonts('fonts.loadMore', { defaultValue: 'Load more fonts' })}
- </Button>
- </HStack>
- ) : null}
- <PropertyControlRow label={t('widgets.canvas.toolOptions.textFontStyle')}>
<Select
- aria-label={t('widgets.canvas.toolOptions.textFontStyle')}
- collection={styleCollection}
- disabled={hasStyleAxis}
+ aria-label={t('widgets.canvas.toolOptions.textFont')}
+ collection={familyCollection}
gridColumn="2 / -1"
+ groupBy={groupBy}
+ itemsMaxH="20rem"
+ minW="0"
positioning={SELECT_POSITIONING}
+ renderGroupLabel={renderGroupLabel}
size="xs"
- value={styleValue}
- valueText={styleCollection.items.find((item) => item.value === active.fontStyle)?.label}
- w="full"
- onValueChange={onStyle}
+ value={familyValue}
+ valueText={familyLabel}
+ onValueChange={onFamily}
/>
</PropertyControlRow>
+ <FontCatalogStatus
+ hasNextPage={hasNextPage}
+ isError={isError}
+ isFetchingNextPage={isFetchingNextPage}
+ isPending={isPending}
+ onLoadMore={loadMoreFonts}
+ onRetry={retryFontCatalog}
+ />
+ {showStyle || showWeight ? (
+ <PropertyControlRow
+ label={t(showStyle ? 'widgets.canvas.toolOptions.textFontStyle' : 'widgets.properties.rows.weight')}
+ >
+ {showStyle ? (
+ <Select
+ aria-label={t('widgets.canvas.toolOptions.textFontStyle')}
+ collection={styleCollection}
+ gridColumn={showWeight ? undefined : '2 / -1'}
+ minW="0"
+ positioning={SELECT_POSITIONING}
+ size="xs"
+ value={styleValue}
+ valueText={styleCollection.items.find((item) => item.value === active.fontStyle)?.label}
+ onValueChange={onStyle}
+ />
+ ) : null}
+ {showWeight ? (
+ <Select
+ aria-label={t('widgets.canvas.toolOptions.textWeight')}
+ collection={weightCollection}
+ flexShrink={0}
+ positioning={SELECT_POSITIONING}
+ size="xs"
+ triggerProps={WEIGHT_TRIGGER_PROPS}
+ value={weightValue}
+ valueText={String(active.fontWeight)}
+ w="4.5rem"
+ onValueChange={onWeight}
+ />
+ ) : null}
+ </PropertyControlRow>
+ ) : null}
<PropertyControlRow label={t('widgets.properties.rows.size')}>
<FormSlider
aria-label={t('widgets.canvas.toolOptions.textSize')}
- max={MAX_TEXT_FONT_SIZE}
- min={MIN_TEXT_FONT_SIZE}
- value={sizeGesture.value}
- onValueChange={sizeGesture.onChange}
- onValueChangeEnd={sizeGesture.onChangeEnd}
+ formatValue={formatSize}
+ getAriaValueText={formatSize}
+ max={SIZE_SLIDER_POSITIONS}
+ min={0}
+ step={1}
+ value={textSizeToSliderPosition(sizeGesture.value)}
+ onKeyDownCapture={onSizeSliderKeyDownCapture}
+ onValueChange={onSizeSlider}
+ onValueChangeEnd={onSizeSliderEnd}
/>
<FormNumberField
aria-label={t('widgets.canvas.toolOptions.textSize')}
max={MAX_TEXT_FONT_SIZE}
min={MIN_TEXT_FONT_SIZE}
suffix="px"
- value={String(Math.round(active.fontSize))}
+ value={String(sizeGesture.value)}
onValueCommit={onSize}
/>
</PropertyControlRow>
- <PropertyControlRow label={t('widgets.properties.rows.weight')}>
- <Select
- aria-label={t('widgets.canvas.toolOptions.textWeight')}
- collection={weightCollection}
- disabled={hasWeightAxis}
- flexShrink={0}
- positioning={SELECT_POSITIONING}
- size="xs"
- triggerProps={WEIGHT_TRIGGER_PROPS}
- value={weightValue}
- valueText={String(active.fontWeight)}
- w="4.5rem"
- onValueChange={onWeight}
- />
- </PropertyControlRow>
<PropertyControlRow label={t('widgets.properties.rows.lineHeight')}>
<FormSlider
aria-label={t('widgets.canvas.toolOptions.textLineHeight')}
@@ -718,11 +894,11 @@ export const TextFontSettings = ({ engine }: ToolFormProps) => {
max={4}
min={0.5}
step={0.1}
- value={active.lineHeight.toFixed(1)}
+ value={lineHeightGesture.value.toFixed(1)}
onValueCommit={onLineHeight}
/>
</PropertyControlRow>
- <FontAxisSettings activeVariations={active.fontVariations} applyEdit={applyEdit} font={activeChoice?.font} />
+ <FontAxisSettings activeVariations={active.fontVariations} applyEdit={applyEdit} font={activeFont} />
</>
);
};
@@ -733,7 +909,7 @@ export const TextParagraphSettings = ({ engine }: ToolFormProps) => {
const onAlign = useCallback((next: TextAlign) => applyEdit({ align: next }, true), [applyEdit]);
return (
<PropertyControlRow label={t('widgets.properties.rows.align')}>
- <HStack gap="0.5">
+ <HStack aria-label={t('widgets.properties.rows.align')} gap="0.5" role="group">
{ALIGN_VALUES.map((value) => (
<AlignButton key={value} active={active.align === value} value={value} onSelect={onAlign} />
))}
@@ -749,7 +925,7 @@ export const TextColorSettings = ({ engine }: ToolFormProps) => {
const onChange = useCallback((hex: string) => applyEdit({ color: hex }, false), [applyEdit]);
const onChangeEnd = useCallback((hex: string) => applyEdit({ color: hex }, true), [applyEdit]);
return (
- <PropertyControlRow label={t('widgets.properties.rows.color')}>
+ <PropertyControlRow label={t('widgets.properties.rows.fill')}>
<ColorPicker
aria-label={t('widgets.canvas.toolOptions.textColor')}
value={active.color}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textForm.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textForm.tsx
index 2cb023da05..071dd3a50c 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textForm.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textForm.tsx
@@ -1,18 +1,21 @@
-import type {
- ToolFormComponent,
- ToolPropertyForm,
-} from '@workbench/widgets/canvas/tool-presentation/toolFormContracts';
+import type { ToolPropertyForm } from '@workbench/widgets/canvas/tool-presentation/toolFormContracts';
+import type { ComponentType, ReactNode } from 'react';
import { Skeleton } from '@chakra-ui/react';
import { lazy, Suspense } from 'react';
-const loading = <Skeleton height="8" />;
+const loadingRows = <Skeleton height="8" />;
+// Matches the specimen card so the form does not jump when the chunk lands.
+const loadingCard = <Skeleton height="20" />;
// Catalog queries and variable-font controls are needed only while text is selected.
-const lazyGroup = (load: () => Promise<{ default: ToolFormComponent }>): ToolFormComponent => {
+const lazyPart = <Props extends object>(
+ load: () => Promise<{ default: ComponentType<Props> }>,
+ fallback: ReactNode = loadingRows
+) => {
const Body = lazy(load);
- return (props) => (
- <Suspense fallback={loading}>
+ return (props: Props) => (
+ <Suspense fallback={fallback}>
<Body {...props} />
</Suspense>
);
@@ -21,21 +24,22 @@ const lazyGroup = (load: () => Promise<{ default: ToolFormComponent }>): ToolFor
export const textForm: ToolPropertyForm = {
groups: [
{
- body: lazyGroup(() => import('./TextOptions').then((module) => ({ default: module.TextFontSettings }))),
+ body: lazyPart(() => import('./TextOptions').then((module) => ({ default: module.TextFontSettings }))),
id: 'text-font',
labelKey: 'widgets.properties.groups.font',
},
{
- body: lazyGroup(() => import('./TextOptions').then((module) => ({ default: module.TextParagraphSettings }))),
+ body: lazyPart(() => import('./TextOptions').then((module) => ({ default: module.TextParagraphSettings }))),
id: 'text-paragraph',
labelKey: 'widgets.properties.groups.paragraph',
},
{
- body: lazyGroup(() => import('./TextOptions').then((module) => ({ default: module.TextColorSettings }))),
+ body: lazyPart(() => import('./TextOptions').then((module) => ({ default: module.TextColorSettings }))),
id: 'text-color',
labelKey: 'widgets.properties.rows.color',
},
],
id: 'text',
paintsLeaf: true,
+ preview: lazyPart(() => import('./TextOptions').then((module) => ({ default: module.TextPreview })), loadingCard),
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textSizeControl.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textSizeControl.test.ts
new file mode 100644
index 0000000000..732e40de8f
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/textSizeControl.test.ts
@@ -0,0 +1,42 @@
+import { describe, expect, it } from 'vitest';
+
+import { sliderPositionToTextSize, textSizeKeyboardStep, textSizeToSliderPosition, textSpecimen } from './TextOptions';
+
+describe('text size slider scale', () => {
+ it('round-trips whole pixel sizes across the track', () => {
+ for (const size of [4, 12, 48, 100, 250, 600]) {
+ expect(sliderPositionToTextSize(textSizeToSliderPosition(size))).toBe(size);
+ }
+ });
+
+ it('spends most of the track on the sizes text is set at', () => {
+ expect(textSizeToSliderPosition(48)).toBeGreaterThan(400);
+ expect(textSizeToSliderPosition(48)).toBeLessThan(600);
+ expect(textSizeToSliderPosition(4)).toBe(0);
+ expect(textSizeToSliderPosition(600)).toBe(1000);
+ });
+
+ it('pins sizes beyond the track at its end and never returns a fraction', () => {
+ expect(textSizeToSliderPosition(2000)).toBe(1000);
+ expect(sliderPositionToTextSize(1000)).toBe(600);
+ expect(sliderPositionToTextSize(-5)).toBe(4);
+ expect(Number.isInteger(sliderPositionToTextSize(333))).toBe(true);
+ });
+
+ it('steps by whole pixels below 100 and by tens above, in both directions at the boundary', () => {
+ expect(textSizeKeyboardStep(48, 1)).toBe(1);
+ expect(textSizeKeyboardStep(99, 1)).toBe(1);
+ expect(textSizeKeyboardStep(100, 1)).toBe(10);
+ expect(textSizeKeyboardStep(100, -1)).toBe(1);
+ expect(textSizeKeyboardStep(110, -1)).toBe(10);
+ });
+});
+
+describe('textSpecimen', () => {
+ it('shows the first non-empty line, trimmed and capped, else a neutral sample', () => {
+ expect(textSpecimen(null)).toBe('Aa');
+ expect(textSpecimen(' \n\t')).toBe('Aa');
+ expect(textSpecimen('\n\n Hello world \nsecond')).toBe('Hello world');
+ expect(textSpecimen('x'.repeat(60))).toHaveLength(40);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/PropertyPrimitives.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/PropertyPrimitives.tsx
index 1883f09473..567786a6cd 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/PropertyPrimitives.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/PropertyPrimitives.tsx
@@ -13,11 +13,12 @@ const GROUP_HEADER_HOVER = { color: 'fg' } as const;
/**
* One settings row of a tool property form: a fixed label column, a flexible
* control cell, and a fixed trailing cell. Grid, not wrapping flex — a slider
- * and its number field are one row at every pane width.
+ * and its number field are one row at every pane width. No label leaves the
+ * column empty so a continuation row lines up under the row above.
*/
-export const PropertyControlRow = ({ children, label }: { children: ReactNode; label: string }) => (
+export const PropertyControlRow = ({ children, label }: { children: ReactNode; label?: string }) => (
<Grid alignItems="center" columnGap="2" gridTemplateColumns="4.5rem minmax(0, 1fr) auto" minH="7" w="full">
- <Text color="fg.muted" fontSize="xs" minW="0" truncate>
+ <Text color="fg.muted" fontSize="xs" minW="0" title={label} truncate>
{label}
</Text>
{children}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolFormContracts.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolFormContracts.ts
index 2b8f407dd9..c5c3dc91e3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolFormContracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolFormContracts.ts
@@ -5,7 +5,7 @@ import type { ComponentType } from 'react';
export type CanvasToolOptionsEngine = Pick<
CanvasEngineHandle,
- 'document' | 'interaction' | 'layers' | 'projectId' | 'selection' | 'tools' | 'viewport'
+ 'document' | 'fonts' | 'interaction' | 'layers' | 'projectId' | 'selection' | 'tools' | 'viewport'
>;
export type CanvasOperationKind = Extract<CanvasOperationState, { status: 'active' }>['identity']['kind'];
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
index ce78ad334c..601b2fda7b 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
@@ -1,4 +1,5 @@
/* oxlint-disable react-perf/jsx-no-new-function-as-prop */
+import type * as fonts from '@features/fonts';
import type { CanvasLayerSourceContract } from '@workbench/canvas-engine/api';
import type { CanvasOperationState } from '@workbench/canvas-operations/api';
import type { CanvasEngine } from '@workbench/canvas-operations/createCanvasEngine';
@@ -7,6 +8,7 @@ import type { CanvasProjectMutationPort } from '@workbench/canvasProjectMutation
import type { Project } from '@workbench/projectContracts';
import { Box, ChakraProvider } from '@chakra-ui/react';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { system } from '@theme/system';
import {
groupContract,
@@ -36,6 +38,16 @@ const harness = vi.hoisted(() => ({
project: null as Project | null,
}));
+// The text form's catalog query must not reach the network from this harness.
+vi.mock('@features/fonts', async (importOriginal) => ({
+ ...(await importOriginal<typeof fonts>()),
+ fontsInfiniteQueryOptions: () => ({
+ getNextPageParam: () => undefined,
+ initialPageParam: 0,
+ queryFn: () => Promise.resolve({ items: [], limit: 100, offset: 0, total: 0 }),
+ queryKey: ['font-catalog-pane-test'],
+ }),
+}));
vi.mock('@workbench/WorkbenchContext', async () => {
const { useSyncExternalStore } = await import('react');
const subscribe = (listener: () => void) => {
@@ -164,6 +176,7 @@ const createFakeOperations = () => {
};
};
+const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
let host: HTMLDivElement | null = null;
let root: Root | null = null;
let registry: EngineRegistry | null = null;
@@ -180,7 +193,7 @@ const settle = () =>
const IDENTITY = { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 };
-type Selection = 'none' | 'layer' | 'group' | 'mask' | 'shape' | 'gradient';
+type Selection = 'none' | 'layer' | 'group' | 'mask' | 'shape' | 'gradient' | 'text';
const SHAPE_SOURCE = {
fill: '#ff0000',
@@ -191,6 +204,16 @@ const SHAPE_SOURCE = {
type: 'shape',
width: 10,
} satisfies Extract<CanvasLayerSourceContract, { type: 'shape' }>;
+const TEXT_SOURCE = {
+ align: 'center',
+ color: '#123456',
+ content: 'Hello there\nsecond line',
+ fontFamily: 'system-ui, sans-serif',
+ fontSize: 72,
+ fontWeight: 700,
+ lineHeight: 1.5,
+ type: 'text',
+} satisfies Extract<CanvasLayerSourceContract, { type: 'text' }>;
const GRADIENT_SOURCE = {
angle: 0,
height: 10,
@@ -214,9 +237,11 @@ const mount = async (View: typeof PropertiesPane, selection: Selection = 'none')
? [layerContract('l0', 'raster', { name: 'My Shape', source: SHAPE_SOURCE })]
: selection === 'gradient'
? [layerContract('l0', 'raster', { name: 'My Gradient', source: GRADIENT_SOURCE })]
- : selection === 'mask'
- ? [layerContract('m0', 'inpaint_mask', { name: 'Mask' })]
- : [groupContract('g0', [layerContract('l0', 'raster', { name: 'Paint' })], { name: 'Folder' })];
+ : selection === 'text'
+ ? [layerContract('l0', 'raster', { name: 'My Text', source: TEXT_SOURCE })]
+ : selection === 'mask'
+ ? [layerContract('m0', 'inpaint_mask', { name: 'Mask' })]
+ : [groupContract('g0', [layerContract('l0', 'raster', { name: 'Paint' })], { name: 'Folder' })];
harness.project = applyCanvasProjectMutation(base, {
document: {
...createEmptyCanvasDocument(),
@@ -238,7 +263,9 @@ const mount = async (View: typeof PropertiesPane, selection: Selection = 'none')
root?.render(
<I18nextProvider i18n={i18n}>
<ChakraProvider value={system}>
- <View />
+ <QueryClientProvider client={queryClient}>
+ <View />
+ </QueryClientProvider>
</ChakraProvider>
</I18nextProvider>
);
@@ -339,6 +366,47 @@ describe('Properties pane', () => {
expect(width.element().getAttribute('data-disabled')).not.toBeNull();
});
+ it('previews the selected text layer above its form and offers style and weight on one row', async () => {
+ await mount(PropertiesPane, 'text');
+ await act(() => engine!.tools.setTool('text'));
+ await settle();
+ await expect.element(page.getByRole('combobox', { exact: true, name: 'Style' })).toBeVisible();
+ // The specimen card carries the chip and the layer's first line in its own style.
+ expect(host!.textContent).not.toContain('second line');
+ const specimen = Array.from(host!.querySelectorAll<HTMLElement>('[aria-hidden="true"]')).find((el) =>
+ el.textContent?.startsWith('Hello there')
+ )!;
+ expect(specimen.parentElement!.textContent).toContain('Editing: My Text');
+ expect(getComputedStyle(specimen).fontWeight).toBe('700');
+ expect(getComputedStyle(specimen).textAlign).toBe('center');
+ expect(getComputedStyle(specimen).color).toBe('rgb(18, 52, 86)');
+ const style = page.getByRole('combobox', { exact: true, name: 'Style' }).element();
+ const weight = page.getByRole('combobox', { exact: true, name: 'Weight' }).element();
+ expect(Math.abs(style.getBoundingClientRect().top - weight.getBoundingClientRect().top)).toBeLessThan(2);
+ expect((page.getByRole('spinbutton', { exact: true, name: 'Font size' }).element() as HTMLInputElement).value).toBe(
+ '72'
+ );
+ });
+
+ it('steps the log-scaled text size slider by whole pixels from the keyboard', async () => {
+ await mount(PropertiesPane);
+ await act(() => engine!.tools.setTool('text'));
+ await settle();
+ const slider = page.getByRole('slider', { exact: true, name: 'Font size' });
+ await expect.element(slider).toBeVisible();
+ const field = () =>
+ (page.getByRole('spinbutton', { exact: true, name: 'Font size' }).element() as HTMLInputElement).value;
+ expect(field()).toBe('48');
+ await act(() => (slider.element() as HTMLElement).focus());
+ await act(() => userEvent.keyboard('{ArrowRight}'));
+ expect(field()).toBe('49');
+ await act(() => userEvent.keyboard('{PageUp}'));
+ expect(field()).toBe('59');
+ await act(() => userEvent.keyboard('{ArrowLeft}'));
+ expect(field()).toBe('58');
+ expect(engine!.interaction.get('textOptions').fontSize).toBe(58);
+ });
+
it('names a selected gradient in the chip and moves a default stop from the keyboard', async () => {
await mount(PropertiesPane, 'gradient');
await act(() => engine!.tools.setTool('gradient'));