refactor: centralize font-size clamps in textLimits.ts

Single source of truth for font-size constraints (text 6–160, sticky
8–96) used by creation defaults, resize-bake, and any future mutation
paths. Replaces scattered hardcoded min/max values.
This commit is contained in:
Hiren Kangad
2026-03-12 23:35:25 +05:30
parent 1ac727ea60
commit 150bb91a27
3 changed files with 28 additions and 3 deletions
+2 -1
View File
@@ -15,6 +15,7 @@ import { PinOverlay } from '../canvas/PinOverlay';
import { CropOverlay } from '../canvas/CropOverlay';
import { TextSprite } from '../canvas/sprites/TextSprite';
import { TextSharpnessManager } from '../canvas/textSharpness';
import { clampTextFontSize } from '../canvas/textLimits';
// PresenceOverlay removed — remote selection highlighting was too heavy for minimal benefit
import { connectSocket, disconnectSocket } from '../socket';
import api from '../api';
@@ -218,7 +219,7 @@ export function useCanvasSetup(deps: CanvasSetupDeps) {
// Use average scale as font multiplier
const scale = (absSx + absSy) / 2;
const d = item.data as any;
d.fontSize = Math.round(d.fontSize * scale);
d.fontSize = clampTextFontSize(d.fontSize * scale);
d.sx = item.data.sx > 0 ? 1 : -1;
d.sy = item.data.sy > 0 ? 1 : -1;
if (item.displayObject instanceof TextSprite) {