Reading the User Interface Scaling Value in UXP

We’re working on a UXP based plug-in for Adobe InDesign and trying to handle with the user adjusts the User Interface Scaling. In macOS one way to reach this this is at InDesign > Preferences > User Interface Scaling...
I never did figure out how to properly handle it in ExtendScript with ScriptUI. But I’m hoping that UXP provides something.

Questions:

  1. Is there a way to read what the value is via JavaScript?

  2. Is there some CSS way of responding to different settings?

  3. Anything else I should know?

jsw

1. Is there a way to read what the value is via JavaScript?

It seems there is no way to get it directly. In ExtendScript, Marc Autret shows how to get it by using the ScriptUI window.
Indiscripts :: ScriptUI vs. UI Scaling

I was able to get it in UXP by executing that ExtendScript via doScript.

const InDesign = require('indesign') ;
const { app, ScriptLanguage, UndoModes } = InDesign ;

// [Indiscripts :: ScriptUI vs. UI Scaling](https://indiscripts.com/post/2021/03/scriptui-vs-ui-scaling)
const uiScaling = `(function(w) {
  (w=new Window('palette','')).margins=0;
  w.add('group').minimumSize=[500,500];
  w.layout.layout(1);
  return [w.size[0]/500,w.size[1]/500];
})();` ;

console.log(app.doScript(uiScaling, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT)) ;
// --> [1.25, 1.252] ;

2. Is there some CSS way of responding to different settings?

I am not familiar with CSS, but Media Queries might be close to what you are looking for.

3. Anything else I should know?

These information may help.

  • app.generalPreferences.useCustomMonitorResolution
  • app.generalPreferences.customMonitorPpi
  • app.generalPreferences.mainMonitorPpi
1 Like

That looks very helpful. Thank you @sttk3

1 Like