Skip to content

Handle text layer scaling by adjusting fontSize and maxWidth#11

Open
prabhatexit0 wants to merge 3 commits into
mainfrom
claude/determined-brahmagupta-4X5WU
Open

Handle text layer scaling by adjusting fontSize and maxWidth#11
prabhatexit0 wants to merge 3 commits into
mainfrom
claude/determined-brahmagupta-4X5WU

Conversation

@prabhatexit0
Copy link
Copy Markdown
Owner

Summary

This PR modifies the transform handle behavior for text layers to convert scale transformations into fontSize and maxWidth adjustments, keeping the scale values at 1. This ensures text layers are resized through their text-specific properties rather than generic scale transforms.

Key Changes

  • Text layer scale absorption: When starting a drag operation on a text layer with non-unit scale values, the existing scale is absorbed into fontSize and maxWidth properties, resetting scale to 1
  • Scale-to-property conversion during drag:
    • Vertical scaling (scaleY) is converted to fontSize adjustments
    • Horizontal scaling (scaleX) is converted to maxWidth adjustments
    • Text layers maintain scaleX=1 and scaleY=1 throughout the transform
  • Separate handling for corner vs. edge handles: Corner handles affect both dimensions, while edge handles only affect their respective dimension
  • Text drawing initialization: When creating a new text layer with the draw-text tool, the initial width is set to 0 instead of 200 to match the expected behavior for text input

Implementation Details

  • Added isTextLayer, textFontSize, and textMaxWidth to the DragState interface to track text-specific properties during drag operations
  • Text properties are updated via store.updateTextProperties() while transform is updated via store.setTransform()
  • Font size values are rounded to one decimal place for consistency
  • The implementation preserves rotation handling and position adjustments for text layers

https://claude.ai/code/session_01R44b9C3iAQZZLpvJefkVMb

Text layers now resize by changing fontSize and maxWidth instead of
scaleX/scaleY, preventing glyph distortion when stretching or shrinking.
Click-to-create text no longer sets a default maxWidth of 200px, so the
bounding box fits the actual text content.

https://claude.ai/code/session_01R44b9C3iAQZZLpvJefkVMb
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 4, 2026

Deploy Preview for vizpix ready!

Name Link
🔨 Latest commit 7bae986
🔍 Latest deploy log https://app.netlify.com/projects/vizpix/deploys/69a85f499ad2c400080565e0
😎 Deploy Preview https://deploy-preview-11--vizpix.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

claude added 2 commits March 4, 2026 16:19
- Text now spawns at cursor position instead of (0,0) when clicking
  to create. The rect is always passed to addTextLayer; maxWidth is
  only set when the drag width > 0.
- Resize only changes maxWidth (wrapping area), never fontSize.
  Font size is controlled exclusively via the properties panel.
  Vertical handles are no-ops for text since height is content-driven.
- Fix measureTextLayer to account for letterSpacing, matching how
  text is rendered and improving hit test accuracy.

https://claude.ai/code/session_01R44b9C3iAQZZLpvJefkVMb
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