A simple (or maybe not) question. What is the Comp...
# compose-desktop
m
A simple (or maybe not) question. What is the Compose Desktop equivalent to
Copy code
val densityDpi = LocalContext.current.resources.displayMetrics.densityDpi
This only seems to work on Android or maybe I am just blind and don’t see the obvious.
s
does
val density = LocalDensity.current
help?
i
The code that initializes HiDPI is here, btw. https://github.com/JetBrains/androidx/blob/jb-main/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/LayoutConfiguration.desktop.kt But
LocalDensity
should be good enough to get that value in an application.
m
I want to get the physical DPI value and that does not seem to be possible without resorting to AWT methods.
Copy code
val scaledDpi = Toolkit.getDefaultToolkit().screenResolution
val displayScalingFactor = LocalDensity.current.density.dp.value
val physicalDpi = displayScalingFactor * scaledDpi
I think the underlying issue is this: https://github.com/JetBrains/compose-jb/issues/531