For your second question: to get the leading, in mm, have a look at this:
(function () {
// this is the default, usually
app.scriptPreferences.measurementUnit = MeasurementUnits.PTS;
const mm = 2.834645;
var doc = app.activeDocument,
text = doc.selection[0];
// sanity-check
if (!text || !text.hasOwnProperty('leading')) {
alert('Please select some text and try again.');
return;
}
// raw value in pts
var leadingPT = text.leading,
leadingMM;
if (leadingPT === Leading.AUTO) {
// calculate auto leading by multiplying auto leading percentage with point size
leadingMM = Math.floor(((text.autoLeading / 100 * text.pointSize) / mm) * 1000) / 1000
}
else {
// just choose one of the following, depending on your taste:
// (a) calculate millimeters, method 1: manually (rounding is optional depending on needs)
leadingMM = Math.floor((text.leading / mm) * 1000) / 1000;
// (b) calculate millimeters, method 2: the UnitValue object handles it all
leadingMM = UnitValue(text.leading, 'pt').as('mm');
}
alert('Leading in mm: ' + leadingMM);
})();
I prefer this method (I don't change the measurementUnit from points), but you may prefer to do so in your case. You can do this:
(function () {
// explicitly set measurement unit to millimeters
app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
var doc = app.activeDocument,
text = doc.selection[0];
// sanity-check
if (!text || !text.hasOwnProperty('leading')) {
alert('Please select some text and try again.');
return;
}
// raw value in MILLIMETERS this time
var leadingMM = text.leading;
if (leadingMM === Leading.AUTO)
// calculate auto leading by multiplying auto leading percentage with point size
leadingMM = Math.floor(text.autoLeading / 100 * text.pointSize * 1000) / 1000;
alert('Leading in mm: ' + leadingMM);
})();