dpi
Size and position types for working with logical and physical pixels.
Window and webview APIs report sizes and positions in physical pixels (actual screen pixels), while most browser APIs and the window creation options use logical pixels (physical pixels divided by the monitor scale factor). The classes in this module make the unit explicit and convert between the two.
import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const size = await appWindow.innerSize(); // PhysicalSizeconst logical = size.toLogical(await appWindow.scaleFactor());They also serialize into the shape tauri::Size / tauri::Position expect, so
they can be passed straight to your own commands, see Size and
Position.
This package is also accessible with window.__TAURI__.dpi when app.withGlobalTauri in tauri.conf.json is set to true.
Classes
Section titled “Classes”LogicalPosition
Section titled “LogicalPosition”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L311
A position represented in logical pixels.
For an explanation of what logical pixels are, see description of LogicalSize.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LogicalPosition(x, y): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L316
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalPosition(object): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L317
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Logical: { x: number; y: number; }; } |
object.Logical |
{ x: number; y: number; } |
object.Logical.x |
number |
object.Logical.y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalPosition(object): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L318
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ x: number; y: number; } |
object.x |
number |
object.y |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
type |
readonly |
"Logical" |
'Logical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L312 |
x |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L313 |
y |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L314 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L381
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L383 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L384 |
round()
Section titled “round()”round(): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L377
Rounds the coordinates to whole pixels, rounding halves away from zero
like Rust’s LogicalPosition::cast::<i32>().
Returns a new LogicalPosition and leaves this one unchanged.
Returns
Section titled “Returns”Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const position = await appWindow.innerPosition(); // PhysicalPositionconst logical = position.toLogical(factor).round();2.13.0
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L388
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L383 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L384 |
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L356
Converts the logical position to a physical one.
The result can have fractional pixels, see PhysicalPosition.round.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { LogicalPosition } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const position = new LogicalPosition(400, 500);const physical = position.toPhysical(factor);2.0.0
LogicalSize
Section titled “LogicalSize”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L46
A size represented in logical pixels.
Logical pixels are scaled according to the window’s DPI scale.
Most browser APIs (i.e. MouseEvent’s clientX) will return logical pixels.
For logical-pixel-based position, see LogicalPosition.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LogicalSize(width, height): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L51
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
width |
number |
height |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalSize(object): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L52
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Logical: { height: number; width: number; }; } |
object.Logical |
{ height: number; width: number; } |
object.Logical.height |
number |
object.Logical.width |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new LogicalSize(object): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L53
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ height: number; width: number; } |
object.height |
number |
object.width |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
height |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L49 |
type |
readonly |
"Logical" |
'Logical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L47 |
width |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L48 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L116
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L119 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L118 |
round()
Section titled “round()”round(): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L112
Rounds the width and height to whole pixels, rounding halves away from zero
like Rust’s LogicalSize::cast::<u32>().
Returns a new LogicalSize and leaves this one unchanged.
Returns
Section titled “Returns”Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const size = await appWindow.innerSize(); // PhysicalSizeconst logical = size.toLogical(factor).round();2.13.0
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L123
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L119 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L118 |
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L91
Converts the logical size to a physical one.
The result can have fractional pixels, see PhysicalSize.round.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { LogicalSize } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const size = new LogicalSize(400, 500);const physical = size.toPhysical(factor);2.0.0
PhysicalPosition
Section titled “PhysicalPosition”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L401
A position represented in physical pixels.
For an explanation of what physical pixels are, see description of PhysicalSize.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PhysicalPosition(x, y): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L406
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalPosition(object): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L407
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Physical: { x: number; y: number; }; } |
object.Physical |
{ x: number; y: number; } |
object.Physical.x |
number |
object.Physical.y |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalPosition(object): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L408
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ x: number; y: number; } |
object.x |
number |
object.y |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
type |
readonly |
"Physical" |
'Physical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L402 |
x |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L403 |
y |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L404 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L472
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L474 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L475 |
round()
Section titled “round()”round(): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L468
Rounds the coordinates to whole pixels, rounding halves away from zero
like Rust’s PhysicalPosition::cast::<i32>().
Returns a new PhysicalPosition and leaves this one unchanged.
APIs that take a physical position, such as Window.setPosition, only accept whole pixels.
Returns
Section titled “Returns”Example
Section titled “Example”import { LogicalPosition } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const physical = new LogicalPosition(-101, 84.17).toPhysical(factor).round();await appWindow.setPosition(physical);2.13.0
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L479
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
x |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L474 |
y |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L475 |
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L444
Converts the physical position to a logical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { PhysicalPosition } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const position = new PhysicalPosition(400, 500);const logical = position.toLogical(factor);2.0.0
PhysicalSize
Section titled “PhysicalSize”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L140
A size represented in physical pixels.
Physical pixels represent actual screen pixels, and are DPI-independent.
For high-DPI windows, this means that any point in the window on the screen
will have a different position in logical pixels LogicalSize.
For physical-pixel-based position, see PhysicalPosition.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PhysicalSize(width, height): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L145
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
width |
number |
height |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalSize(object): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L146
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ Physical: { height: number; width: number; }; } |
object.Physical |
{ height: number; width: number; } |
object.Physical.height |
number |
object.Physical.width |
number |
Returns
Section titled “Returns”Constructor
Section titled “Constructor”new PhysicalSize(object): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L147
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
object |
{ height: number; width: number; } |
object.height |
number |
object.width |
number |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
height |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L143 |
type |
readonly |
"Physical" |
'Physical' |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L141 |
width |
public |
number |
undefined |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L142 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L209
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L212 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L211 |
round()
Section titled “round()”round(): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L205
Rounds the width and height to whole pixels, rounding halves away from zero
like Rust’s PhysicalSize::cast::<u32>().
Returns a new PhysicalSize and leaves this one unchanged.
APIs that take a physical size, such as Window.setSize, only accept whole pixels.
Returns
Section titled “Returns”Example
Section titled “Example”import { LogicalSize } from '@tauri-apps/api/dpi';import { getCurrentWindow } from '@tauri-apps/api/window';
const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const physical = new LogicalSize(301, 201).toPhysical(factor).round();await appWindow.setSize(physical);2.13.0
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L216
Returns
Section titled “Returns”object
| Name | Type | Defined in |
|---|---|---|
height |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L212 |
width |
number |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L211 |
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L181
Converts the physical size to a logical one.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const appWindow = getCurrentWindow();const factor = await appWindow.scaleFactor();const size = await appWindow.innerSize(); // PhysicalSizeconst logical = size.toLogical(factor);2.0.0
Position
Section titled “Position”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L516
A position represented either in physical or in logical pixels.
This type is basically a union type of LogicalPosition and PhysicalPosition
but comes in handy when using tauri::Position in Rust as an argument to a command, as this class
automatically serializes into a valid format so it can be deserialized correctly into tauri::Position
So instead of
import { invoke } from '@tauri-apps/api/core';import { LogicalPosition, PhysicalPosition } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPositionconst validPosition = position instanceof LogicalPosition ? { Logical: { x: position.x, y: position.y } } : { Physical: { x: position.x, y: position.y } }await invoke("do_something_with_position", { position: validPosition });You can just use Position
import { invoke } from '@tauri-apps/api/core';import { LogicalPosition, PhysicalPosition, Position } from '@tauri-apps/api/dpi';
const position: LogicalPosition | PhysicalPosition = someFunction(); // where someFunction returns either LogicalPosition or PhysicalPositionconst validPosition = new Position(position);await invoke("do_something_with_position", { position: validPosition });2.1.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Position(position): Position;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L519
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
position |
| PhysicalPosition | LogicalPosition |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Defined in |
|---|---|---|
position |
| PhysicalPosition | LogicalPosition |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L517 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L553
Returns
Section titled “Returns”object
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L562
Returns
Section titled “Returns”object
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L532
Converts the wrapped position to a logical one.
Returns the inner value untouched when it already is a LogicalPosition.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
scaleFactor |
number |
The monitor scale factor, e.g. await appWindow.scaleFactor(). |
Returns
Section titled “Returns”2.1.0
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalPosition;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L547
Converts the wrapped position to a physical one.
Returns the inner value untouched when it already is a PhysicalPosition.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
scaleFactor |
number |
The monitor scale factor, e.g. await appWindow.scaleFactor(). |
Returns
Section titled “Returns”2.1.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L253
A size represented either in physical or in logical pixels.
This type is basically a union type of LogicalSize and PhysicalSize
but comes in handy when using tauri::Size in Rust as an argument to a command, as this class
automatically serializes into a valid format so it can be deserialized correctly into tauri::Size
So instead of
import { invoke } from '@tauri-apps/api/core';import { LogicalSize, PhysicalSize } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSizeconst validSize = size instanceof LogicalSize ? { Logical: { width: size.width, height: size.height } } : { Physical: { width: size.width, height: size.height } }await invoke("do_something_with_size", { size: validSize });You can just use Size
import { invoke } from '@tauri-apps/api/core';import { LogicalSize, PhysicalSize, Size } from '@tauri-apps/api/dpi';
const size: LogicalSize | PhysicalSize = someFunction(); // where someFunction returns either LogicalSize or PhysicalSizeconst validSize = new Size(size);await invoke("do_something_with_size", { size: validSize });2.1.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Size(size): Size;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L256
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
size |
| PhysicalSize | LogicalSize |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Defined in |
|---|---|---|
size |
| PhysicalSize | LogicalSize |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L254 |
Methods
Section titled “Methods”__TAURI_TO_IPC_KEY__()
Section titled “__TAURI_TO_IPC_KEY__()”__TAURI_TO_IPC_KEY__(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L290
Returns
Section titled “Returns”object
toJSON()
Section titled “toJSON()”toJSON(): object;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L299
Returns
Section titled “Returns”object
toLogical()
Section titled “toLogical()”toLogical(scaleFactor): LogicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L269
Converts the wrapped size to a logical one.
Returns the inner value untouched when it already is a LogicalSize.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
scaleFactor |
number |
The monitor scale factor, e.g. await appWindow.scaleFactor(). |
Returns
Section titled “Returns”2.1.0
toPhysical()
Section titled “toPhysical()”toPhysical(scaleFactor): PhysicalSize;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/dpi.ts#L284
Converts the wrapped size to a physical one.
Returns the inner value untouched when it already is a PhysicalSize.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
scaleFactor |
number |
The monitor scale factor, e.g. await appWindow.scaleFactor(). |
Returns
Section titled “Returns”2.1.0
© 2026 Tauri Contributors. CC-BY / MIT