var doc = app.activeDocument; var layer = doc.activeLayer; var strokeO = 2; //Offset from baseline function drawUnderline(x, y, w, sw, sg, color, ln){ var h = 1;//height stroke var p = sw+sg; //stroke period prevColor = app.foregroundColor; app.foregroundColor = color; // ======================================================= var id2631 = charIDToTypeID( "Mk " ); var desc192 = new ActionDescriptor(); var id2632 = charIDToTypeID( "null" ); var ref77 = new ActionReference(); var id2633 = stringIDToTypeID( "contentLayer" ); ref77.putClass( id2633 ); desc192.putReference( id2632, ref77 ); var id2634 = charIDToTypeID( "Usng" ); var desc193 = new ActionDescriptor(); var id2635 = charIDToTypeID( "Type" ); var id2636 = stringIDToTypeID( "solidColorLayer" ); desc193.putClass( id2635, id2636 ); var id2637 = charIDToTypeID( "Shp " ); var desc194 = new ActionDescriptor(); var id2638 = charIDToTypeID( "Top " ); var id2639 = charIDToTypeID( "#Pxl" ); desc194.putUnitDouble( id2638, id2639, y ); var id2640 = charIDToTypeID( "Left" ); var id2641 = charIDToTypeID( "#Pxl" ); desc194.putUnitDouble( id2640, id2641, x ); var id2642 = charIDToTypeID( "Btom" ); var id2643 = charIDToTypeID( "#Pxl" ); desc194.putUnitDouble( id2642, id2643, y+h ); var id2644 = charIDToTypeID( "Rght" ); var id2645 = charIDToTypeID( "#Pxl" ); desc194.putUnitDouble( id2644, id2645, x+sw ); var id2646 = charIDToTypeID( "Rctn" ); desc193.putObject( id2637, id2646, desc194 ); var id2647 = stringIDToTypeID( "contentLayer" ); desc192.putObject( id2634, id2647, desc193 ); executeAction( id2631, desc192, DialogModes.NO ); for (var i= 0; i < ((w-p)/p); i++){ // ======================================================= var id2648 = charIDToTypeID( "AddT" ); var desc195 = new ActionDescriptor(); var id2649 = charIDToTypeID( "null" ); var ref78 = new ActionReference(); var id2650 = charIDToTypeID( "Path" ); var id2651 = charIDToTypeID( "Ordn" ); var id2652 = charIDToTypeID( "Trgt" ); ref78.putEnumerated( id2650, id2651, id2652 ); desc195.putReference( id2649, ref78 ); var id2653 = charIDToTypeID( "T " ); var desc196 = new ActionDescriptor(); var id2654 = charIDToTypeID( "Top " ); var id2655 = charIDToTypeID( "#Pxl" ); desc196.putUnitDouble( id2654, id2655, y ); var id2656 = charIDToTypeID( "Left" ); var id2657 = charIDToTypeID( "#Pxl" ); desc196.putUnitDouble( id2656, id2657, (p*(i+1))+x ); var id2658 = charIDToTypeID( "Btom" ); var id2659 = charIDToTypeID( "#Pxl" ); desc196.putUnitDouble( id2658, id2659, y+h ); var id2660 = charIDToTypeID( "Rght" ); var id2661 = charIDToTypeID( "#Pxl" ); desc196.putUnitDouble( id2660, id2661, (p*(i+1))+x+sw ); var id2662 = charIDToTypeID( "Rctn" ); desc195.putObject( id2653, id2662, desc196 ); executeAction( id2648, desc195, DialogModes.NO ); } app.foregroundColor = prevColor; var newLayer = doc.activeLayer; newLayer.link(doc.layers.getByName (ln)) } dlg = new Window ('dialog', 'Dotted and Dashed Text For Point Text'); dotBtn = dlg.add('button', undefined, 'Dotted'); dashBtn = dlg.add('button', undefined, 'Dashed'); dotBtn.onClick = function(){ var strokeW = 1; // Width var strokeG = 1; // Gitter ti.underline = UnderlineType.UNDERLINEOFF; drawUnderline(Math.round(layer.bounds[0]), Math.round(ti.position[1]+strokeO), layer.bounds[2] - layer.bounds[0], strokeW, strokeG, ti.color, layer.name); dlg.hide(); } dashBtn.onClick = function(){ var strokeW = 3; // Width var strokeG = 2; // Gitter ti.underline = UnderlineType.UNDERLINEOFF; drawUnderline(Math.round(layer.bounds[0]), Math.round(ti.position[1]+strokeO), layer.bounds[2] - layer.bounds[0], strokeW, strokeG, ti.color, layer.name); dlg.hide(); } if (layer.kind == LayerKind.TEXT){ ti = layer.textItem; if (ti.kind = TextType.POINTTEXT){ dlg.show(); } }