How can we optimize this script in order to run faster on Photoshop? Here is the script…
- User
How can we optimize this script in order to run faster on Photoshop? Here is the script : // Define all the glyphs as a string var glyphs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_+=[]{}|;:'",.<>?/";
// Common symbols glyphs += "-_+=[]{}|;:'",.<>?/";
// Create the Photoshop document var doc = app.documents.add(1024, 1024, 72, "Extended Latin Glyphs", NewDocumentMode.RGB, DocumentFill.BACKGROUNDCOLOR);
// Font settings var fontName = "Arial"; var fontSize = 500; // You can adjust this size as needed var textColor = new SolidColor(); textColor.rgb.hexValue = 'FFFFFF'; // White color
// Create an array to store text layers var textLayers = [];
for (var i = 0; i < glyphs.length; i++) { var glyph = glyphs.charAt(i);
// Determine the name based on the type of character var glyphName; if (/[A-Z]/.test(glyph)) { glyphName = "Uppercase " + glyph; } else if (/[a-z]/.test(glyph)) { glyphName = "Lowercase " + glyph; } else if (/[0-9]/.test(glyph)) { glyphName = "Number " + glyph; } else { // Special characters switch (glyph) { case '!': glyphName = "Exclamation Mark"; break; case '@': glyphName = "At Symbol"; break; case '#': glyphName = "Hash/Pound Sign"; break; case '$': glyphName = "Dollar Sign"; break; case '%': glyphName = "Percent Sign"; break; case '^': glyphName = "Caret"; break; case '&': glyphName = "Ampersand"; break; case '*': glyphName = "Asterisk"; break; case '(': glyphName = "Left Parenthesis"; break; case ')': glyphName = "Right Parenthesis"; break; case '-': glyphName = "Hyphen/Minus"; break; case '_': glyphName = "Underscore"; break; case '+': glyphName = "Plus Sign"; break; case '=': glyphName = "Equals Sign"; break; case '[': glyphName = "Left Square Bracket"; break; case ']': glyphName = "Right Square Bracket"; break; case '{': glyphName = "Left Curly Brace"; break; case '}': glyphName = "Right Curly Brace"; break; case '|': glyphName = "Vertical Bar"; break; case ';': glyphName = "Semicolon"; break; case ':': glyphName = "Colon"; break; case "'": glyphName = "Single Quote"; break; case '"': glyphName = "Double Quote"; break; case ',': glyphName = "Comma"; break; case '.': glyphName = "Period"; break; case '<': glyphName = "Less Than Sign"; break; case '>': glyphName = "Greater Than Sign"; break; case '?': glyphName = "Question Mark"; break; case '/': glyphName = "Forward Slash"; break; default: glyphName = glyph; // Use the original character for unknown symbols } } // Create a text layer for each glyph var textLayer = doc.artLayers.add(); textLayer.kind = LayerKind.TEXT; textLayer.textItem.font = fontName; textLayer.textItem.size = fontSize; textLayer.textItem.color = textColor; textLayer.textItem.contents = glyphName; // Center the text in the document textLayer.textItem.position = [doc.width / 2, doc.height / 2]; textLayer.textItem.justification = Justification.CENTER; textLayers.push(textLayer); - Assistant