ScriptUI vs. UI Scaling
March 08, 2021 | Tips | en
From CC 2014, InDesign and Illustrator interfaces needed to adapt to OS “scale settings” strategy on 4K/Retina displays. And with Windows 10 defaultly scaling at 150% in such resolutions, Adobe engineers were forced to rework their famous HiDPI support, which led to introduce UI Scaling in the Preferences dialog box. So far, so good. But ScriptUI has not been fully “informed” of these new rules…
ScriptUI for InDesign CC still has serious problems with HiDPI monitors in Windows. Your typical settings—if you don't want to use a magnifying glass while navigating InDesign's submenus—probably look like this:
In short, a 1.5X factor is applied at some point in order to fit the screen coordinate space. The question is, does this factor come into play upstream, or downstream, relative to ScriptUI measurements? For example, when we set the preferredSize
of a widget to [300,200]
, or read its windowBounds
properties, are the dimensions and locations already upscaled (in actual screen coordinates), or should we talk to ScriptUI in some agnostic, internal coordinate language?
And the full, although nebulous, answer is:
This Depends On Which Property You Are Setting Or Reading!
Indeed, ScriptUI sometimes speaks its own language (regarding size
and location
properties of inner elements), and sometimes it outputs and/or expects SCREEN coordinates (mainly for Window
metrics.) Even worse, it may mix the two languages in a single object. For example, we found that the windowBounds
property of a component blends ScriptUI dimensions (.width
and .height
attributes) and screen dimensions (.left
and .top
attributes.)
Note. — As a result, windowBounds.right
and windowBounds.bottom
are purely irrelevant since they are automatically computed by adding the (width,height) dimensions to the (left,top) location!
Tests and report
We found these interesting results by benchmarking coordinates from the below script:
The below figure recaps my findings. (ScriptUI coordinates are in yellow, screen coordinates in white.)
Note. — The reported issues are CC specific. In InDesign CS6, for example, all measurements are consistent and reflect internal ScriptUI coordinates.
How to Detect the Scaling Factor
The good thing is that we can exploit the bias that corrupts ScriptUI CC coordinates to determine the actual UI scaling factor (1.5
along X- and Y- axes) applied to the display:
This routine has solved critical issues with complex UI components that required fine-tuned coordinate adjustments. It is now in use in IdExtenso.