It's pixel to millimeter ratio not to DPI ratio: 
https://github.com/codenameone/CodenameOne/blob/master/Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java#L11289-L11294

On Friday, January 8, 2021 at 11:06:55 AM UTC+2 P5music wrote:

> I read on the internet some formulas involving the pixelRatio but the 
> value in the documents you refer to seems to be an order of magnitude 
> larger than typical ratios. What is the correct formula? What that 
> pixelRatio really mean here?
> Regards
>
> Il giorno venerdì 8 gennaio 2021 alle 09:12:14 UTC+1 Shai Almog ha scritto:
>
>> It's calculated based on the pixelRatio value: 
>> https://github.com/codenameone/codenameone-skins/blob/master/HTC10/skin.properties#L9
>>
>> On Thursday, January 7, 2021 at 5:38:30 PM UTC+2 P5music wrote:
>>
>>> I cannot find the dpi value in that list.
>>>
>>> The problem is with devices sporting the Display.DENSITY_HD=60 device 
>>> density, that corresponds to XXHDPI devices.
>>> I had dpi=540 as the corresponding value (it is the value used in 
>>> calculations), I do not remember why I put that value. 
>>> Also with the dpi=480 value (from Android development website) the cm 
>>> length is too big in the CEF BrowserComponent, although smaller.
>>>
>>> These are the devices with that device density HD=60 -> 540/480 dpi
>>>
>>> Android
>>> pixel pixel2 pixel2xl htconea9 htconem8 huaweyp8 nexus5x nexus6p note5 
>>> s5 s7 s8
>>> iPhone
>>> X 5plus 6splus 7splus 8splus
>>>
>>> Maybe the dpi value is wrong but also maybe the device density value is 
>>> wrong.
>>> Regards
>>>
>>>
>>> Il giorno giovedì 7 gennaio 2021 alle 04:07:07 UTC+1 Shai Almog ha 
>>> scritto:
>>>
>>>> I would assume the problem is in the CEF browser and not in the skin. 
>>>> Did you check the values in the properties file and verify that they match 
>>>> the stated DPI of the device?
>>>>
>>>> On Wednesday, January 6, 2021 at 2:13:07 PM UTC+2 P5music wrote:
>>>>
>>>>>
>>>>> It seems to be a skin issue for many device skins.
>>>>> These skins show big buttons when the size is from the material icon 
>>>>> set. They also show that the cm length is big.
>>>>>
>>>>> The cm length is meant to be what the simulator CEF BrowserComponent 
>>>>> shows as a fixed value. It is not a real cm I think but this is another 
>>>>> issue of Milestone 7.0.  It is the same whatever device is chosen as 
>>>>> skin, 
>>>>> it is sometime blatantly wrong because it is in the simulator, not the 
>>>>> device.
>>>>>
>>>>> So let's consider just the differences from right and wrong cm measure 
>>>>> from dpi value.
>>>>>
>>>>> (Other buttons are instead sized according the dpi constant (not the 
>>>>> dpi value) with hard coded measure from the Android version of my app, 
>>>>> for 
>>>>> example 32,48,72 and so on, they happen to be re right, so they will not 
>>>>> be 
>>>>> considered.)
>>>>>
>>>>> Some skins with big buttons (material icon set) and big cm length:
>>>>> Note5, Pixel2XL, Pixel, Pixel2, HTCA9, HTCM8,Nexus5X,Nexus6P, S8
>>>>>
>>>>> skins with small buttons (material icon set) and big cm length
>>>>> iPhone6PLus, iPhone7XPlus, iPhone8Plus, X
>>>>>
>>>>> skins that have big button size (material icon set) and right cm 
>>>>> length, for example:
>>>>> MotoE, MotoG, Nexus4, GrandPrime, S3,iPhone5c
>>>>>
>>>>> skins with small buttons (material icon set) and right cm length
>>>>> iPhone6S, iPhone7, iPhone8
>>>>> Il giorno mercoledì 6 gennaio 2021 alle 04:19:18 UTC+1 Shai Almog ha 
>>>>> scritto:
>>>>>
>>>>>> Look at the skin file properties file to see the ratio variable used 
>>>>>> to calculate the density of the display. Maybe there was a mistake in 
>>>>>> generating this specific theme file. 
>>>>>> You can see the skins here: 
>>>>>> https://github.com/codenameone/codenameone-skins
>>>>>> On Tuesday, January 5, 2021 at 1:37:01 PM UTC+2 P5music wrote:
>>>>>>
>>>>>>> This question is related to
>>>>>>>
>>>>>>> https://groups.google.com/g/codenameone-discussions/c/ohobrY3v83s/m/ypQ8fmnvAQAJ
>>>>>>>
>>>>>>> In my code there is the need to have a standard length. The 
>>>>>>> instruction to do so is:
>>>>>>>
>>>>>>> int frameHeight= (int) (Utils.dpi()* 0.393701);
>>>>>>>
>>>>>>> This should be a centimeter. 
>>>>>>> (Utils.dpi() is a convenience method to get the dpi from the 
>>>>>>> Display.getInstance().getDeviceDensity() value)
>>>>>>>
>>>>>>> I tested it with two skins:
>>>>>>>
>>>>>>> Android Note5 (dpi=540 xxhdpi -> 212px)
>>>>>>>
>>>>>>> iOS iPad3  (dpi=240 hdpi -> 94px)
>>>>>>>
>>>>>>> The length measure is used in some HTML, displayed in a 
>>>>>>> BrowserComponent.
>>>>>>>
>>>>>>> When running in simulator I get that
>>>>>>> the device is different - OK
>>>>>>> the font size and the icons size or images size are the same - OK
>>>>>>> the calculated pixels value for 1cm has different size, it is bigger 
>>>>>>> in the Note5 skin.
>>>>>>>
>>>>>>> Should I use CN.convertToPixels()?
>>>>>>>
>>>>>>> Thanks in advance
>>>>>>>
>>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/ab6bedb3-3f39-4e93-9ea1-7cb1f91ed7dfn%40googlegroups.com.

Reply via email to