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

Did CC 2014.2 break textItem.size?

Community Beginner ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

Scripts that worked before the update are now broken, and text layers created via script are all 12px. See this simple script:

var docRef = activeDocument;

var TextLabel = docRef.artLayers.add();

TextLabel.kind = LayerKind.TEXT;

TextLabel.name = "Test";

TextLabel.textItem.contents = "This text should be 50pt";

TextLabel.textItem.size = new UnitValue("50 points"); // other variations, such as TextLabel.textItem.size = 50 also fail.

TextLabel.textItem.font = "Monaco";

Any help? Thanks.

TOPICS
Actions and scripting

Views

5.3K
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

Adobe Employee , Dec 10, 2014 Dec 10, 2014

This should be fixed in the 2014.2.2 update released tonight. Choose Help>Updates... to install.

Votes

Translate
Adobe
Advisor ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

This is a problem that I think was previously seen.

Here's a slight revision of your test code.

var doc = app.documents.add();
var layer = doc.artLayers.add(); 
layer.kind = LayerKind.TEXT; 
layer.name = "Test"; 
var titem = layer.textItem;
titem.contents = "This text should be 50pt"; 
titem.size = new UnitValue("50", "pts");
titem.font = "Monaco";

alert(titem.size);

Run it in CS6 and the alert is "50 pt".

Run it in CC14 (and maybe CC) and the alert is "12 pt".

I'll see if I can find a work around for this because it's causing problems with some of my code.

X

Votes

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
Community Beginner ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

Thanks for the adjusted test code! Truthfully I don't know if the UnitValue() method was broken before 2014.2 or not, but I know for sure that this shorthand method was working fine in both CC and CC 2014:

titem.size = 50;

Note that this method isn't the documented one and is probably more likely to give unexpected results, but this is the one that I can say for sure was working. If I'm remembering correctly, the unitless number is interpreted as pixels (even if your measurement unit is currently set to points), so this would only yield 50pts if your resolution is set to 72.

Votes

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
Advisor ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

I found the/a problem. When you create a new text layer, the size is getting stuck at 12 pixels. And there is no way using the DOM to change that. Run it in the debugger with a breakpoint and try to change it to anything other than 12 px. I couldn't.

I'm going to see if I can find a workaround with some AM code.

Votes

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
Advisor ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

OK Using  ActionManager code can work around the problem. Below I have an object called PSCCFontSizeFix with a single method setFontSize that takes a layer and the font size in points. This needs to be the first operation on the text layer or odd things may happen. Also, you will need to explicitly set the font type-face as the one embedded probably isn't the one that you want. Sample usage code is down at the bottom.

PSCCFontSizeFix = {};
PSCCFontSizeFix.setFontSize = function(layer, pts) {
var idsetd = charIDToTypeID( "setd" );
    var desc70 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idTxLr = charIDToTypeID( "TxLr" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref13.putEnumerated( idTxLr, idOrdn, idTrgt );
    desc70.putReference( idnull, ref13 );
    var idT = charIDToTypeID( "T   " );
        var desc71 = new ActionDescriptor();
        var idTxt = charIDToTypeID( "Txt " );
        desc71.putString( idTxt, """tmp""" );
        var idwarp = stringIDToTypeID( "warp" );
            var desc72 = new ActionDescriptor();
            var idwarpStyle = stringIDToTypeID( "warpStyle" );
            var idwarpStyle = stringIDToTypeID( "warpStyle" );
            var idwarpNone = stringIDToTypeID( "warpNone" );
            desc72.putEnumerated( idwarpStyle, idwarpStyle, idwarpNone );
            var idwarpValue = stringIDToTypeID( "warpValue" );
            desc72.putDouble( idwarpValue, 0.000000 );
            var idwarpPerspective = stringIDToTypeID( "warpPerspective" );
            desc72.putDouble( idwarpPerspective, 0.000000 );
            var idwarpPerspectiveOther = stringIDToTypeID( "warpPerspectiveOther" );
            desc72.putDouble( idwarpPerspectiveOther, 0.000000 );
            var idwarpRotate = stringIDToTypeID( "warpRotate" );
            var idOrnt = charIDToTypeID( "Ornt" );
            var idHrzn = charIDToTypeID( "Hrzn" );
            desc72.putEnumerated( idwarpRotate, idOrnt, idHrzn );
        var idwarp = stringIDToTypeID( "warp" );
        desc71.putObject( idwarp, idwarp, desc72 );
        var idtextGridding = stringIDToTypeID( "textGridding" );
        var idtextGridding = stringIDToTypeID( "textGridding" );
        var idNone = charIDToTypeID( "None" );
        desc71.putEnumerated( idtextGridding, idtextGridding, idNone );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idOrnt = charIDToTypeID( "Ornt" );
        var idHrzn = charIDToTypeID( "Hrzn" );
        desc71.putEnumerated( idOrnt, idOrnt, idHrzn );
        var idAntA = charIDToTypeID( "AntA" );
        var idAnnt = charIDToTypeID( "Annt" );
        var idantiAliasSharp = stringIDToTypeID( "antiAliasSharp" );
        desc71.putEnumerated( idAntA, idAnnt, idantiAliasSharp );
        var idbounds = stringIDToTypeID( "bounds" );
            var desc73 = new ActionDescriptor();
            var idLeft = charIDToTypeID( "Left" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc73.putUnitDouble( idLeft, idPnt, 0.000000 );
            var idTop = charIDToTypeID( "Top " );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc73.putUnitDouble( idTop, idPnt, -52.739868 );
            var idRght = charIDToTypeID( "Rght" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc73.putUnitDouble( idRght, idPnt, 108.017578 );
            var idBtom = charIDToTypeID( "Btom" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc73.putUnitDouble( idBtom, idPnt, 25.253906 );
        var idbounds = stringIDToTypeID( "bounds" );
        desc71.putObject( idbounds, idbounds, desc73 );
        var idboundingBox = stringIDToTypeID( "boundingBox" );
            var desc74 = new ActionDescriptor();
            var idLeft = charIDToTypeID( "Left" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc74.putUnitDouble( idLeft, idPnt, 2.640000 );
            var idTop = charIDToTypeID( "Top " );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc74.putUnitDouble( idTop, idPnt, -42.960000 );
            var idRght = charIDToTypeID( "Rght" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc74.putUnitDouble( idRght, idPnt, 104.651719 );
            var idBtom = charIDToTypeID( "Btom" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc74.putUnitDouble( idBtom, idPnt, 12.720000 );
        var idboundingBox = stringIDToTypeID( "boundingBox" );
        desc71.putObject( idboundingBox, idboundingBox, desc74 );
        var idtextShape = stringIDToTypeID( "textShape" );
            var list13 = new ActionList();
                var desc75 = new ActionDescriptor();
                var idTEXT = charIDToTypeID( "TEXT" );
                var idTEXT = charIDToTypeID( "TEXT" );
                var idPnt = charIDToTypeID( "Pnt " );
                desc75.putEnumerated( idTEXT, idTEXT, idPnt );
                var idOrnt = charIDToTypeID( "Ornt" );
                var idOrnt = charIDToTypeID( "Ornt" );
                var idHrzn = charIDToTypeID( "Hrzn" );
                desc75.putEnumerated( idOrnt, idOrnt, idHrzn );
                var idTrnf = charIDToTypeID( "Trnf" );
                    var desc76 = new ActionDescriptor();
                    var idxx = stringIDToTypeID( "xx" );
                    desc76.putDouble( idxx, 1.000000 );
                    var idxy = stringIDToTypeID( "xy" );
                    desc76.putDouble( idxy, 0.000000 );
                    var idyx = stringIDToTypeID( "yx" );
                    desc76.putDouble( idyx, 0.000000 );
                    var idyy = stringIDToTypeID( "yy" );
                    desc76.putDouble( idyy, 1.000000 );
                    var idtx = stringIDToTypeID( "tx" );
                    desc76.putDouble( idtx, 0.000000 );
                    var idty = stringIDToTypeID( "ty" );
                    desc76.putDouble( idty, 0.000000 );
                var idTrnf = charIDToTypeID( "Trnf" );
                desc75.putObject( idTrnf, idTrnf, desc76 );
                var idrowCount = stringIDToTypeID( "rowCount" );
                desc75.putInteger( idrowCount, 1 );
                var idcolumnCount = stringIDToTypeID( "columnCount" );
                desc75.putInteger( idcolumnCount, 1 );
                var idrowMajorOrder = stringIDToTypeID( "rowMajorOrder" );
                desc75.putBoolean( idrowMajorOrder, true );
                var idrowGutter = stringIDToTypeID( "rowGutter" );
                var idPnt = charIDToTypeID( "#Pnt" );
                desc75.putUnitDouble( idrowGutter, idPnt, 0.000000 );
                var idcolumnGutter = stringIDToTypeID( "columnGutter" );
                var idPnt = charIDToTypeID( "#Pnt" );
                desc75.putUnitDouble( idcolumnGutter, idPnt, 0.000000 );
                var idSpcn = charIDToTypeID( "Spcn" );
                var idPnt = charIDToTypeID( "#Pnt" );
                desc75.putUnitDouble( idSpcn, idPnt, 0.000000 );
                var idframeBaselineAlignment = stringIDToTypeID( "frameBaselineAlignment" );
                var idframeBaselineAlignment = stringIDToTypeID( "frameBaselineAlignment" );
                var idalignByAscent = stringIDToTypeID( "alignByAscent" );
                desc75.putEnumerated( idframeBaselineAlignment, idframeBaselineAlignment, idalignByAscent );
                var idfirstBaselineMinimum = stringIDToTypeID( "firstBaselineMinimum" );
                var idPnt = charIDToTypeID( "#Pnt" );
                desc75.putUnitDouble( idfirstBaselineMinimum, idPnt, 0.000000 );
                var idbase = stringIDToTypeID( "base" );
                    var desc77 = new ActionDescriptor();
                    var idHrzn = charIDToTypeID( "Hrzn" );
                    desc77.putDouble( idHrzn, 0.000000 );
                    var idVrtc = charIDToTypeID( "Vrtc" );
                    desc77.putDouble( idVrtc, 0.000000 );
                var idPnt = charIDToTypeID( "Pnt " );
                desc75.putObject( idbase, idPnt, desc77 );
            var idtextShape = stringIDToTypeID( "textShape" );
            list13.putObject( idtextShape, desc75 );
        desc71.putList( idtextShape, list13 );
        var idTxtt = charIDToTypeID( "Txtt" );
            var list14 = new ActionList();
                var desc78 = new ActionDescriptor();
                var idFrom = charIDToTypeID( "From" );
                desc78.putInteger( idFrom, 0 );
                var idT = charIDToTypeID( "T   " );
                desc78.putInteger( idT, 4 );
                var idTxtS = charIDToTypeID( "TxtS" );
                    var desc79 = new ActionDescriptor();
                    var idstyleSheetHasParent = stringIDToTypeID( "styleSheetHasParent" );
                    desc79.putBoolean( idstyleSheetHasParent, true );
                    var idfontPostScriptName = stringIDToTypeID( "fontPostScriptName" );
                    desc79.putString( idfontPostScriptName, """Monaco""" );
                    var idFntN = charIDToTypeID( "FntN" );
                    desc79.putString( idFntN, """Monaco""" );
                    var idFntS = charIDToTypeID( "FntS" );
                    desc79.putString( idFntS, """Regular""" );
                    var idScrp = charIDToTypeID( "Scrp" );
                    desc79.putInteger( idScrp, 0 );
                    var idFntT = charIDToTypeID( "FntT" );
                    desc79.putInteger( idFntT, 1 );
                    var idSz = charIDToTypeID( "Sz  " );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( idSz, idPnt, pts );
                    var idimpliedFontSize = stringIDToTypeID( "impliedFontSize" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( idimpliedFontSize, idPnt, pts );
                    var idHrzS = charIDToTypeID( "HrzS" );
                    desc79.putDouble( idHrzS, 100.000000 );
                    var idVrtS = charIDToTypeID( "VrtS" );
                    desc79.putDouble( idVrtS, 100.000000 );
                    var idsyntheticBold = stringIDToTypeID( "syntheticBold" );
                    desc79.putBoolean( idsyntheticBold, false );
                    var idsyntheticItalic = stringIDToTypeID( "syntheticItalic" );
                    desc79.putBoolean( idsyntheticItalic, false );
                    var idautoLeading = stringIDToTypeID( "autoLeading" );
                    desc79.putBoolean( idautoLeading, true );
                    var idTrck = charIDToTypeID( "Trck" );
                    desc79.putInteger( idTrck, 0 );
                    var idBsln = charIDToTypeID( "Bsln" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( idBsln, idPnt, 0.000000 );
                    var idimpliedBaselineShift = stringIDToTypeID( "impliedBaselineShift" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( idimpliedBaselineShift, idPnt, 0.000000 );
                    var idAtKr = charIDToTypeID( "AtKr" );
                    var idAtKr = charIDToTypeID( "AtKr" );
                    var idmetricsKern = stringIDToTypeID( "metricsKern" );
                    desc79.putEnumerated( idAtKr, idAtKr, idmetricsKern );
                    var idfontCaps = stringIDToTypeID( "fontCaps" );
                    var idfontCaps = stringIDToTypeID( "fontCaps" );
                    var idNrml = charIDToTypeID( "Nrml" );
                    desc79.putEnumerated( idfontCaps, idfontCaps, idNrml );
                    var iddigitSet = stringIDToTypeID( "digitSet" );
                    var iddigitSet = stringIDToTypeID( "digitSet" );
                    var iddefaultDigits = stringIDToTypeID( "defaultDigits" );
                    desc79.putEnumerated( iddigitSet, iddigitSet, iddefaultDigits );
                    var idkashidas = stringIDToTypeID( "kashidas" );
                    var idkashidas = stringIDToTypeID( "kashidas" );
                    var idkashidaDefault = stringIDToTypeID( "kashidaDefault" );
                    desc79.putEnumerated( idkashidas, idkashidas, idkashidaDefault );
                    var iddiacXOffset = stringIDToTypeID( "diacXOffset" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( iddiacXOffset, idPnt, 0.000000 );
                    var iddiacYOffset = stringIDToTypeID( "diacYOffset" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( iddiacYOffset, idPnt, 0.000000 );
                    var idmarkYDistFromBaseline = stringIDToTypeID( "markYDistFromBaseline" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc79.putUnitDouble( idmarkYDistFromBaseline, idPnt, 24.000000 );
                    var idbaseline = stringIDToTypeID( "baseline" );
                    var idbaseline = stringIDToTypeID( "baseline" );
                    var idNrml = charIDToTypeID( "Nrml" );
                    desc79.putEnumerated( idbaseline, idbaseline, idNrml );
                    var idstrikethrough = stringIDToTypeID( "strikethrough" );
                    var idstrikethrough = stringIDToTypeID( "strikethrough" );
                    var idstrikethroughOff = stringIDToTypeID( "strikethroughOff" );
                    desc79.putEnumerated( idstrikethrough, idstrikethrough, idstrikethroughOff );
                    var idUndl = charIDToTypeID( "Undl" );
                    var idUndl = charIDToTypeID( "Undl" );
                    var idunderlineOff = stringIDToTypeID( "underlineOff" );
                    desc79.putEnumerated( idUndl, idUndl, idunderlineOff );
                    var idligature = stringIDToTypeID( "ligature" );
                    desc79.putBoolean( idligature, true );
                    var idaltligature = stringIDToTypeID( "altligature" );
                    desc79.putBoolean( idaltligature, false );
                    var idcontextualLigatures = stringIDToTypeID( "contextualLigatures" );
                    desc79.putBoolean( idcontextualLigatures, false );
                    var idfractions = stringIDToTypeID( "fractions" );
                    desc79.putBoolean( idfractions, false );
                    var idordinals = stringIDToTypeID( "ordinals" );
                    desc79.putBoolean( idordinals, false );
                    var idswash = stringIDToTypeID( "swash" );
                    desc79.putBoolean( idswash, false );
                    var idtitling = stringIDToTypeID( "titling" );
                    desc79.putBoolean( idtitling, false );
                    var idconnectionForms = stringIDToTypeID( "connectionForms" );
                    desc79.putBoolean( idconnectionForms, false );
                    var idstylisticAlternates = stringIDToTypeID( "stylisticAlternates" );
                    desc79.putBoolean( idstylisticAlternates, false );
                    var idornaments = stringIDToTypeID( "ornaments" );
                    desc79.putBoolean( idornaments, false );
                    var idjustificationAlternates = stringIDToTypeID( "justificationAlternates" );
                    desc79.putBoolean( idjustificationAlternates, false );
                    var idfigureStyle = stringIDToTypeID( "figureStyle" );
                    var idfigureStyle = stringIDToTypeID( "figureStyle" );
                    var idNrml = charIDToTypeID( "Nrml" );
                    desc79.putEnumerated( idfigureStyle, idfigureStyle, idNrml );
                    var idproportionalMetrics = stringIDToTypeID( "proportionalMetrics" );
                    desc79.putBoolean( idproportionalMetrics, false );
                    var idkana = stringIDToTypeID( "kana" );
                    desc79.putBoolean( idkana, false );
                    var iditalics = stringIDToTypeID( "italics" );
                    desc79.putBoolean( iditalics, false );
                    var idbaselineDirection = stringIDToTypeID( "baselineDirection" );
                    var idbaselineDirection = stringIDToTypeID( "baselineDirection" );
                    var idrotated = stringIDToTypeID( "rotated" );
                    desc79.putEnumerated( idbaselineDirection, idbaselineDirection, idrotated );
                    var idtextLanguage = stringIDToTypeID( "textLanguage" );
                    var idtextLanguage = stringIDToTypeID( "textLanguage" );
                    var idenglishLanguage = stringIDToTypeID( "englishLanguage" );
                    desc79.putEnumerated( idtextLanguage, idtextLanguage, idenglishLanguage );
                    var idjapaneseAlternate = stringIDToTypeID( "japaneseAlternate" );
                    var idjapaneseAlternate = stringIDToTypeID( "japaneseAlternate" );
                    var iddefaultForm = stringIDToTypeID( "defaultForm" );
                    desc79.putEnumerated( idjapaneseAlternate, idjapaneseAlternate, iddefaultForm );
                    var idmojiZume = stringIDToTypeID( "mojiZume" );
                    desc79.putDouble( idmojiZume, 0.000000 );
                    var idgridAlignment = stringIDToTypeID( "gridAlignment" );
                    var idgridAlignment = stringIDToTypeID( "gridAlignment" );
                    var idroman = stringIDToTypeID( "roman" );
                    desc79.putEnumerated( idgridAlignment, idgridAlignment, idroman );
                    var idnoBreak = stringIDToTypeID( "noBreak" );
                    desc79.putBoolean( idnoBreak, false );
                    var idClr = charIDToTypeID( "Clr " );
                        var desc80 = new ActionDescriptor();
                        var idRd = charIDToTypeID( "Rd  " );
                        desc80.putDouble( idRd, 122.625584 );
                        var idGrn = charIDToTypeID( "Grn " );
                        desc80.putDouble( idGrn, 122.625591 );
                        var idBl = charIDToTypeID( "Bl  " );
                        desc80.putDouble( idBl, 122.625591 );
                    var idRGBC = charIDToTypeID( "RGBC" );
                    desc79.putObject( idClr, idRGBC, desc80 );
                    var idstrokeColor = stringIDToTypeID( "strokeColor" );
                        var desc81 = new ActionDescriptor();
                        var idRd = charIDToTypeID( "Rd  " );
                        desc81.putDouble( idRd, 0.000000 );
                        var idGrn = charIDToTypeID( "Grn " );
                        desc81.putDouble( idGrn, 0.000000 );
                        var idBl = charIDToTypeID( "Bl  " );
                        desc81.putDouble( idBl, 0.000000 );
                    var idRGBC = charIDToTypeID( "RGBC" );
                    desc79.putObject( idstrokeColor, idRGBC, desc81 );
                    var idbaseParentStyle = stringIDToTypeID( "baseParentStyle" );
                        var desc82 = new ActionDescriptor();
                        var idfontPostScriptName = stringIDToTypeID( "fontPostScriptName" );
                        desc82.putString( idfontPostScriptName, """MyriadPro-Regular""" );
                        var idFntN = charIDToTypeID( "FntN" );
                        desc82.putString( idFntN, """Myriad Pro""" );
                        var idFntS = charIDToTypeID( "FntS" );
                        desc82.putString( idFntS, """Regular""" );
                        var idScrp = charIDToTypeID( "Scrp" );
                        desc82.putInteger( idScrp, 0 );
                        var idFntT = charIDToTypeID( "FntT" );
                        desc82.putInteger( idFntT, 0 );
                        var idSz = charIDToTypeID( "Sz  " );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idSz, idPnt, 12.000000 );
                        var idimpliedFontSize = stringIDToTypeID( "impliedFontSize" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idimpliedFontSize, idPnt, 12.000000 );
                        var idHrzS = charIDToTypeID( "HrzS" );
                        desc82.putDouble( idHrzS, 100.000000 );
                        var idVrtS = charIDToTypeID( "VrtS" );
                        desc82.putDouble( idVrtS, 100.000000 );
                        var idsyntheticBold = stringIDToTypeID( "syntheticBold" );
                        desc82.putBoolean( idsyntheticBold, false );
                        var idsyntheticItalic = stringIDToTypeID( "syntheticItalic" );
                        desc82.putBoolean( idsyntheticItalic, false );
                        var idautoLeading = stringIDToTypeID( "autoLeading" );
                        desc82.putBoolean( idautoLeading, true );
                        var idTrck = charIDToTypeID( "Trck" );
                        desc82.putInteger( idTrck, 0 );
                        var idBsln = charIDToTypeID( "Bsln" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idBsln, idPnt, 0.000000 );
                        var idimpliedBaselineShift = stringIDToTypeID( "impliedBaselineShift" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idimpliedBaselineShift, idPnt, 0.000000 );
                        var idcharacterRotation = stringIDToTypeID( "characterRotation" );
                        desc82.putDouble( idcharacterRotation, 0.000000 );
                        var idAtKr = charIDToTypeID( "AtKr" );
                        var idAtKr = charIDToTypeID( "AtKr" );
                        var idmetricsKern = stringIDToTypeID( "metricsKern" );
                        desc82.putEnumerated( idAtKr, idAtKr, idmetricsKern );
                        var idfontCaps = stringIDToTypeID( "fontCaps" );
                        var idfontCaps = stringIDToTypeID( "fontCaps" );
                        var idNrml = charIDToTypeID( "Nrml" );
                        desc82.putEnumerated( idfontCaps, idfontCaps, idNrml );
                        var iddigitSet = stringIDToTypeID( "digitSet" );
                        var iddigitSet = stringIDToTypeID( "digitSet" );
                        var iddefaultDigits = stringIDToTypeID( "defaultDigits" );
                        desc82.putEnumerated( iddigitSet, iddigitSet, iddefaultDigits );
                        var iddirOverride = stringIDToTypeID( "dirOverride" );
                        var iddirOverride = stringIDToTypeID( "dirOverride" );
                        var iddirOverrideDefault = stringIDToTypeID( "dirOverrideDefault" );
                        desc82.putEnumerated( iddirOverride, iddirOverride, iddirOverrideDefault );
                        var idkashidas = stringIDToTypeID( "kashidas" );
                        var idkashidas = stringIDToTypeID( "kashidas" );
                        var idkashidaDefault = stringIDToTypeID( "kashidaDefault" );
                        desc82.putEnumerated( idkashidas, idkashidas, idkashidaDefault );
                        var iddiacVPos = stringIDToTypeID( "diacVPos" );
                        var iddiacVPos = stringIDToTypeID( "diacVPos" );
                        var iddiacVPosOpenType = stringIDToTypeID( "diacVPosOpenType" );
                        desc82.putEnumerated( iddiacVPos, iddiacVPos, iddiacVPosOpenType );
                        var iddiacXOffset = stringIDToTypeID( "diacXOffset" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( iddiacXOffset, idPnt, 0.000000 );
                        var iddiacYOffset = stringIDToTypeID( "diacYOffset" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( iddiacYOffset, idPnt, 0.000000 );
                        var idmarkYDistFromBaseline = stringIDToTypeID( "markYDistFromBaseline" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idmarkYDistFromBaseline, idPnt, 100.000000 );
                        var idbaseline = stringIDToTypeID( "baseline" );
                        var idbaseline = stringIDToTypeID( "baseline" );
                        var idNrml = charIDToTypeID( "Nrml" );
                        desc82.putEnumerated( idbaseline, idbaseline, idNrml );
                        var idotbaseline = stringIDToTypeID( "otbaseline" );
                        var idotbaseline = stringIDToTypeID( "otbaseline" );
                        var idNrml = charIDToTypeID( "Nrml" );
                        desc82.putEnumerated( idotbaseline, idotbaseline, idNrml );
                        var idstrikethrough = stringIDToTypeID( "strikethrough" );
                        var idstrikethrough = stringIDToTypeID( "strikethrough" );
                        var idstrikethroughOff = stringIDToTypeID( "strikethroughOff" );
                        desc82.putEnumerated( idstrikethrough, idstrikethrough, idstrikethroughOff );
                        var idUndl = charIDToTypeID( "Undl" );
                        var idUndl = charIDToTypeID( "Undl" );
                        var idunderlineOff = stringIDToTypeID( "underlineOff" );
                        desc82.putEnumerated( idUndl, idUndl, idunderlineOff );
                        var idunderlineOffset = stringIDToTypeID( "underlineOffset" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idunderlineOffset, idPnt, 0.000000 );
                        var idligature = stringIDToTypeID( "ligature" );
                        desc82.putBoolean( idligature, true );
                        var idaltligature = stringIDToTypeID( "altligature" );
                        desc82.putBoolean( idaltligature, false );
                        var idcontextualLigatures = stringIDToTypeID( "contextualLigatures" );
                        desc82.putBoolean( idcontextualLigatures, false );
                        var idalternateLigatures = stringIDToTypeID( "alternateLigatures" );
                        desc82.putBoolean( idalternateLigatures, false );
                        var idoldStyle = stringIDToTypeID( "oldStyle" );
                        desc82.putBoolean( idoldStyle, false );
                        var idfractions = stringIDToTypeID( "fractions" );
                        desc82.putBoolean( idfractions, false );
                        var idordinals = stringIDToTypeID( "ordinals" );
                        desc82.putBoolean( idordinals, false );
                        var idswash = stringIDToTypeID( "swash" );
                        desc82.putBoolean( idswash, false );
                        var idtitling = stringIDToTypeID( "titling" );
                        desc82.putBoolean( idtitling, false );
                        var idconnectionForms = stringIDToTypeID( "connectionForms" );
                        desc82.putBoolean( idconnectionForms, false );
                        var idstylisticAlternates = stringIDToTypeID( "stylisticAlternates" );
                        desc82.putBoolean( idstylisticAlternates, false );
                        var idornaments = stringIDToTypeID( "ornaments" );
                        desc82.putBoolean( idornaments, false );
                        var idjustificationAlternates = stringIDToTypeID( "justificationAlternates" );
                        desc82.putBoolean( idjustificationAlternates, false );
                        var idfigureStyle = stringIDToTypeID( "figureStyle" );
                        var idfigureStyle = stringIDToTypeID( "figureStyle" );
                        var idNrml = charIDToTypeID( "Nrml" );
                        desc82.putEnumerated( idfigureStyle, idfigureStyle, idNrml );
                        var idproportionalMetrics = stringIDToTypeID( "proportionalMetrics" );
                        desc82.putBoolean( idproportionalMetrics, false );
                        var idkana = stringIDToTypeID( "kana" );
                        desc82.putBoolean( idkana, false );
                        var iditalics = stringIDToTypeID( "italics" );
                        desc82.putBoolean( iditalics, false );
                        var idruby = stringIDToTypeID( "ruby" );
                        desc82.putBoolean( idruby, false );
                        var idbaselineDirection = stringIDToTypeID( "baselineDirection" );
                        var idbaselineDirection = stringIDToTypeID( "baselineDirection" );
                        var idrotated = stringIDToTypeID( "rotated" );
                        desc82.putEnumerated( idbaselineDirection, idbaselineDirection, idrotated );
                        var idtextLanguage = stringIDToTypeID( "textLanguage" );
                        var idtextLanguage = stringIDToTypeID( "textLanguage" );
                        var idenglishLanguage = stringIDToTypeID( "englishLanguage" );
                        desc82.putEnumerated( idtextLanguage, idtextLanguage, idenglishLanguage );
                        var idjapaneseAlternate = stringIDToTypeID( "japaneseAlternate" );
                        var idjapaneseAlternate = stringIDToTypeID( "japaneseAlternate" );
                        var iddefaultForm = stringIDToTypeID( "defaultForm" );
                        desc82.putEnumerated( idjapaneseAlternate, idjapaneseAlternate, iddefaultForm );
                        var idmojiZume = stringIDToTypeID( "mojiZume" );
                        desc82.putDouble( idmojiZume, 0.000000 );
                        var idgridAlignment = stringIDToTypeID( "gridAlignment" );
                        var idgridAlignment = stringIDToTypeID( "gridAlignment" );
                        var idroman = stringIDToTypeID( "roman" );
                        desc82.putEnumerated( idgridAlignment, idgridAlignment, idroman );
                        var idenableWariChu = stringIDToTypeID( "enableWariChu" );
                        desc82.putBoolean( idenableWariChu, false );
                        var idwariChuCount = stringIDToTypeID( "wariChuCount" );
                        desc82.putInteger( idwariChuCount, 2 );
                        var idwariChuLineGap = stringIDToTypeID( "wariChuLineGap" );
                        desc82.putInteger( idwariChuLineGap, 0 );
                        var idwariChuScale = stringIDToTypeID( "wariChuScale" );
                        desc82.putDouble( idwariChuScale, 0.500000 );
                        var idwariChuWidow = stringIDToTypeID( "wariChuWidow" );
                        desc82.putInteger( idwariChuWidow, 2 );
                        var idwariChuOrphan = stringIDToTypeID( "wariChuOrphan" );
                        desc82.putInteger( idwariChuOrphan, 2 );
                        var idwariChuJustification = stringIDToTypeID( "wariChuJustification" );
                        var idwariChuJustification = stringIDToTypeID( "wariChuJustification" );
                        var idwariChuAutoJustify = stringIDToTypeID( "wariChuAutoJustify" );
                        desc82.putEnumerated( idwariChuJustification, idwariChuJustification, idwariChuAutoJustify );
                        var idtcyUpDown = stringIDToTypeID( "tcyUpDown" );
                        desc82.putInteger( idtcyUpDown, 0 );
                        var idtcyLeftRight = stringIDToTypeID( "tcyLeftRight" );
                        desc82.putInteger( idtcyLeftRight, 0 );
                        var idleftAki = stringIDToTypeID( "leftAki" );
                        desc82.putDouble( idleftAki, -1.000000 );
                        var idrightAki = stringIDToTypeID( "rightAki" );
                        desc82.putDouble( idrightAki, -1.000000 );
                        var idjiDori = stringIDToTypeID( "jiDori" );
                        desc82.putInteger( idjiDori, 0 );
                        var idnoBreak = stringIDToTypeID( "noBreak" );
                        desc82.putBoolean( idnoBreak, false );
                        var idClr = charIDToTypeID( "Clr " );
                            var desc83 = new ActionDescriptor();
                            var idRd = charIDToTypeID( "Rd  " );
                            desc83.putDouble( idRd, 0.000000 );
                            var idGrn = charIDToTypeID( "Grn " );
                            desc83.putDouble( idGrn, 0.000000 );
                            var idBl = charIDToTypeID( "Bl  " );
                            desc83.putDouble( idBl, 0.000000 );
                        var idRGBC = charIDToTypeID( "RGBC" );
                        desc82.putObject( idClr, idRGBC, desc83 );
                        var idstrokeColor = stringIDToTypeID( "strokeColor" );
                            var desc84 = new ActionDescriptor();
                            var idRd = charIDToTypeID( "Rd  " );
                            desc84.putDouble( idRd, 0.000000 );
                            var idGrn = charIDToTypeID( "Grn " );
                            desc84.putDouble( idGrn, 0.000000 );
                            var idBl = charIDToTypeID( "Bl  " );
                            desc84.putDouble( idBl, 0.000000 );
                        var idRGBC = charIDToTypeID( "RGBC" );
                        desc82.putObject( idstrokeColor, idRGBC, desc84 );
                        var idFl = charIDToTypeID( "Fl  " );
                        desc82.putBoolean( idFl, true );
                        var idStrk = charIDToTypeID( "Strk" );
                        desc82.putBoolean( idStrk, false );
                        var idfillFirst = stringIDToTypeID( "fillFirst" );
                        desc82.putBoolean( idfillFirst, true );
                        var idfillOverPrint = stringIDToTypeID( "fillOverPrint" );
                        desc82.putBoolean( idfillOverPrint, false );
                        var idstrokeOverPrint = stringIDToTypeID( "strokeOverPrint" );
                        desc82.putBoolean( idstrokeOverPrint, false );
                        var idlineCap = stringIDToTypeID( "lineCap" );
                        var idlineCap = stringIDToTypeID( "lineCap" );
                        var idbuttCap = stringIDToTypeID( "buttCap" );
                        desc82.putEnumerated( idlineCap, idlineCap, idbuttCap );
                        var idlineJoin = stringIDToTypeID( "lineJoin" );
                        var idlineJoin = stringIDToTypeID( "lineJoin" );
                        var idmiterJoin = stringIDToTypeID( "miterJoin" );
                        desc82.putEnumerated( idlineJoin, idlineJoin, idmiterJoin );
                        var idlineWidth = stringIDToTypeID( "lineWidth" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idlineWidth, idPnt, 1.000000 );
                        var idmiterLimit = stringIDToTypeID( "miterLimit" );
                        var idPnt = charIDToTypeID( "#Pnt" );
                        desc82.putUnitDouble( idmiterLimit, idPnt, 4.000000 );
                        var idlineDashoffset = stringIDToTypeID( "lineDashoffset" );
                        desc82.putDouble( idlineDashoffset, 0.000000 );
                    var idTxtS = charIDToTypeID( "TxtS" );
                    desc79.putObject( idbaseParentStyle, idTxtS, desc82 );
                var idTxtS = charIDToTypeID( "TxtS" );
                desc78.putObject( idTxtS, idTxtS, desc79 );
            var idTxtt = charIDToTypeID( "Txtt" );
            list14.putObject( idTxtt, desc78 );
        desc71.putList( idTxtt, list14 );
        var idparagraphStyleRange = stringIDToTypeID( "paragraphStyleRange" );
            var list15 = new ActionList();
                var desc85 = new ActionDescriptor();
                var idFrom = charIDToTypeID( "From" );
                desc85.putInteger( idFrom, 0 );
                var idT = charIDToTypeID( "T   " );
                desc85.putInteger( idT, 4 );
                var idparagraphStyle = stringIDToTypeID( "paragraphStyle" );
                    var desc86 = new ActionDescriptor();
                    var idstyleSheetHasParent = stringIDToTypeID( "styleSheetHasParent" );
                    desc86.putBoolean( idstyleSheetHasParent, true );
                    var idAlgn = charIDToTypeID( "Algn" );
                    var idAlg = charIDToTypeID( "Alg " );
                    var idLeft = charIDToTypeID( "Left" );
                    desc86.putEnumerated( idAlgn, idAlg, idLeft );
                    var idfirstLineIndent = stringIDToTypeID( "firstLineIndent" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idfirstLineIndent, idPnt, 0.000000 );
                    var idimpliedFirstLineIndent = stringIDToTypeID( "impliedFirstLineIndent" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idimpliedFirstLineIndent, idPnt, 0.000000 );
                    var idstartIndent = stringIDToTypeID( "startIndent" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idstartIndent, idPnt, 0.000000 );
                    var idimpliedStartIndent = stringIDToTypeID( "impliedStartIndent" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idimpliedStartIndent, idPnt, 0.000000 );
                    var idendIndent = stringIDToTypeID( "endIndent" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idendIndent, idPnt, 0.000000 );
                    var idimpliedEndIndent = stringIDToTypeID( "impliedEndIndent" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idimpliedEndIndent, idPnt, 0.000000 );
                    var idspaceBefore = stringIDToTypeID( "spaceBefore" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idspaceBefore, idPnt, 0.000000 );
                    var idimpliedSpaceBefore = stringIDToTypeID( "impliedSpaceBefore" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idimpliedSpaceBefore, idPnt, 0.000000 );
                    var idspaceAfter = stringIDToTypeID( "spaceAfter" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idspaceAfter, idPnt, 0.000000 );
                    var idimpliedSpaceAfter = stringIDToTypeID( "impliedSpaceAfter" );
                    var idPnt = charIDToTypeID( "#Pnt" );
                    desc86.putUnitDouble( idimpliedSpaceAfter, idPnt, 0.000000 );
                    var idautoLeadingPercentage = stringIDToTypeID( "autoLeadingPercentage" );
                    desc86.putDouble( idautoLeadingPercentage, 1.200000 );
                    var idleadingType = stringIDToTypeID( "leadingType" );
                    var idleadingType = stringIDToTypeID( "leadingType" );
                    var idleadingBelow = stringIDToTypeID( "leadingBelow" );
                    desc86.putEnumerated( idleadingType, idleadingType, idleadingBelow );
                    var iddirectionType = stringIDToTypeID( "directionType" );
                    var iddirectionType = stringIDToTypeID( "directionType" );
                    var iddirLeftToRight = stringIDToTypeID( "dirLeftToRight" );
                    desc86.putEnumerated( iddirectionType, iddirectionType, iddirLeftToRight );
                    var idkashidaWidthType = stringIDToTypeID( "kashidaWidthType" );
                    var idkashidaWidthType = stringIDToTypeID( "kashidaWidthType" );
                    var idkashidaWidthMedium = stringIDToTypeID( "kashidaWidthMedium" );
                    desc86.putEnumerated( idkashidaWidthType, idkashidaWidthType, idkashidaWidthMedium );
                    var idhyphenate = stringIDToTypeID( "hyphenate" );
                    desc86.putBoolean( idhyphenate, true );
                    var idhyphenateWordSize = stringIDToTypeID( "hyphenateWordSize" );
                    desc86.putInteger( idhyphenateWordSize, 6 );
                    var idhyphenatePreLength = stringIDToTypeID( "hyphenatePreLength" );
                    desc86.putInteger( idhyphenatePreLength, 2 );
                    var idhyphenatePostLength = stringIDToTypeID( "hyphenatePostLength" );
                    desc86.putInteger( idhyphenatePostLength, 2 );
                    var idhyphenateLimit = stringIDToTypeID( "hyphenateLimit" );
                    desc86.putInteger( idhyphenateLimit, 0 );
                    var idhyphenationZone = stringIDToTypeID( "hyphenationZone" );
                    desc86.putDouble( idhyphenationZone, 36.000000 );
                    var idhyphenateCapitalized = stringIDToTypeID( "hyphenateCapitalized" );
                    desc86.putBoolean( idhyphenateCapitalized, true );
                    var idjustificationWordMinimum = stringIDToTypeID( "justificationWordMinimum" );
                    desc86.putDouble( idjustificationWordMinimum, 0.800000 );
                    var idjustificationWordDesired = stringIDToTypeID( "justificationWordDesired" );
                    desc86.putDouble( idjustificationWordDesired, 1.000000 );
                    var idjustificationWordMaximum = stringIDToTypeID( "justificationWordMaximum" );
                    desc86.putDouble( idjustificationWordMaximum, 1.330000 );
                    var idjustificationLetterMinimum = stringIDToTypeID( "justificationLetterMinimum" );
                    desc86.putDouble( idjustificationLetterMinimum, 0.000000 );
                    var idjustificationLetterDesired = stringIDToTypeID( "justificationLetterDesired" );
                    desc86.putDouble( idjustificationLetterDesired, 0.000000 );
                    var idjustificationLetterMaximum = stringIDToTypeID( "justificationLetterMaximum" );
                    desc86.putDouble( idjustificationLetterMaximum, 0.000000 );
                    var idjustificationGlyphMinimum = stringIDToTypeID( "justificationGlyphMinimum" );
                    desc86.putDouble( idjustificationGlyphMinimum, 1.000000 );
                    var idjustificationGlyphDesired = stringIDToTypeID( "justificationGlyphDesired" );
                    desc86.putDouble( idjustificationGlyphDesired, 1.000000 );
                    var idjustificationGlyphMaximum = stringIDToTypeID( "justificationGlyphMaximum" );
                    desc86.putDouble( idjustificationGlyphMaximum, 1.000000 );
                    var idhangingRoman = stringIDToTypeID( "hangingRoman" );
                    desc86.putBoolean( idhangingRoman, false );
                    var idburasagari = stringIDToTypeID( "burasagari" );
                    var idburasagari = stringIDToTypeID( "burasagari" );
                    var idburasagariNone = stringIDToTypeID( "burasagariNone" );
                    desc86.putEnumerated( idburasagari, idburasagari, idburasagariNone );
                    var idpreferredKinsokuOrder = stringIDToTypeID( "preferredKinsokuOrder" );
                    var idpreferredKinsokuOrder = stringIDToTypeID( "preferredKinsokuOrder" );
                    var idpushIn = stringIDToTypeID( "pushIn" );
                    desc86.putEnumerated( idpreferredKinsokuOrder, idpreferredKinsokuOrder, idpushIn );
                    var idtextEveryLineComposer = stringIDToTypeID( "textEveryLineComposer" );
                    desc86.putBoolean( idtextEveryLineComposer, false );
                    var idtextComposerEngine = stringIDToTypeID( "textComposerEngine" );
                    var idtextComposerEngine = stringIDToTypeID( "textComposerEngine" );
                    var idtextLatinCJKComposer = stringIDToTypeID( "textLatinCJKComposer" );
                    desc86.putEnumerated( idtextComposerEngine, idtextComposerEngine, idtextLatinCJKComposer );
                var idparagraphStyle = stringIDToTypeID( "paragraphStyle" );
                desc85.putObject( idparagraphStyle, idparagraphStyle, desc86 );
            var idparagraphStyleRange = stringIDToTypeID( "paragraphStyleRange" );
            list15.putObject( idparagraphStyleRange, desc85 );
        desc71.putList( idparagraphStyleRange, list15 );
        var idkerningRange = stringIDToTypeID( "kerningRange" );
            var list16 = new ActionList();
        desc71.putList( idkerningRange, list16 );
    var idTxLr = charIDToTypeID( "TxLr" );
    desc70.putObject( idT, idTxLr, desc71 );
executeAction( idsetd, desc70, DialogModes.NO );
};

// Sample usage code

var doc = app.documents.add(5, 7, 300);
var layer = doc.artLayers.add(); 
layer.kind = LayerKind.TEXT; 
layer.name = "Test"; 
var titem = layer.textItem;
titem.size = new UnitValue("50", "pt");

if (titem.size.as("pt") != 50) {
  PSCCFontSizeFix.setFontSize(layer, 50);
}

titem.contents = "This text should be 50pt"; 
titem.font = "Monaco";
alert(titem.size);

Votes

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
Community Beginner ,
Oct 09, 2014 Oct 09, 2014

Copy link to clipboard

Copied

Thanks, indeed this code yields text that is 50pt (actually, not quite)...

Screen Shot 2014-10-09 at 10.44.06 AM.png

But I can't get it to integrate with an existing script. When the .setFontSize() method is called, nothing else happens. The method itself also has no result. In fact, replacing that line with "exit;" has the same effect.

There is lots of other stuff going on in the script, but this is the first operation performed on this specific text layer as you specified.

Any ideas? Or do we just wait for Adobe to fix it?

Votes

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
Advisor ,
Oct 09, 2014 Oct 09, 2014

Copy link to clipboard

Copied

I can't log in to the PS/JS forums website. When I can, I'll provide a

response.

Votes

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
Advisor ,
Oct 10, 2014 Oct 10, 2014

Copy link to clipboard

Copied

Cross-posted from ps-scripts.com:

2014 TextItem.size bug

Postby xbytor » Wed Oct 08, 2014 6:06 pm

Text is contained in a TextItem object. One of it's it's attributes is 'size' for the font size.

You can set it like this:
  textItem.size = UnitValue(50, "px");
or
  textItem.size = UnitValue(15, "pt");

The problem in the current rev is that regardless of what you set the font size to, it will always stay 12 px. So, if your rez is 72 ppi, the font size is 12 pts. If your rez is 300 ppi, your font size will be 2.83 pts.

My fix was to use low-level ActionManager code from the ScriptingListener plugin. The one problem is that setting the size will bash the font, contents, and several other attributes so you need to set the size immediately after creating the layer.

My fix has been added to xtools and can be found here:
This code is cleaner than raw ScriptListener plugin output.

Votes

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
Explorer ,
Oct 10, 2014 Oct 10, 2014

Copy link to clipboard

Copied

Hi, this also seems to work, at least in CC 2014. I haven't tested it fully, but it's shorter and doesn't seem to affect content or other text properties. That being said, I still hope Adobe gets a fix out fast for textItem.size

var changeTextSize = function(newSize){
    var idsetd = charIDToTypeID( "setd" );
        var desc23 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref6 = new ActionReference();
            var idPrpr = charIDToTypeID( "Prpr" );
            var idTxtS = charIDToTypeID( "TxtS" );
            ref6.putProperty( idPrpr, idTxtS );
            var idTxLr = charIDToTypeID( "TxLr" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idTrgt = charIDToTypeID( "Trgt" );
            ref6.putEnumerated( idTxLr, idOrdn, idTrgt );
        desc23.putReference( idnull, ref6 );
        var idT = charIDToTypeID( "T   " );
            var desc24 = new ActionDescriptor();
            var idtextOverrideFeatureName = stringIDToTypeID( "textOverrideFeatureName" );
            desc24.putInteger( idtextOverrideFeatureName, 808465458 );
            var idtypeStyleOperationType = stringIDToTypeID( "typeStyleOperationType" );
            desc24.putInteger( idtypeStyleOperationType, 3 );
            var idSz = charIDToTypeID( "Sz  " );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc24.putUnitDouble( idSz, idPxl, newSize );
        var idTxtS = charIDToTypeID( "TxtS" );
        desc23.putObject( idT, idTxtS, desc24 );
    executeAction( idsetd, desc23, DialogModes.NO );
}

Votes

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
Advisor ,
Oct 10, 2014 Oct 10, 2014

Copy link to clipboard

Copied

I recognize your superior solution and will use it instead of mine. Thanks.

BTW, magic numbers like '808465458' give me the willies

Votes

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
Explorer ,
Oct 11, 2014 Oct 11, 2014

Copy link to clipboard

Copied

Yep, agree on the willies But then again, most AM code does that to me.

Btw, thanks for all your contributions to the scripting community. Much appreciated!

Votes

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
Guest
Oct 11, 2014 Oct 11, 2014

Copy link to clipboard

Copied

It might be a coincidence, or some kind of private joke, but this magic number could be related to the meaning of life, since it is equal to:

charIDToTypeID ("0042")

Votes

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 ,
Oct 09, 2014 Oct 09, 2014

Copy link to clipboard

Copied

Not exactly your question since I've never tried to set it, but reading the text size is a known challenge.. The thing is that text_item.size does not include the transforms either in the object or in the document. So you have to check if there are transforms and calculate result. I have the following code for doing that

getTextSize: function (text_item) {

  return Math.round(text_item.size*getTextScaleHorizontal()) // .size is a unit value and we want to round it first to a regular number 

}

 

getTextScaleHorizontal: function () {  

  var ref = new ActionReference() 

  ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ) 

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

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

  var transform = desc.getObjectValue(stringIDToTypeID('transform')) 

  var mFactor = transform.getUnitDoubleValue (stringIDToTypeID('yy')) 

  return mFactor 

  }   

  return 1 

}

Votes

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
Oct 10, 2014 Oct 10, 2014

Copy link to clipboard

Copied

We are working on a fix for this issue.Use Action Manager code to set the entire text descriptor as shown above in the meantime.

Votes

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 Employee ,
Dec 10, 2014 Dec 10, 2014

Copy link to clipboard

Copied

This should be fixed in the 2014.2.2 update released tonight. Choose Help>Updates... to install.

Votes

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
Community Expert ,
Dec 11, 2014 Dec 11, 2014

Copy link to clipboard

Copied

Yes version 15.2.2 seems to have fixed this and background eraser problem that's been bugging me.   I wish the Adobe would reconsider their decision to implement the ESC key the wrong way for only the text tool and do the correct way. Esc should cancel text tool current use like it does other tools.  Why in the world does Adobe think doing it wrong is better then doing it right??????

JJMack

Votes

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
Community Beginner ,
Dec 11, 2014 Dec 11, 2014

Copy link to clipboard

Copied

LATEST

Awesome! I tried to change this to the correct answer, but it won't let me for some reason.

Votes

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