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

get FontSize of the text

Contributor ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

Hi,

how to get the font size of the text? the following code returns empty

  var oProp = doc.GetTextPropVal( textRange.beg, Constants.FP_FontSize);

  alert(oProp.propVal.sval);

pls help

TOPICS
Scripting

Views

1.3K

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
Advocate ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

Use oProp.propVal.val instead. And note that all sizes in Fm are expressed in Metrics. For a full conversion table from Metrics to other measurement units, here is the page in the FDK Reference Guide you can use:

Votes

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
Advocate ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

I have always found it very hard to set individual text properties. Maybe Rick can jump in here (I am sure he will - but he is in the US so in a different time zone).

Votes

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
Contributor ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

Thank you  for your response.. i have used ival instead of sval then works fine..

now i am trying to reset the font size..

pls help how to set the font size using setTextPropVal() or is there any other method to set font size?

Votes

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
Community Expert ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

#target framemaker

var doc, textRange, prop;

doc = app.ActiveDoc;

textRange = doc.TextSelection;

prop = new PropVal ();

prop.propIdent.num = Constants.FP_FontSize;

prop.propVal.valType = Constants.FT_Metric;

prop.propVal.val = 8 * 65536;

doc.SetTextPropVal (textRange, prop);

Votes

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
Contributor ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

Hi, This is sample script

var findSize  = "12";

var changeSize = "20";

var doc = app.ActiveDoc;

var pgf = doc.TextSelection.beg.obj;

main(pgf, doc);

function main (pgf, doc) {

    var end = Constants.FV_OBJ_END_OFFSET - 1, begin = 0, textRange;

    

    var textList = pgf.GetText (Constants.FTI_CharPropsChange);

    for (var i = textList.length - 1; i >= 0; i -= 1) {

        begin = textList.offset;

        if (begin !== end) {          

            textRange = new TextRange (new TextLoc (pgf, begin), new TextLoc (pgf, end));           

            var oProp = doc.GetTextPropVal(textRange.beg, Constants.FP_FontSize);

            if(oProp.propVal.ival /  65536 == Number(findSize)){

                newVal = 65536 * changeSize;    

                prop = new PropVal ();

                prop.propIdent.num = Constants.FP_FontSize;

                prop.propVal.valType = Constants.FT_Metric;

                prop.propVal.val = newVal;                  

                doc.SetTextPropVal (textRange, prop);

                }                  

            end = begin;

        }

    }

    if (end > 0) {

        textRange = new TextRange (new TextLoc (pgf,0), new TextLoc (pgf,end));

         var oProp = doc.GetTextPropVal(textRange.beg, Constants.FP_FontSize);      

         if(oProp.propVal.ival /  65536 == Number(findSize)){            

         newVal = 65536 * Number(changeSize);     

         prop = new PropVal ();

        prop.propIdent.num = Constants.FP_FontSize;

        prop.propVal.valType = Constants.FT_Metric;

        prop.propVal.val = newVal;

        doc.SetTextPropVal (textRange, prop);

        }

    }

}

The above script found text which have font size 12pt successfully.. but did not changed to the size 20pt.. i think it changed by default size..

is there any mistake in the above script?

Votes

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
Community Expert ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

LATEST

What exactly are you trying to do? Are you changing the whole paragraph from 12 to 20 points, or just some words inside the paragraph. You are trying to make a local property change and this is not typically how you do things in FrameMaker. You would normally modify or apply a Paragraph or Character Format to text or change the Format's properties. Can you give us the overall task that you are trying to accomplish?

Votes

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