[TIMOB-25986] Windows: Physical pixel as a unit in views and fonts is not working
GitHub Issue | n/a |
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2018-06-21T23:18:21.000+0000 |
Affected Version/s | Release 7.1.0 |
Fix Version/s | Release 7.3.0 |
Components | Windows |
Labels | n/a |
Reporter | Aminul Islam |
Assignee | Kota Iguchi |
Created | 2018-04-24T14:36:01.000+0000 |
Updated | 2018-07-05T16:36:04.000+0000 |
Description
Hi !
Using the current Ti SDK GA 7.1.0 Windows applications do not recognize widths nor heights set as pixels. Also the fonts seem to be hardcoded to DIP since they don't change when specifying "18px" as a value. See attached app folder of an alloy application that has 4 boxes, each with a different unit (px, dip, dp and pt)
*Test Project*:
[^app.zip]
Our application requires us to have a 1920x1400 canvas to display all the elements needed. However if the user has a screen with 2736x1824 @ 200%, the actual dip that we can use are 1368x912
The device is a surface 4 pro.
Attachments
File | Date | Size |
app.zip | 2018-04-24T14:37:21.000+0000 | 22754 |
[~kiguchi] is there any update on the investigation?
[~vvazquezmontero] I fixed font size issue (TIMOB-25989) which is ready for code review. I and [~aislam] can't reproduce "
Windows applications do not recognize widths nor heights set as pixels
" issue. We might want to get more information on that, maybe screenshot (expected & actual) from customer would be appreciated.[~kiguchi] thank you. I had to check as the emailed about this being high priority. I will ask them for screen shots of this behavior
A way to reproduce this is to run the application in a high density screen (for example a Surface 4) Settings of the surface 4: 2736x1824 @ 200% (these are the recommended settings) create an application and use the width as 2000px (not DIP) The content should fit in the screen since the amount of physical pixels is higher than the screen size. Current result: The view does not fill the screen since Titanium does not recognize px, but continues to use DIP. Customer don't think screenshots will help here since there is no way to show that the proper scaling is not being done. However, the steps above should be detailed enough to figure the issue out. If you run the sample application that also helps, 100 DIP is not the same as 100 PX and Titanium is rendering them the same. That's a better example.
[~aislam] Thank you for the information, I think I understand the use cases. So this is interesting question because what Microsoft describes "pixels" is *_effective pixels_*, not actual physical pixels. Effective pixels (epx) are a virtual unit of measurement, and they're used to express layout dimensions and spacing, independent of screen density. (See [Introduction to UWP app design](https://docs.microsoft.com/en-us/windows/uwp/design/basics/design-and-ui-intro) for details). So when Microsoft uses the term "pixels" _it doesn't mean actual physical pixels_ and that's why Titanium is using this effective pixels when you use "px" unit specifier. I would think Windows UWP app should be designed based on this effective pixels because that's what platform recommends, but I also think that we could have "_actual physical pixels_" support in any way. I don't think it is a good idea to change the meaning of "px" that is currently used as "effective pixels" on Windows now because it introduces huge breaking change. Maybe we might want to introduce new unit specifier that describes actual physical pixels which is specially designed for Windows, let say
"ppx"
(physical pixels)?{quote} 100 DIP is not the same as 100 PX and Titanium is rendering them the same {quote} I was not able to reproduce it. Test code:
Here's a workaround idea to deal with actual physical pixels; You might already know that you can use
Ti.Platform.displayCaps.logicalDensityFactor
to calculate physical pixels from effective pixels.As we have a workaround to get size of physical pixels (see above), can we close this ticket with this workaround? Or do we still want to add new unit specifier (ppx?) to enable sizing with physical pixels?
Just in case FYI, unit specifier support for
Font.fontSize
(px, pt, dp, dip) is done by TIMOB-25989, and scheduled to be available as of 7.3.0.https://github.com/appcelerator/titanium_mobile_windows/pull/1252
Physical pixels support is now available on the nightly build, checkout the sdk
7.4.0.v20180609133753
.Now new unit specifier
ppx
is added to support layout with physical pixels. Easiest way to enable it is to specifyppx
forti.ui.defaultunit
intiapp.xml
. Check out the example in https://github.com/appcelerator/titanium_mobile_windows/pull/1252 for details.I assume this ticket can be closed along with TIMOB-26072. Feel free to reopen if that's not the case.