This Illustrator script streamlines the process of generating individual artboards for each glyph from a defined character set. Each artboard is automatically assigned a descriptive name that corresponds to the glyph it represents (e.g., “Uppercase_A” for A, “Lowercase_a” for a, “Number_0” for 0, etc.). The script creates a new document, sets a standardized artboard size, and uses a pre-defined font (such as Arial) to place the glyph in the center of its corresponding artboard, automatically adjusting the font size to ensure the glyph fits comfortably within the frame. Once all glyphs are processed, the script rearranges the artboards into a grid for easier viewing in Illustrator.
JavaScript
// Illustrator Script: Create Glyph Artboards with Descriptive Names
// This script creates individual artboards for each glyph in the given character set with descriptive names
// Character set and corresponding names
var charSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklmnopqrstuvwxyz" +
"1234567890" +
". , ; : \"„\" ' ' ‚ ... ‹ › » « * [ ] ( ) { } / – -_<>?!$@&+?^#";
function getGlyphName(char) {
var glyphNames = {
'A': 'Uppercase_A', 'B': 'Uppercase_B', 'C': 'Uppercase_C', 'D': 'Uppercase_D', 'E': 'Uppercase_E',
'F': 'Uppercase_F', 'G': 'Uppercase_G', 'H': 'Uppercase_H', 'I': 'Uppercase_I', 'J': 'Uppercase_J',
'K': 'Uppercase_K', 'L': 'Uppercase_L', 'M': 'Uppercase_M', 'N': 'Uppercase_N', 'O': 'Uppercase_O',
'P': 'Uppercase_P', 'Q': 'Uppercase_Q', 'R': 'Uppercase_R', 'S': 'Uppercase_S', 'T': 'Uppercase_T',
'U': 'Uppercase_U', 'V': 'Uppercase_V', 'W': 'Uppercase_W', 'X': 'Uppercase_X', 'Y': 'Uppercase_Y',
'Z': 'Uppercase_Z',
'a': 'Lowercase_a', 'b': 'Lowercase_b', 'c': 'Lowercase_c', 'd': 'Lowercase_d', 'e': 'Lowercase_e',
'f': 'Lowercase_f', 'g': 'Lowercase_g', 'h': 'Lowercase_h', 'i': 'Lowercase_i', 'j': 'Lowercase_j',
'k': 'Lowercase_k', 'l': 'Lowercase_l', 'm': 'Lowercase_m', 'n': 'Lowercase_n', 'o': 'Lowercase_o',
'p': 'Lowercase_p', 'q': 'Lowercase_q', 'r': 'Lowercase_r', 's': 'Lowercase_s', 't': 'Lowercase_t',
'u': 'Lowercase_u', 'v': 'Lowercase_v', 'w': 'Lowercase_w', 'x': 'Lowercase_x', 'y': 'Lowercase_y',
'z': 'Lowercase_z',
'0': 'Number_0', '1': 'Number_1', '2': 'Number_2', '3': 'Number_3', '4': 'Number_4',
'5': 'Number_5', '6': 'Number_6', '7': 'Number_7', '8': 'Number_8', '9': 'Number_9',
'.': 'Period', ',': 'Comma', ';': 'Semicolon', ':': 'Colon', '"': 'Double_Quote',
'„': 'Double_Low_9_Quotation_Mark', ''': 'Left_Single_Quotation_Mark',
''': 'Right_Single_Quotation_Mark', '‚': 'Single_Low_9_Quotation_Mark',
'...': 'Ellipsis', '‹': 'Single_Left_Pointing_Angle_Quotation_Mark',
'›': 'Single_Right_Pointing_Angle_Quotation_Mark', '»': 'Right_Pointing_Double_Angle_Quotation_Mark',
'«': 'Left_Pointing_Double_Angle_Quotation_Mark', '*': 'Asterisk', '[': 'Left_Square_Bracket',
']': 'Right_Square_Bracket', '(': 'Left_Parenthesis', ')': 'Right_Parenthesis',
'{': 'Left_Curly_Bracket', '}': 'Right_Curly_Bracket', '/': 'Forward_Slash',
'–': 'En_Dash', '-': 'Hyphen', '_': 'Underscore', '<': 'Less_Than', '>': 'Greater_Than',
'?': 'Question_Mark', '!': 'Exclamation_Mark', '$': 'Dollar_Sign', '@': 'At_Sign',
'&': 'Ampersand', '+': 'Plus_Sign', '^': 'Caret', '#': 'Hash'
};
return glyphNames[char] || 'Glyph_' + char.charCodeAt(0);
}
// Document setup
var doc = app.documents.add();
var artboardSize = 1024;
// Font settings (adjust as needed)
var fontName = "Arial";
var fontSize = 800; // Starting font size, will be adjusted to fit
// Create artboards and text for each character
for (var i = 0; i < charSet.length; i++) {
var char = charSet[i];
var glyphName = getGlyphName(char);
// Create new artboard
var artboard = doc.artboards.add([0, 0, artboardSize, artboardSize]);
artboard.name = glyphName;
// Create text frame
var textFrame = doc.textFrames.add();
textFrame.contents = char;
textFrame.textRange.characterAttributes.textFont = app.textFonts.getByName(fontName);
textFrame.textRange.characterAttributes.size = fontSize;
// Center text
textFrame.left = (artboardSize - textFrame.width) / 2;
textFrame.top = (artboardSize + textFrame.height) / 2;
// Adjust font size to fit artboard if necessary
while (textFrame.width > artboardSize * 0.9 || textFrame.height > artboardSize * 0.9) {
fontSize *= 0.9;
textFrame.textRange.characterAttributes.size = fontSize;
textFrame.left = (artboardSize - textFrame.width) / 2;
textFrame.top = (artboardSize + textFrame.height) / 2;
}
// Move to next artboard position
doc.artboards.setActiveArtboardIndex(i + 1);
}
// Rearrange artboards in a grid
var columns = Math.ceil(Math.sqrt(charSet.length));
var rows = Math.ceil(charSet.length / columns);
for (var i = 0; i < charSet.length; i++) {
var row = Math.floor(i / columns);
var col = i % columns;
var artboard = doc.artboards[i];
artboard.artboardRect = [col * artboardSize, -row * artboardSize, (col + 1) * artboardSize, -(row + 1) * artboardSize];
}
alert("Artboards created successfully with descriptive names!");
Guidelines:
- Prerequisites:
- Ensure Adobe Illustrator is installed and ready.
- Familiarize yourself with using scripts in Illustrator (e.g., via File > Scripts or the ExtendScript Toolkit).
- Running the Script:
- Open Adobe Illustrator.
- Run the script through Illustrator’s script menu or load it via your preferred scripting environment.
- The script will automatically create a new document, generate an artboard for each glyph in the specified character set, and assign descriptive names to each artboard based on the glyph.
- Overview of the Process:
- The script defines a character set that includes uppercase letters, lowercase letters, numeric digits, and several punctuation marks.
- For each character, a helper function generates a descriptive name (e.g., “Uppercase_A” for A) using a predefined mapping. If a glyph isn’t explicitly mapped, it is assigned a generic name based on its character code.
- A new artboard is created for each glyph, and the glyph is rendered using a specified font and an initial font size.
- The script ensures the glyph is visually centered within the artboard by automatically adjusting the font size until it fits within 90% of the artboard’s dimensions.
- After processing all glyphs, the script organizes the artboards into a grid layout, determined by calculating the optimal number of rows and columns based on the total number of glyphs.
- Customization Options:
- You can modify the character set to include only specific characters.
- Adjust the artboard size if needed by modifying the value of the artboardSize variable.
- Change the font type and starting font size to better suit your design requirements.
- Final Output:
- Once the script completes, a confirmation alert is displayed.
- The new Illustrator document will contain a grid of artboards, each neatly labeled with a descriptive glyph name, ready for further editing or export.