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

New Here ,
Oct 02, 2020 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?
TOPICS
Scripting, SDK

Views

158

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Oct 02, 2020 Oct 02, 2020
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);    

Likes

translate

Translate

Translate
Adobe Community Professional ,
Oct 02, 2020 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

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
community guidelines
Enthusiast ,
Oct 02, 2020 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

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
community guidelines
New Here ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

Awesome! , Thanks for reply .

Likes

translate

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
community guidelines