Search code examples
adobe-illustrator

Select all objects with font-size between two sizes in illustrator?


I need to select all text-objects with a size between two values, for example 12 and 14pt (including 12.1, 12.2 etc). Is this at all possible?


Solution

  • This seems to be the candidate for a script. Try this:

    function selectTextWhosePointSizeIs ( minPointSize, maxPointSize )
    {
        var doc, tfs, i = 0, n = 0, selectionArray = [];
    
        if ( !app.documents.length ) { return; }
    
        doc = app.activeDocument;
        tfs = doc.textFrames;
        n = tfs.length;
    
        if ( !n ){ return; }
    
        if ( isNaN ( minPointSize ) )
        {
            alert(minPointSize + " is not a valid number" );
            return;
        }
        else if ( isNaN ( maxPointSize ) )
        {
            alert(maxPointSize + " is not a valid number" );
            return;
        }
        else if ( minPointSize > maxPointSize )
        {
            alert(minPointSize + " can't be greater than "+ maxPointSize);
            return;
        }
    
        for ( i = 0 ; i < n ; i++ )
        {
            if ( tfs[i].textRange.size >= minPointSize && tfs[i].textRange.size <= maxPointSize )
            {
                selectionArray [ selectionArray.length ] = tfs[i];
            }
        }
    
        if ( selectionArray.length )
        {
            app.selection = selectionArray;
        }
        else
        {
            alert("Nothing found in this range.");
        }
    }
    
    selectTextWhosePointSizeIs ( 12, 14 );
    

    Hope it helps,

    Loic