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

Getting old font size value of text after image resizing.

Contributor ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

Hi all,

I write the script of getting font size of the text layer. I am getting old font size after image resizing.

Following are the steps:

- I write the function to get the property of selected text layer..

     getInfoOfText=function(textLayer)

     {

          ........;

          var textItem = textLayer.textItem;

          var fontSize = textItem.size;

          .........;

     }

- After image resize to 50%. I am executing this function.

But, I am still getting old font size value.

Let's say the font size of text = 36 px.

Now I apply Image Resize to 50%. So, the font size of the text becomes 18 px.

Now If I execute the function "getInfoOfText", I am still getting 36 px.

I am unable to understand the behaviour. Am I missing something here? Is there any way to get the correct font size value?

Please note that I am using CS6 version.

Waiting for ur help guys.

Thanks

TOPICS
Actions and scripting

Views

2.3K

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

correct answers 1 Correct answer

Enthusiast , Oct 30, 2013 Oct 30, 2013

It seems that there is a BUG in CS6 and CC with transformed text, here is a function from http://www.ps-bridge-scripts.talktalk.net/

function getFontSize(){

if(app.version.match(/^\d+/) < 13) return activeDocument.activeLayer.textItem.size;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));

var textSize =  desc.getList(stringIDToTypeID('textStyleRan

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

It seems that there is a BUG in CS6 and CC with transformed text, here is a function from http://www.ps-bridge-scripts.talktalk.net/

function getFontSize(){

if(app.version.match(/^\d+/) < 13) return activeDocument.activeLayer.textItem.size;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));

var textSize =  desc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle')).getDouble (stringIDToTypeID('size'));

if (desc.hasKey(stringIDToTypeID('transform'))) {

            var mFactor = desc.getObjectValue(stringIDToTypeID('transform')).getUnitDoubleValue (stringIDToTypeID('yy') );

    textSize = (textSize* mFactor).toFixed(2).toString().replace(/0+$/g,'').replace(/\.$/,'');

    }

return textSize;

};

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
Contributor ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

LATEST

Thanks Philip for the response,

It is working.

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