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

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

New Here ,
Oct 02, 2020 Oct 02, 2020

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.pngexpand image

  • Is there any way to w Check if a font is a bold  or derivate?
TOPICS
Scripting , SDK
423
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

Community Expert , 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);

 

 

Translate
Adobe
Community Expert ,
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);

 

 

Best regards
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
Guide ,
Oct 02, 2020 Oct 02, 2020

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 );

 

 

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 ,
Oct 05, 2020 Oct 05, 2020
LATEST

Awesome! , Thanks for reply .

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