Skip to main content
Tassos Anastasiou
Inspiring
September 8, 2022
Question

How to set font size with Extendscript

  • September 8, 2022
  • 2 replies
  • 1243 views

I am trying to set the font family, size and style of the selection using ExtendScript. Family and Style are applied correctly but the font size stays the same. FM2019. What am I doing wrong?

FA_Errno  is set to FE_Success after the operation.

 

function fixText(targetDoc){
var i = 0;
   var arial = GetFontFamilyValue("Symbol"); 
   var textProps = AllocatePropVals(3);
    i=0;
    textProps[i].propIdent.num = Constants.FP_FontFamily;
    textProps[i].propVal.valType = Constants.Integer;
    textProps[i].propVal.ival = arial ; 
   
    i++;
    textProps[i].propIdent.num = Constants.FP_FontSize;
    textProps[i].propVal.valType = Constants.Integer;
    textProps[i].propVal.ival = 36 * 65536;
     
    i++;
    textProps[i].propIdent.num = Constants.FP_Underlining;
    textProps[i].propVal.valType = Constants.Integer;
    textProps[i].propVal.ival = Constants.FV_CB_SINGLE_UNDERLINE;
   
    var  tr = targetDoc.TextSelection;
      targetDoc.SetTextProps(tr, textProps);
      PrintFAErrno ();
      return;

     }

 

This topic has been closed for replies.

2 replies

Legend
September 9, 2022

I think Rick is right. When I query the property, it comes back with a valType of 2. The documentation suggests that this should be Constants.FT_Metric. I don't have time at the moment to actually test it.

 

Russ

Legend
September 9, 2022

After posting that, I notice that you are using Constants.Integer. I don't think that is defined. I think it should be Constants.FT_Integer. Makes me wonder why it works, though. Maybe the default is integer if it can't make sense of anything else.

Tassos Anastasiou
Inspiring
September 9, 2022

Thanks@frameexpert @Russ Ward I have tried both Constants.FT_Metric and Constants.FT_Integer but I still don't get the expected results.

frameexpert
Community Expert
Community Expert
September 9, 2022

Are you sure the valType for font size is Integer? Font sizes can be fractional values.

www.frameexpert.com