Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25986] Windows: Physical pixel as a unit in views and fonts is not working

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2018-06-21T23:18:21.000+0000
Affected Version/sRelease 7.1.0
Fix Version/sRelease 7.3.0
ComponentsWindows
Labelsn/a
ReporterAminul Islam
AssigneeKota Iguchi
Created2018-04-24T14:36:01.000+0000
Updated2018-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

FileDateSize
app.zip2018-04-24T14:37:21.000+000022754

Comments

  1. Victor Vazquez Montero 2018-04-26

    [~kiguchi] is there any update on the investigation?
  2. Kota Iguchi 2018-04-26

    [~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.
  3. Victor Vazquez Montero 2018-04-26

    [~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
  4. Aminul Islam 2018-04-30

    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.
  5. Kota Iguchi 2018-05-01

    [~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)?
  6. Kota Iguchi 2018-05-02

    {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:
       var win = Ti.UI.createWindow({
           backgroundColor: 'green',
       });
       
       var view1 = Ti.UI.createView({
           backgroundColor: 'red',
           top: 70, left: 10,
           width: '60px', height: '60px'
       });
       view1.add(Ti.UI.createLabel({ text: 'PX' }));
       
       var view2 = Ti.UI.createView({
           backgroundColor: 'red',
           top: 130, left: 10,
           width: '60dp', height: '60dp'
       });
       view2.add(Ti.UI.createLabel({ text: 'DP' }));
       
       var view3 = Ti.UI.createView({
           backgroundColor: 'red',
           top: 200, left: 10,
           width: '60dip', height: '60dip'
       });
       view3.add(Ti.UI.createLabel({ text: 'DIP' }));
       
       var view4 = Ti.UI.createView({
           backgroundColor: 'red',
           top: 270, left: 10,
           width: '60pt', height: '60pt'
       });
       view4.add(Ti.UI.createLabel({ text: 'PT' }));
       
       win.add(view1);
       win.add(view2);
       win.add(view3);
       win.add(view4);
       
       win.open();
       
  7. Kota Iguchi 2018-05-02

    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.
       var physical= effective * Ti.Platform.displayCaps.logicalDensityFactor;
       
  8. Kota Iguchi 2018-05-15

    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?
  9. Kota Iguchi 2018-05-21

    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.
  10. Kota Iguchi 2018-06-07

    https://github.com/appcelerator/titanium_mobile_windows/pull/1252
  11. Kota Iguchi 2018-06-11

    Physical pixels support is now available on the nightly build, checkout the sdk 7.4.0.v20180609133753.
            appc ti sdk install --branch master 7.4.0.v20180609133753
        
    Now new unit specifier ppx is added to support layout with physical pixels. Easiest way to enable it is to specify ppx for ti.ui.defaultunit in tiapp.xml. Check out the example in https://github.com/appcelerator/titanium_mobile_windows/pull/1252 for details.
          <property name="ti.ui.defaultunit" type="string">ppx</property>
        
  12. Kota Iguchi 2018-06-11

  13. Kota Iguchi 2018-06-21

    I assume this ticket can be closed along with TIMOB-26072. Feel free to reopen if that's not the case.
  14. Samir Mohammed 2018-07-05

JSON Source