1

I'm using multi images and counting font sizes using Display.getInstance().convertToPixels(sizeInMM), which on majority of devices works great. On old android tablet, if I set font size to 2.1mm, it actualy has that size. The problem is with newer small devices with retina display. 2.1mm font on iPhone 6 is only 1.9mm, which is not that bad, but on iPad mini with retina, it's only 1.1, which is pretty much unusable... How can I overcome that limitation?

I was thinking about adding some kind of correction to the conversion like:

if (isIOS() && isTablet()) {
    return Display.getInstance().convertToPixels(sizeInMM * 2);
} else if (isIPhone6_OrHigher()) {
    return Display.getInstance().convertToPixels(sizeInMM * 1.1);
} else if (...) {
    ...
}

But I think that's just not the way cn1 is designed. At least in doc, this is not recommended...

feci
  • 127
  • 6

1 Answers1

0

That's a pretty problematic scenario. Apple doesn't want us to detect iPad mini, some hacks exist and we considered using them to give a slightly different DPI for iPad mini but ultimately they are hacks so we decided to avoid that and treat it like an iPad which is what Apple "wants".

That sounds bad but it's generally a good practice, you are relying a bit too much on the accuracy of the sizes returned by convertToPixels which is a problem as these sizes are often reported incorrectly by devices especially on Android. This usually isn't a problem if elements are too big but as you discovered it is an issue when elements are too small which is why we usually aim at 2.5mm font size and use 2mm only for very small text.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Is there a way to get to larger multi-images? or basicly to various sizes of multi-images? `resource.getImage` returns already counted and pre-cached one... – feci Jun 25 '17 at 21:34
  • The idea of multi image is that it's seamless and memory efficient so the other resolutions were already discarded. The `Resources.open(String,int)` method allows you to open a resource file with a specific DPI setting, this is mostly designed for games where you don't care as much about density as you do about resolution. I would recommend avoiding such hacks as it leads down the road of device detection which... well... You have 24,000 Android device **types** that's insane... You need to write logic that's flexible. – Shai Almog Jun 26 '17 at 04:27