├── README.md └── lettererbuddy.jsx /README.md: -------------------------------------------------------------------------------- 1 | # InDesign-Scripts 2 | General InDesign Scripts primarily designed for use in manga lettering 3 | 4 | ## Letterer Buddy 5 | ![](https://i.imgur.com/GlA0Mjr.png) ![](https://i.imgur.com/qwmELup.png) 6 | 7 | Allows you to load a script in a .txt file and automatically input lines into text frames as they're being created (in a similar vein to Typesetterer). At the moment, it simply takes a text file and reads it line by line, so some prior formatting will be required to make it output properly. 8 | 9 | ### Usage 10 | 1) Run the script file inside InDesign 11 | 2) Select your text file. 12 | 3) Create a text frame and shape/place/format as you wish. DO NOT ENTER ANY TEXT as the text frame needs to be empty for this to work. 13 | 4) Press escape to exit the text editing function of the text frame. This will set the contents of the text frame to the currently selected item in the script list. 14 | 15 | You can choose your starting point by selecting the required line in the script list. 16 | 17 | This is an early version of the script, and changes will most likely be coming quicky in order to further flesh it out. It hasn't been tested that much, so I expect some bugs to happen while using it. Please contact me with any issues which may occur while using this script. 18 | -------------------------------------------------------------------------------- /lettererbuddy.jsx: -------------------------------------------------------------------------------- 1 | #targetengine session; 2 | 3 | var doc = app.activeDocument; 4 | var script = []; 5 | var scriptFile = null; 6 | var scriptFileName = null; 7 | var lastScriptPath = null; 8 | var newScript = true; 9 | var lastScriptIndex = 0; 10 | 11 | var directory = new File($.fileName).parent; 12 | 13 | // DIALOG 14 | // ====== 15 | var dialog = new Window("window", undefined, undefined, {maximizeButton: false}); 16 | dialog.text = "Letterer Buddy"; 17 | dialog.orientation = "column"; 18 | dialog.alignChildren = ["center","top"]; 19 | dialog.spacing = 10; 20 | dialog.margins = 16; 21 | dialog.onClose = function() { 22 | doc.removeEventListener('afterSelectionChanged', selectionChanged); 23 | saveOptions(); 24 | }; 25 | 26 | // TPANEL1 27 | // ======= 28 | var tpanel1 = dialog.add("tabbedpanel", undefined, undefined, {name: "tpanel1"}); 29 | tpanel1.alignChildren = "fill"; 30 | tpanel1.preferredSize.width = 324; 31 | tpanel1.margins = 0; 32 | 33 | // SCRIPTTAB 34 | // ========= 35 | var scriptTab = tpanel1.add("tab", undefined, undefined, {name: "scriptTab"}); 36 | scriptTab.text = "Script"; 37 | scriptTab.orientation = "column"; 38 | scriptTab.alignChildren = ["left","top"]; 39 | scriptTab.spacing = 10; 40 | scriptTab.margins = 10; 41 | 42 | var list = scriptTab.add("listbox", undefined, undefined, {name: "list"}); 43 | list.preferredSize.width = 300; 44 | list.preferredSize.height = 200; 45 | 46 | // ACTIONSPANEL 47 | // ============ 48 | var actionsPanel = scriptTab.add("panel", undefined, undefined, {name: "actionsPanel"}); 49 | actionsPanel.text = "Actions"; 50 | actionsPanel.orientation = "row"; 51 | actionsPanel.alignChildren = ["center","top"]; 52 | actionsPanel.spacing = 10; 53 | actionsPanel.margins = 10; 54 | actionsPanel.preferredSize.width = 300; 55 | 56 | var loadScript = actionsPanel.add("button", undefined, undefined, {name: "loadScript"}); 57 | loadScript.text = "Load Script"; 58 | loadScript.onClick = function() { 59 | resetOptions(); 60 | openScript(); 61 | readScript(); 62 | populateList(); 63 | }; 64 | 65 | var resetScript = actionsPanel.add("button", undefined, undefined, {name: "resetScript"}); 66 | resetScript.text = "Reset Script"; 67 | resetScript.onClick = function() { 68 | resetOptions(); 69 | readScript(); 70 | populateList(); 71 | }; 72 | 73 | // SETTINGSTAB 74 | // =========== 75 | var settingsTab = tpanel1.add("tab", undefined, undefined, {name: "settingsTab"}); 76 | settingsTab.text = "Settings"; 77 | settingsTab.orientation = "column"; 78 | settingsTab.alignChildren = ["left","top"]; 79 | settingsTab.spacing = 0; 80 | settingsTab.margins = 10; 81 | 82 | var speakerText = settingsTab.add("checkbox", undefined, undefined, {name: "speakerText"}); 83 | speakerText.text = "Remove Speaker Text"; 84 | speakerText.onClick = function() { 85 | if (list != null) { 86 | speakerTextFunction(); 87 | populateList(); 88 | } 89 | }; 90 | 91 | var crossbarI = settingsTab.add("checkbox", undefined, undefined, {name: "crossbarI"}); 92 | crossbarI.text = "Replace Crossbar I"; 93 | crossbarI.onClick = function() { 94 | if (list != null) { 95 | crossbarIFunction(); 96 | populateList(); 97 | } 98 | }; 99 | 100 | var ellipses = settingsTab.add("checkbox", undefined, undefined, {name: "ellipses"}); 101 | ellipses.text = "Replace Ellipses with Periods"; 102 | ellipses.onClick = function() { 103 | if (list != null) { 104 | ellipsesFunction(); 105 | populateList() ; 106 | } 107 | }; 108 | 109 | var trimPeriods = settingsTab.add("checkbox", undefined, undefined, {name: "trimPeriods"}); 110 | trimPeriods.text = "Trim ...+ to ..."; 111 | trimPeriods.onClick = function() { 112 | if (list != null) { 113 | trimPeriodsFunction(); 114 | populateList() ; 115 | } 116 | }; 117 | 118 | var removeJP = settingsTab.add("checkbox", undefined, undefined, {name: "removeJP"}); 119 | removeJP.text = "Remove JP Characters"; 120 | removeJP.onClick = function() { 121 | if (list != null) { 122 | removeJPFunction(); 123 | populateList() ; 124 | } 125 | }; 126 | 127 | var replaceSplit = settingsTab.add("checkbox", undefined, undefined, {name: "replaceSplit"}); 128 | replaceSplit.text = "Replace Bubble Separator with New Line"; 129 | replaceSplit.onClick = function() { 130 | if (list != null) { 131 | replaceSplitFunction(); 132 | populateList() ; 133 | } 134 | }; 135 | 136 | var splitText = settingsTab.add('edittext {properties: {name: "splitText"}}'); 137 | splitText.text = "//"; 138 | 139 | var removePageNumbers = settingsTab.add("checkbox", undefined, undefined, {name: "removePageNumbers"}); 140 | removePageNumbers.text = "Remove Page Numbers"; 141 | removePageNumbers.onClick = function() { 142 | if (list != null) { 143 | removePageNumbersFunction(); 144 | populateList() ; 145 | } 146 | }; 147 | 148 | var removeParentheticalText = settingsTab.add("checkbox", undefined, undefined, {name: "removeParentheticalText"}); 149 | removeParentheticalText.text = "Remove Parathentical Text"; 150 | removeParentheticalText.onClick = function() { 151 | if (list != null) { 152 | removeParentheticalTextFunction(); 153 | populateList() ; 154 | } 155 | }; 156 | 157 | var removeBracketedText = settingsTab.add("checkbox", undefined, undefined, {name: "removeBracketedText"}); 158 | removeBracketedText.text = "Remove Bracketed Text"; 159 | removeBracketedText.onClick = function() { 160 | if (list != null) { 161 | removeBracketedTextFunction(); 162 | populateList() ; 163 | } 164 | }; 165 | 166 | var removeCurlyBracedText = settingsTab.add("checkbox", undefined, undefined, {name: "removeCurlyBracedText"}); 167 | removeCurlyBracedText.text = "Remove Curly Braced Text"; 168 | removeCurlyBracedText.onClick = function() { 169 | if (list != null) { 170 | removeCurlyBracedTextFunction(); 171 | populateList() ; 172 | } 173 | }; 174 | 175 | var saveSettings = settingsTab.add("checkbox", undefined, undefined, {name: "saveSettings"}); 176 | saveSettings.text = "Save Settings"; 177 | 178 | var loadLastScript = settingsTab.add("checkbox", undefined, undefined, {name: "loadLastScript"}); 179 | loadLastScript.text = "Load Last Script"; 180 | 181 | loadOptions(); 182 | 183 | if (loadLastScript.value && lastScriptPath != null) { 184 | openScript(); 185 | readScript(); 186 | speakerTextFunction(); 187 | crossbarIFunction(); 188 | ellipsesFunction(); 189 | trimPeriodsFunction(); 190 | removeJPFunction(); 191 | replaceSplitFunction(); 192 | removePageNumbersFunction(); 193 | removeParentheticalTextFunction(); 194 | removeBracketedTextFunction(); 195 | removeCurlyBracedTextFunction(); 196 | populateList(); 197 | } 198 | 199 | dialog.show(); 200 | 201 | doc.addEventListener('afterSelectionChanged', selectionChanged); 202 | 203 | function selectionChanged() { 204 | if (doc.selection[0] instanceof TextFrame && doc.selection[0].contents == '' && doc.selection[1] == null) { 205 | placeText(); 206 | } 207 | } 208 | 209 | function placeText() { 210 | if (list.selection != null) { 211 | if (doc.selection[0] instanceof TextFrame) { 212 | doc.selection[0].contents = list.selection.text; 213 | if (list.selection < list.items.length) { 214 | list.selection = list.selection + 1; 215 | } 216 | } 217 | } 218 | } 219 | 220 | function populateList() { 221 | if (scriptFile != "" && scriptFile != null && scriptFileName.indexOf(".txt") == -1){ 222 | alert("This file type is not supported. Please use .txt files only."); 223 | return; 224 | } 225 | else if (scriptFile != "" && scriptFile != null) { 226 | list.removeAll(); 227 | for (var i=0; i