Skip to main content
February 15, 2010
Question

Minumum and Maximum pointsize in the active document with font name

  • February 15, 2010
  • 1 reply
  • 701 views

hi

How to find the font with point size in active document and how to get the minimum point size and maximum point size used in the active document with font name

Thanks in Advance.

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
February 15, 2010

?

(thoughtfully added because it appeared to be missing in your post.)

I believe TextStyleRanges can gather all that information for you. To check an entire document, you will have to iterate over all its stories; with these stories, iterate over the text style ranges. For a minimum and maximum (per font? not totally clear) you can use the size of the very first text style range you find, then compare all next ones to these.

Apart from a question mark, there are a few more important things missing from your post. InDesign version? Language? Platform? Are you willing to pay for a complete working script, written & tested by a professional, or are you trying to write something yourself and got stuck? If so, what do you have so far?

February 15, 2010

hi

Thanks for your Quick Reply.

Find below the answer as required.

Indesign Version CS3

Language english

Platform windows/mac

find below the script

================================================

myAllFonts = app.fonts;
_UsedAllFonts = new Array;
for(p=0;p<=app.documents[0].pages.length-1;p++){
UsedFonts = new Array;
_UsedFonts = new Array;
UsedFonts_ = new Array;
for(t=app.documents[0].pages

.textFrames.length-1;t>=0;t--){
  myRanges = app.documents[0].pages

.textFrames.textStyleRanges;
   for(i=myRanges.length-1;i>=0;i--){
    var FontStyle;
    if(myRanges.fontStyle !=""){
     FontStyle = "\t"+myRanges.fontStyle;
    }
    else{
     FontStyle = "";
    }
    if(myRanges.appliedFont != ""){
     UsedFonts.push(myRanges.appliedFont.fontFamily+FontStyle);
    }
   }
   UsedFonts_ = UsedFonts_.concat(UsedFonts);
   UsedFonts = UniteSame(UsedFonts_);
}
_UsedFonts = UniteSame(UsedFonts);
//
_UsedAllFonts = _UsedAllFonts.concat(_UsedFonts);
_UsedAllFonts = UniteSame(_UsedAllFonts);
//
UsedFontss = _UsedFonts.join(",");
//
try{
  myTextFrame = app.documents[0].pages

.textFrames.item("EveryPage"+(p+1));
  myTextFrame.contents = UsedFontss;                  
  myTextFrameProp(myTextFrame);
}  
catch(e){                                                 
  myTextFrame = app.documents[0].pages

.textFrames.add();
  myTextFrame.geometricBounds = new Array(-40, 0, 0.001, app.documents[0].documentPreferences.pageWidth);
  myTextFrame.label = "EveryPage"+(p+1);
  myTextFrame.contents = UsedFontss;
  myTextFrameProp(myTextFrame);
}
}
//
UsedAllFonts = UniteSame(_UsedAllFonts);
UsedAllFontss = UsedAllFonts.join(",");
//
try{
myTextFrameA = app.documents[0].pages[0].textFrames.item("All");
myTextFrameA.textFramePreferences.verticalJustification = VerticalJustification.bottomAlign;
myTextFrameA.contents = UsedAllFontss;                                    
myTextFrameProp(myTextFrameA);                    
}
catch(e){                                                                 
myTextFrameA = app.documents[0].pages[0].textFrames.add();
myTextFrameA.textFramePreferences.verticalJustification = VerticalJustification.bottomAlign;                                            
myTextFrameA.geometricBounds = new Array(app.documents[0].documentPreferences.pageHeight+40, 0, app.documents[0].documentPreferences.pageHeight-0.001, app.documents[0].documentPreferences.pageWidth);
myTextFrameA.label = "All";
myTextFrameA.contents = UsedAllFontss;                                                                  
myTextFrameProp(myTextFrameA);
}
alert(myTextFrameA.contents);
alert("Done!");
function myTextFrameProp(myTextFrameA){
myTextA = myTextFrameA.texts.item(0);//words[-1];                                                     
myTextA.appliedFont = "Arial";                                                                       
myTextA.pointSize = "14pt";                                                                          
myTextA.leading = "16pt";
myTextA.fillColor = app.documents[0].swatches.item("Black");                                                                            
myTextA.justification = Justification.leftJustified;
}

function UniteSame(A) {
var x,y;
for ( x=0;x<=A.length-1; x++){
  for ( y=A.length-1;y>=0; y--){
    if ((A == A)&&(y!=x)){
      A.splice(y,1);
    }
  }
}
return(A.sort());
}

===================================================

Jongware
Community Expert
Community Expert
February 15, 2010

Okay, that does look good (without testing it). Does it do its job?

I think it can be made a bit more efficiently by not running over all text frames, but rather over all stories in the document -- a small change, the rest can stay the same.

You can also try turning the gathering of used data around. It appears you are now pushing every item immediately into your array, then weed out duplicates. (For my thoughts on the latter, see below!) It might be quicker and more memory-efficient to scan your present array to see if the new item is already in there, and only push when it's not. (Bonus points for a binary tree implementation -- the fastest possible way! But a linear search on the entire array, or on a sorted array and bailing out if you go "past" the current item, may be fast enough.)

(On Weeding out duplicates; you might want to skip this, as it won't be necessary for the above:)

Your function UniteSame sorts out and removes duplicates by comparing every item to every other one; then it sorts the array. An alternative can be to

1. Sort the array

2. Create a new empty one

3. Push an item of the original onto the new one.

4. Skip items of the original list while they are the same as the bottom one of the new list.

5. Until you run out of items.