mac os x and fauxItalic

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

pivanov

mac os x and fauxItalic

Post by pivanov »

Hi guys,
I have problem with my script :

I try it with Mac os x and Adobe Photoshop CS5, CS6

Code: Select all...
var fontStyle = currentLayer.textItem.fauxItalic;
...

and I receive error:

Error 8500: The requested property does not exist.

Do you have a idea?

Thanks in advance.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

mac os x and fauxItalic

Post by Mike Hale »

You did not post all of your code. The only thing I can think of for it not working is currentLayer is not a text layer and it's textItem not existing that is causing the error.
pivanov

mac os x and fauxItalic

Post by pivanov »

Here is part of my code:

Code: Select allfunction ExportText(el, outputFile, path) {
  // Get the layers
  var layers = el.layers;

  for (var i = 0, count = layers.length; i < count; i++) {
    // curentLayer
    var currentLayer = layers;
    doc.activeLayer = currentLayer;


    // currentLayer is a LayerSet
    if (currentLayer.typename == "LayerSet") {
      ExportText(currentLayer, outputFile, path + currentLayer.name + '/');
    } else {
      // is Text layer visible
      if ( (currentLayer.visible) && (currentLayer.kind == LayerKind.TEXT) && currentLayer.textItem.contents)
      {
        outputFile.writeln('\n');
        outputFile.writeln(separator);

        // outputFile.writeln('Group: ' + path);
        // outputFile.writeln('Layer Name: ' + currentLayer.name);
        outputFile.writeln('Layer Content: ' + currentLayer.textItem.contents);
        outputFile.writeln(separator);


        try {
          var color = currentLayer.textItem.color.rgb.hexValue;
        } catch(e) {
          var  color = new SolidColor;
          color.rgb.red = 0;
          color.rgb.green = 0;
          color.rgb.blue = 0;
        }

        var fontSize = parseInt(currentLayer.textItem.size) / 10; //from px/pt to rem
        var fontFamily = currentLayer.textItem.font;
        var fontWeight = app.fonts.getByName(fontFamily).style.toLowerCase();
        var fontStyle = currentLayer.textItem.fauxItalic;
        var textTransform = currentLayer.textItem.capitalization;
        var letterSpacing = currentLayer.textItem.tracking;

        var opacity = currentLayer.opacity;
        var fillOpacity = currentLayer.fillOpacity;

        try {
        var lineHeight = parseInt(currentLayer.textItem.leading) / 10; //from px/pt to rem
        }
        catch (e) {
          var lineHeight = "auto";
        };

        //color
        outputFile.writeln('color: #' + color + semiColon);

        //fontSize
        outputFile.writeln('font-size: '+ fontSize + 'rem' + semiColon);

        //fontFamily
        outputFile.writeln('font-family: ' + fontFamily + semiColon);

        //fontWeight
        if (fontWeight && fontWeightValue[fontWeight] != '400') {
          outputFile.writeln('font-weight: ' + fontWeightValue[fontWeight] + semiColon);
        }

        //fontStyle
        if (fontStyle) {
          outputFile.writeln('font-style: italic' + semiColon);
        }

        //textTransform
        if (textTransform && textTransform != "TextCase.NORMAL") {
          outputFile.writeln('text-transform: uppercase' + semiColon);
        }

        //letterSpacing
        if (letterSpacing) {
          outputFile.writeln('letter-spacing: ' + letterSpacing);
        }

        //lineHeight
        if (lineHeight && lineHeight != 'auto') {
          outputFile.writeln('line-height: ' + lineHeight + 'rem' + semiColon);
        }

        //empty line
        outputFile.writeln('');

        if ( opacity != '100' || fillOpacity != '100') {
          outputFile.writeln('* Important: This text have ' + '"Opacity: ' + Math.round(opacity) + '" and "' + 'Fill: ' + fillOpacity + '"');
        }

      }
    }
  }
}