Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS] Turn ligatures off.

New Here ,
May 26, 2009 May 26, 2009

Hi,

Is there a javascript to turn Ligatures off of Paragraph styles? We have a bunch of files with the ligatures turned on that we need to update. I know you can update the paragraph styles, but I was wondering if there is some way to tell InDesign to turn the Ligatures of with out updating each style.

Thanks!

TOPICS
Scripting
5.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , May 26, 2009 May 26, 2009

Here is a simple example which turns ligatures off in all paragraph styles that are not in groups:

var myDoc = app.activeDocument;
var myParStyles = myDoc.paragraphStyles;
for (i = 1; i < myParStyles.length; i++) {
    myParStyles.ligatures = false;
}

Translate
Valorous Hero ,
May 26, 2009 May 26, 2009

Here is a simple example which turns ligatures off in all paragraph styles that are not in groups:

var myDoc = app.activeDocument;
var myParStyles = myDoc.paragraphStyles;
for (i = 1; i < myParStyles.length; i++) {
    myParStyles.ligatures = false;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 26, 2009 May 26, 2009

Thank you so much! Will this same script work for removing hyphenation, I just need to change that line in the code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2009 May 26, 2009

var myDoc = app.activeDocument;
var myParStyles = myDoc.allParagraphStyles;
for (i = 1; i < myParStyles.length; i++) {
    myParStyles.ligatures = false;

    myParStyles.hyphenation = false;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2016 Oct 18, 2016

Hello, I know this is a very old thread; but this is exactly what I need. We use a font that has ligatures ruining our readability and it's a corporate font. This means we need to turn off the ligatures constantly (especially when an art director has copy/pasted from Microsoft Word.) We also have a lot of old files that were done by previous art directors and so they never paid much attention to ligatures and sometimes made strange work-arounds because they were nescient of ligatures (for example they would make a space and tighten up the kerning in that space.)

Point being is that I really need a script that I can run when I open a file that looks at all text and turns off ligatures and turns off hyphenations regardless if it is part of a group or not. The script you posted looks like what I want, but since Adobe has released a few versions in the past 7 years I think something needs to be changed and outside of some html/css and BASIC about 27 years ago I am not that savvy with coding and scripts.

I would appreciate it if you or someone could update this for the current InDesign. Thank you, in advance.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 18, 2016 Oct 18, 2016

The code still works in the latest version of InDesign -- CC 2015.4.

To turn off hyphenations (in all paragraph styles), you have to add one more line of code like so:

var myDoc = app.activeDocument;

var myParStyles = myDoc.paragraphStyles;

for (i = 1; i < myParStyles.length; i++) {

    myParStyles.ligatures = false;

    myParStyles.hyphenation = false; 

}

...turns off ligatures and turns off hyphenations regardless if it is part of a group or not.

The script processes all paragraph styles irrespective of whether they are in a style group or not.

Besides paragraph styles, formatting can be applied  via character styles and as local formatting:

Ligatures can be set in the

  1. paragraph style panel
  2. character style panel
  3. character panel

hyphenation can be set in the

  1. paragraph style panel
  2. paragraph panel

So, changing it in a paragraph style will have no effect, if it's overridden by a character styles or local formatting.

I think something needs to be changed and outside of some html/css

When I was writing this script, I found out that the "export tagging" feature in scripting was buggy. That's why I wasn't able to get it into shape. Though I haven't tested it in the latest version.

— Kas

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2016 Oct 18, 2016

I tried using this script and got an AppleScript error!
Error Number: -2740
Error String: A identifier can't go after this identifier
.

Engine: Default

File: {location of the script file.}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 18, 2016 Oct 18, 2016

This is a JavaScript, not AppleScript.

Save it as 'plain text' jsx-file in your Scripts > Scripts Panel folder.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2016 Oct 18, 2016

I saved it as a .scpt originally and I've now tried .js and .jsx and .txt

None seem to work....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 19, 2016 Oct 19, 2016

Download the script from here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 19, 2016 Oct 19, 2016

Thank you very much!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 12, 2017 Sep 12, 2017
LATEST

Thanks Kasyan. I downloaded the script from your link and installed it on my Mac and it works.

To install on a Mac:

Download script to Desktop

Open InDesign

Go to Window > Utilities > Scripts

Right click the User Folder, choose Reveal in Finder.

Copy the Turn ligatures off.jsx file to this folder.

Return to InDesign

Turn ligatures off should appear in the User Folder list of scripts.

Select a text block with ligature characters.

Right click the Turn ligatures off script, choose Run Script

Wait a second .. it worked for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2009 May 26, 2009

All you need to make that work with groups is change:

myDoc.paragraphStyles; to: myDoc.allParagraphStyles;

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 12, 2017 Sep 12, 2017

This script doesn't appear to work in InDesign CC2017 on a Mac? Am I missing something?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 12, 2017 Sep 12, 2017

Sorry .. It does work on Mac InDesign CC2017!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines