Answered
Indesign Script: Getting the x-height
Hi.
I am trying to read the x-height of a selected character using InDesign script.
I can't seem to find the property.
Do you have any sugesstions?
Hi.
I am trying to read the x-height of a selected character using InDesign script.
I can't seem to find the property.
Do you have any sugesstions?
Hi rasmussvanejensen,
you could do the following:
( function()
{
var testContents = "x";
if( app.selection.length != 1 ){ return };
if( !app.selection[0].hasOwnProperty( "baselineShift" ) ){ return };
if( app.selection[0].insertionPoints.length < 2 ){ return };
var doc = app.documents[0];
var character = app.selection[0].characters[0];
var tempFrame = doc.textFrames.add({ geometricBounds : doc.pages[0].bounds });
character.duplicate( LocationOptions.AT_BEGINNING , tempFrame.parentStory );
tempFrame.parentStory.contents = testContents ;
var outlinedX = tempFrame.characters[0].createOutlines( false )[0];
var gB = outlinedX.geometricBounds;
var height = gB[2] - gB[0] ;
alert( "Height "+testContents+": "+ height );
outlinedX.remove();
tempFrame.remove();
}() )
Regards,
Uwe Laubender
( ACP )
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.