Highlighted

anyone know how to check if a character fontStyle is bold?

New Here ,
Oct 02, 2020

Copy link to clipboard

Copied

Hi Community, Im iterating characters of  a TextFrame to check if font Style is 'bold' , But the problem is  : 
- Fonts dont follow a nomenclature , So Arial bold is named  : 'Arial-BoldMT' ,  And by eg : Calibri bold is named as  'Calibri-BD' or something else
 ------------------------------------------------------------
The structure of fontStyle property is the following : 

 

Screenshot_1.png

  • Is there any way to w Check if a font is a bold  or derivate?
Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi,

The following snippet will give all list of fonts available in Illustrator. And style is the property that will tell you whether it is bold or regular or other

 

 

var fonts = app.textFonts;
for(var i=0;i<fonts.length;i++)
    $.writeln("Name - " + fonts[i].name + "Style - " + fonts[i].style);

 

 

TOPICS
Scripting, SDK

Views

104

Likes

Translate

Translate

Report

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

anyone know how to check if a character fontStyle is bold?

New Here ,
Oct 02, 2020

Copy link to clipboard

Copied

Hi Community, Im iterating characters of  a TextFrame to check if font Style is 'bold' , But the problem is  : 
- Fonts dont follow a nomenclature , So Arial bold is named  : 'Arial-BoldMT' ,  And by eg : Calibri bold is named as  'Calibri-BD' or something else
 ------------------------------------------------------------
The structure of fontStyle property is the following : 

 

Screenshot_1.png

  • Is there any way to w Check if a font is a bold  or derivate?
Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi,

The following snippet will give all list of fonts available in Illustrator. And style is the property that will tell you whether it is bold or regular or other

 

 

var fonts = app.textFonts;
for(var i=0;i<fonts.length;i++)
    $.writeln("Name - " + fonts[i].name + "Style - " + fonts[i].style);

 

 

TOPICS
Scripting, SDK

Views

105

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 02, 2020 1
Adobe Community Professional ,
Oct 02, 2020

Copy link to clipboard

Copied

Hi,

The following snippet will give all list of fonts available in Illustrator. And style is the property that will tell you whether it is bold or regular or other

 

 

var fonts = app.textFonts;
for(var i=0;i<fonts.length;i++)
    $.writeln("Name - " + fonts[i].name + "Style - " + fonts[i].style);

 

 

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2020 4
Engaged ,
Oct 02, 2020

Copy link to clipboard

Copied

As Charu Rajput said, test for it as such

 

textFonts[i].style == "Bold"

 

For example, this should produce a list of your bold fonts:

 

var list1 = "";
for (var i = 0; i < textFonts.length; i++){
  if (textFonts[i].style == "Bold") {
    list1 = list1 + textFonts[i].name + ",  " 
  }
}
alert ( list1 );

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2020 3
New Here ,
Oct 05, 2020

Copy link to clipboard

Copied

Awesome! , Thanks for reply .

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 05, 2020 0
Resources