Skip to content

Instantly share code, notes, and snippets.

View mb-14's full-sized avatar
🏠
Working from home

Miroojin Bakshi mb-14

🏠
Working from home
View GitHub Profile
@mb-14
mb-14 / SetTextProp.jsx
Created January 2, 2023 20:03 — forked from akamilkhan/SetTextProp.jsx
Set bold and set italic function for Photoshop JS Scripting. This can be used to control text properties in ranges, which is otherwise not supported by conventional PS JS scripting.
function setbold(IO, start, end, fontSize) {
//Sanity checking: is the active layer a text layer?
var activeLayer = app.activeDocument.activeLayer;
if (activeLayer.kind == LayerKind.TEXT) {
//More checking: does the text layer have content, and are start and end set to reasonable values?
if ((activeLayer.textItem.contents != "") && (start >= 0) && (end <= activeLayer.textItem.contents.length)) {
//The indentation that the Script Listerner gives you is weird, but it’s useful.
var idsetd = app.charIDToTypeID("setd");
var action = new ActionDescriptor();
var idnull = app.charIDToTypeID("null");