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

How to change fontsize of edittext object?

New Here ,
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

I tried this code....

editbox.graphics.font = ScriptUI.newFont ("ArialMT", ScriptUI.FontStyle.REGULAR,16);

...

editbox.graphics.font = ScriptUI.newFont ("ArialMT", ScriptUI.FontStyle.REGULAR,20);

but.... nothing to happened.

(Photoshop 2015 cc in Windows 10)

TOPICS
Actions and scripting

Views

827

Translate

Translate

Report

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
Adobe
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

Moving to  Photoshop Scripting

Votes

Translate

Translate

Report

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
New Here ,
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

You can try this : ScriptUI for dummies | Peter Kahrel 

var w = new Window ("dialog");

var s = w.add ("statictext", undefined, "Static");

var e = w.add ("edittext", undefined, "Edit");

// Font and its colour for the first item, statictext

s.graphics.font = ScriptUI.newFont ("Trebuchet MS", "Bold", 20);

s.graphics.foregroundColor = s.graphics.newPen (w.graphics.PenType.SOLID_COLOR, [0.2, 0.2, 0.2], 1);

// Font and colours for the second item, edittext

e.graphics.font = ScriptUI.newFont ("Arial", "REGULAR", 20);

e.graphics.foregroundColor = e.graphics.newPen (e.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);

e.graphics.backgroundColor = e.graphics.newBrush (e.graphics.BrushType.SOLID_COLOR, [0.5, 0.5, 0.5]);

w.show ();

" editbox.graphics.font = ScriptUI.newFont ("ArialMT", ScriptUI.FontStyle.REGULAR,20);"

     In my Photoshop this font (ArialMT) does not exist . Please ensure that you have this font.


https://dl.dropboxusercontent.com/u/5114007/scriptui-2-9.pdf   page 88 .


have fun  

Votes

Translate

Translate

Report

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
New Here ,
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

Thank you for your response.

I tried to run the code what you provided. but my problem still exist.

P.S "Arial" is family name, and "ArlalMT" is postScriptName. the same.
and..

<p.108 in JavaScript Tools Guide CC.pdf>

I  tried this code too.

var w = new Window('dialog','test text input');

var p = w.add('panel',undefined,'Input here');

var editbox = p.add('edittext',undefined,'your name',{characters:30});

var isActivated = false;

w.onActivate = function(){

    if(isActivated) return;

    alert("EditBox ItemSize=" + editbox.itemSize);

    isActivated = true;

    };

w.show();

but, I got result is "undefined", so strange.

Votes

Translate

Translate

Report

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
Engaged ,
Feb 04, 2016 Feb 04, 2016

Copy link to clipboard

Copied

Are you using CC 2015?  The static text size stopped working in CC 2015 as well.  I have not tested to see if it was fixed in latest release though.

Votes

Translate

Translate

Report

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
Engaged ,
Feb 04, 2016 Feb 04, 2016

Copy link to clipboard

Copied

I just tested CC2015.1.2 and the statictext sizing is fixed now.  The edittext sizing does not work.  I then ran the same script in CS6 and the edittext sizing works.  It appears that Adobe has fixed the statictext sizing in CC2015 but not the edittext yet.

Votes

Translate

Translate

Report

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
New Here ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

LATEST

Thank you for your infomation.

Votes

Translate

Translate

Report

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
Enthusiast ,
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

If you just need to set text size you do that with layer.textItem.size, but you have to consider two things:

a) It's a unit value so it's better to not assign a number because it depends on user settings (AND Photoshop version!) if it's treated as px or pt

b) You have to consider transforms, i.e. if user has stretched doc/layer, it'll multiply the size

Below is not 100%, you need to parse the value from a reference (my code had this overly complex utility function

setTextSize: function (layer, size) {

  if (layer && layer.kind == LayerKind.TEXT && size) {

  var text_item = layer.textItem

  var scale = _getTextScaleVertical(layer)

  var unit_val = new UnitValue(size/scale+"px")

  text_item.size = unit_val

  }

}

_getTextScaleVertical: function (layer) {

  var ref = new ActionReference()

  ref.putIdentifier( charIDToTypeID("Lyr "), layer.id)

  var desc = executeActionGet(ref)

  var result = // parse out horizontal text scale from "textKey.transform.yy"

  return result

}

Votes

Translate

Translate

Report

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