cassidyjames / dippi

Calculate display info like DPI and aspect ratio
https://cassidyjames.com/dippi
GNU General Public License v3.0
75 stars 24 forks source link

Compute DPI for smartphones too #130

Open Kekun opened 5 months ago

Kekun commented 5 months ago

I have a OnePlus 6, which has a 19:9 6.22" 2280×1080 ~405 DPI screen, and it runs postmarketOS with GNOME Shell. Its default DPI is 300% for a logical DPI of 135, but I find that fairly high for a device as close to our faces as a smartphone, so I set it to 275% for a 147 logical DPI, which I find to work better (fractional scaling glitches aside).

While this issue seems to be related to https://github.com/cassidyjames/dippi/issues/129, it's not, what I am trying to say is just as laptops and desktops have different DPI recommendations because of how close or far we put them to our face, so are smartphones and given Linux is starting to work almost decently on phones (even if it's all still very experimental), it's be nice to have dippi support smartphones as a device type, with a target logical DPI of 145~150 maybe, 160 is a bit too high, and 135 is a bit too tiny.

For reference, the OnePlus 6 has a DPI of 402, and postmarketOS defaults GNOME to 300% on it for a logical DPI of 134 and a logical screen size of 360×760, and it's a bit large, larger than the ideal for a laptop even as we hold smartphones even closer to our eyes. I feel a scale of 250% for ~161 logical DPI is starting to bee really hard to read, and 275% for ~146 logical DPI strikes the right balance.

Kekun commented 5 months ago

If my calculations are correct (or more exactly, if the info I base them on are correct), the iPhone 12, Pro and Pro Max have a DPI of 456 and a scale of 300%, so the matching logical DPI is 152. The iPhone 12 Mini has a DPI of 496 and a scale of 300%, so the matching logical DPI is 165. I don't know if the diagonals I found account for the rounded corners or not, which is what could make my calculations fluctuate the most.

Regardless, 152 logical DPI as a target feels about right for a "regular" phone. On my OnePlus 6 running GNOME and its 402 DPI screen, I feel like the right scale is somewhere in between 250% (160 logical DPI) and 275% (146 logical DPI).


I just checked my Xperia 10 IV and it also has a 456 DPI screen. It seems to me 456 DPI and 300% scaling (so 152 logical DPI) pretty much was the gold standard for smartphones a few years ago, and likely is what we should target too.

Also I may be wrong be I had the impression this phone's Android lets me choose the UI's scaling between:

It's hard to tell because it only shows a stepped scale (only the steps are valid values) and there are no numbers visible, but it's the impression these steps give me.


It took me time but I found out that Android defines the Density Independent Pixel unit (dp or dip) as a pixel at 160 DPI, and it's the base for their scaling model. It kinda makes sense, and that's exactly what I have if I set the scale to 250% on my OnePlus 6 running GNOME, but I feel like it' really is the upper limit, beyond that it's definitely too small and it's already too small to my liking, I think 152 DPI is a better target.

AdrianVovk commented 4 months ago

I was researching this for the purposes of picking defaults in Mutter.

TL;DR: Here's the target DPI values. https://gitlab.gnome.org/GNOME/mutter/-/blob/422ee451/src/backends/meta-monitor.c#L1845-1867. 135 is the target for mobile too. On screens over 20 inches, we drop down to 110.

I reached that number by setting default settings on different OSs and devices, then physically comparing the UI size against different scale factors on GNOME to compensate for scaling differences just hard-coded into the apps. For example: different Android skins use different sizes for buttons, icons, etc even though they're all using the same DP unit. Here's my raw data dump: https://docs.google.com/spreadsheets/d/1NEDFEEpT3WBmzbwBUYqu92vDSt6Go_zhTxRr1_FWdjU/edit?usp=sharing

More context: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2653

Conclusion for Android phones was: "It depends". Basically, we found that Android generally comes in two flavors, ~130ish logical DPI, and 150 logical DPI. Didn't look at iPhones, or really all that many phones in general. I personally almost always drop the UI scale on my phones - I prefer a smaller UI than tends to be the default.

cassidyjames commented 3 months ago

I'd love to tackle this for a redesign/rewrite (in tandem with #122). :) I agree, more device types would be more interesting—but it might require a whole lot more smarts than my (admittedly pretty dumb) current implementation.