Skip to content

fix: preserve letterSpacing and shadows from selectedTextStyle in text editor input#788

Open
faizahmaddae wants to merge 1 commit intohm21:stablefrom
faizahmaddae:fix/preserve-letter-spacing
Open

fix: preserve letterSpacing and shadows from selectedTextStyle in text editor input#788
faizahmaddae wants to merge 1 commit intohm21:stablefrom
faizahmaddae:fix/preserve-letter-spacing

Conversation

@faizahmaddae
Copy link
Contributor

@faizahmaddae faizahmaddae commented Mar 9, 2026

Problem

The TextEditorInput widget hard-codes letterSpacing: 0 and shadows: [] in its style copyWith call (text_editor_input.dart#L206-L212):

style: widget.selectedTextStyle.copyWith(
  color: widget.textColor,
  fontSize: widget.textFontSize,
  letterSpacing: 0,           // ← overrides any user-set value
  decoration: TextDecoration.none,
  shadows: [],                // ← overrides any user-set shadows
),

This means any letterSpacing or shadows set on selectedTextStyle (e.g. via setTextStyle(style.copyWith(letterSpacing: 5))) is silently discarded in the live text input preview.

Observed behavior

Context letterSpacing respected? shadows respected?
Hint text (placeholder) ✅ Yes ❌ No (hintStyle also overrides)
Live typing preview No — always 0 No — always empty
Final rendered layer (LayerWidgetTextItem) ✅ Yes ✅ Yes

The values are correctly stored on the TextLayer and render properly once the text is placed on the canvas, but users cannot see the effect while editing. This makes letter spacing and shadow controls appear broken during the editing experience.

Root cause trace

  1. User adjusts letter spacing / shadow → TextEditorState.setTextStyle(style.copyWith(letterSpacing: value))selectedTextStyle is updated correctly
  2. TextEditorInput receives updated selectedTextStyle as a prop ✅
  3. _buildInputField() applies selectedTextStyle.copyWith(letterSpacing: 0, shadows: [])overrides both values
  4. RoundedBackgroundTextField receives style with zeroed-out values → preview shows no spacing or shadows

Fix

Removed the letterSpacing: 0 and shadows: [] lines so the input field respects whatever values are already set on selectedTextStyle. When these properties are not explicitly set, they default to null (Flutter's default behavior), so there is no change in behavior for the default case.

 style: widget.selectedTextStyle.copyWith(
   color: widget.textColor,
   fontSize: widget.textFontSize,
-  letterSpacing: 0,
   decoration: TextDecoration.none,
-  shadows: [],
 ),

Impact

  • 2 lines removed, zero new lines added
  • No behavior change when letterSpacing / shadows are not explicitly set (defaults to null)
  • Enables real-time preview of letter spacing and shadow changes in the text editor input
  • Consistent with how the final layer rendering already works (LayerWidgetTextItem preserves both properties)

@faizahmaddae faizahmaddae force-pushed the fix/preserve-letter-spacing branch from 3545871 to 69df52e Compare March 9, 2026 16:36
@faizahmaddae faizahmaddae changed the title fix: preserve letterSpacing from selectedTextStyle in text editor input fix: preserve letterSpacing and shadows from selectedTextStyle in text editor input Mar 9, 2026
@hm21
Copy link
Owner

hm21 commented Mar 14, 2026

@faizahmaddae Thanks for creating the PR and sorry for the late review.

I remember we added this cuz some fonts had alignment issues, and this fixed the problem (which is weird i know). However, I think the best approach would be to add it to the TextEditorStyle class and keep it there as the default with letterSpacing: 0 and shadows: []. That way we avoid any breaking changes for users who rely on those special fonts, while still allowing it to be controlled.

@faizahmaddae
Copy link
Contributor Author

Thanks for the feedback! I've updated the PR based on your suggestion.

Instead of removing the hard-coded letterSpacing: 0 and shadows: [], I've moved them into the TextEditorStyle class as configurable properties:

  • inputLetterSpacing (default: 0) — preserves the fix for font alignment issues
  • inputShadows (default: const []) — prevents unwanted shadow rendering

Both properties are nullable, so users who need the font's native behavior can set them to null.

The hintStyle and style in TextEditorInput now read from widget.configs.style.inputLetterSpacing and widget.configs.style.inputShadows instead of hard-coding the values.

This way:

  • No breaking changes — existing users get the same behavior
  • Users with special fonts that need native letter spacing/shadows can override via TextEditorStyle

Please take a look when you get a chance!

…torStyle

Instead of hard-coding letterSpacing: 0 and shadows: [] in the text
input copyWith, move these values into TextEditorStyle as configurable
properties with the same defaults:

- inputLetterSpacing (default: 0) — fixes font alignment issues
- inputShadows (default: []) — prevents unwanted shadow rendering

This preserves the existing behavior by default while allowing users
to override these values (e.g. set to null) when they need the font's
native letter spacing or shadows.

Both hintStyle and style in TextEditorInput now read from these
style properties.
@faizahmaddae faizahmaddae force-pushed the fix/preserve-letter-spacing branch from 5844762 to 61589f9 Compare March 14, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants