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

Select the strings that uses a specific font

New Here ,
Jul 08, 2019 Jul 08, 2019

I have not found a solution for aligning strings for specific font

I searched for information on Google. Some people said that I can use a script to solve it. I haven't used it yet. Any suggestions are welcome.

In my file, there are two font strings, I need to select them separately then align them.

E.g:

  1. Select the strings that use the calibri font
  2. Align bottoms
  3. Move the strings right 3 pixels

4.Select the strings that use Arial fonts

  1. Align bottoms
  2. Move the strings down 3 pixels

Please see the picture below

PIC.gif

TOPICS
Scripting
1.6K
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
Adobe
Advocate ,
Jul 08, 2019 Jul 08, 2019

L'image n'est pas significative,

Trois textes ou un seul texte ??

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 ,
Jul 08, 2019 Jul 08, 2019

Thank you for your reply, is three texts

img.png

Sample file link:

https://yadi.sk/i/cAqAOqfr7fa5TQ

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

you can using this script:

var doc=app.activeDocument;

var targetfont=doc.selection.characterAttributes.textFont.name;

var targetalign=doc.selection.characterAttributes.alignment;

for (var i=0;i<doc.textFrames.length;i++)

{

    for(var j=0;j<doc.textFrames.characters.length;j++)

    {

        if(doc.textFrames.characters.characterAttributes.textFont.name==targetfont)

            doc.textFrames.characters.alignment=targetalign;

        }

}

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 ,
Jul 11, 2019 Jul 11, 2019

Hello, thank you for your reply, can't run successfully, prompt the following error

Error 1220: Illegal Argument

Line: 3

->  var targetfont=doc.selection.characterAttributes.textFont.name;

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

You must select a character before excute script.

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 ,
Jul 11, 2019 Jul 11, 2019

I have already selected, please see the picture below

Sample file link:

https://yadi.sk/i/cAqAOqfr7fa5TQ

pic.png

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

This script will set alignment of character you selected to characters have font name the same.

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 ,
Jul 11, 2019 Jul 11, 2019

I tried it many times and still can't succeed.

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

Please select character (Text), not select textframe.

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 ,
Jul 11, 2019 Jul 11, 2019

There are no more error tips this time, but there is no alignment effect.

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

This script only set to font you selected, if you want set other font, you must select next font and run script.

Ex: if data have 2 font: you must select 2 that fonts and run 2 times.

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 ,
Jul 11, 2019 Jul 11, 2019

No effect, the version I am using is cs6

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

you can up file sample.

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 ,
Jul 11, 2019 Jul 11, 2019

I didn't find the button to upload the attachment, I uploaded it to the network drive.

Sample file link:

https://yadi.sk/i/cAqAOqfr7fa5TQ

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

Hi, i think you must 2 scipt to up or down text.

1 .  move up 3px:

var doc=app.activeDocument;

var targetfont=doc.selection.characterAttributes.textFont.name;

for (var i=0;i<doc.textFrames.length;i++)

{

    for(var j=0;j<doc.textFrames.characters.length;j++)

    {

        if(doc.textFrames.characters.characterAttributes.textFont.name==targetfont)

          { 

              doc.textFrames.characters.alignment=StyleRunAlignmentType.bottom;

              doc.textFrames.characters.baselineShift=doc.textFrames.characters.baselineShift +3;

            }

        }

}

2. move down 3 px:

var doc=app.activeDocument;

var targetfont=doc.selection.characterAttributes.textFont.name;

for (var i=0;i<doc.textFrames.length;i++)

{

    for(var j=0;j<doc.textFrames.characters.length;j++)

    {

        if(doc.textFrames.characters.characterAttributes.textFont.name==targetfont)

          { 

              doc.textFrames.characters.alignment=StyleRunAlignmentType.bottom;

              doc.textFrames.characters.baselineShift=doc.textFrames.characters.baselineShift -3;

            }

        }

}

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 ,
Jul 11, 2019 Jul 11, 2019
LATEST

The problem of moving strings has been resolved

At present, only the problem of aligning strings is not solved. I hope someone can provide some solutions. 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
New Here ,
Jul 11, 2019 Jul 11, 2019

The strings in each box are independent, please see the image below

pic2.png

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