Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting text contents via script changes formatting

Enthusiast ,
Mar 21, 2025 Mar 21, 2025

Setting textItem contents for an empty text layer via script changes the text layer formatting. Verified on both Windows 10 Pro and Mac Sequoia, Photoshop 26.4.1.

 

1. Create a new document.

2. Add a type layer with the text tool, type in a few characters

3. Manually set font and size formatting

4. Manually select and delete the text, clicking the checkmark in the Options bar to leave a blank type layer

5. Run the following code snippet:

var docRef = app.activeDocument;
var layerRef = docRef.activeLayer;
var textRef = layerRef.textItem;
textRef.contents = Window.prompt('Enter text');

Result: The text size and font will change to Myriad Pro 9 point. This is regardless of the setting in Preferences/Settings->Type->Set default font size automatically

Expected: Size and font will remain the same

Double-clicking the type layer in the Layers panel and then manually typing in characters retains the previous formatting

TOPICS
Actions and scripting , macOS , Windows
42
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Adobe