PixelRatio.get() is the number of physical pixels per density-independent pixel: 1 on mdpi Android screens, 2 on xhdpi and older iPhones, 3 on xxhdpi phones and most recent iPhones. getPixelSizeForLayoutSize(dp) converts to whole pixels, which is how you request an image of exactly the right size from a server, and roundToNearestPixel(dp) snaps a layout value to the pixel grid so a hairline does not blur across two rows. getFontScale() returns the user's font-size setting. The same Metrics screen logs them:
console.log(`ratio ${PixelRatio.get()}, font scale ${PixelRatio.getFontScale()}, `
+ `50 dp = ${PixelRatio.getPixelSizeForLayoutSize(50)} px, `
+ `8.4 dp -> ${r(PixelRatio.roundToNearestPixel(8.4) * 1000) / 1000} dp`);It ran twice, the second time after adb shell settings put system font_scale 1.3:
LOG ratio 2.625, font scale 1, 50 dp = 131 px, 8.4 dp -> 8.381 dp LOG ratio 2.625, font scale 1.2999999523162842, 50 dp = 131 px, 8.4 dp -> 8.381 dp
At 420 dpi the ratio is 2.625, not a whole number, so 50 dp is 131.25 pixels, rounded to 131, and 8.4 dp snaps to 22 pixels, 8.381 dp. The font scale arrives as a 32-bit float, hence the long decimal; compare it with a tolerance.