Most likely, you're setting the size of the TextItem
in points, and the PPI of your images varies. Points are a unit of measurement that depend on the PPI of the document. This is so text of a given size in points is the same physical size (in inches) when printed.
There are two ways you can get your text layer's size to be consistent:
Use a consistent PPI.
The third argument to
Document#resizeImage
is the resolution (PPI). Try setting it to 96 (the conventional DPI of computer displays).activeDocument.resizeImage(MedWidth, null, 96, ResampleMethod.BICUBIC);
With a consistent DPI, your font size should also be consistent.
Set the text layer's size in pixels rather than points.
TextItem#size
can be set to aUnitValue
, which allows you to specify the unit of measurement to be used. Pixels are always pixels and do not depend on the document's PPI.textItemRef.size = new UnitValue(15, 'px');
Either should work; you only need to use one. I'd lean toward the first option.