Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8421] MobileWeb: Sizes in millimeters interpreted incorrectly

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-06-14T13:51:04.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.1.0, Sprint 2012-12 MW
ComponentsMobileWeb
Labelsparity, qe-port
ReporterArthur Evans
AssigneeBryan Hughes
Created2012-03-29T13:13:32.000+0000
Updated2012-08-08T16:24:39.000+0000

Description

When adding a view with a size specified in points (mm), the view is sized in centimeters, instead. In the following code sample, the blue and red boxes should be the same size, as on iOS. See attached screenshots.
var win1 = Titanium.UI.createWindow({  
    title:'Composite Layout Test',
    backgroundColor:'#fff',
    layout: 'vertical'
});
var l1 = Titanium.UI.createLabel({
	top: 0,
	color:'#999',
	backgroundColor: 'blue',
	text:'1in',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'1in',
	height:'1in'
});
win1.add(l1);

var l2 = Titanium.UI.createLabel({
	top: 0,
	color:'#999',
	backgroundColor: 'red',
	text:'72pt',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
        // this should be 1 inch
	width:'25.4mm',
	height:'25.4mm'
});
win1.add(l2);

var l3 = Titanium.UI.createLabel({
	top: 0,
	color:'#999',
	backgroundColor: 'green',
	text:'72 units',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:72,
	height:72
});
win1.add(l3);

win1.open();

Attachments

FileDateSize
app.js2012-06-12T17:09:40.000+00003668
ios_layout_mm.png2012-03-29T13:19:34.000+000010810
mobileweb_mm.png2012-03-29T13:19:34.000+000025584

Comments

  1. Arthur Evans 2012-03-29

    Also, centimeters appears to be unimplemented. According to the spec this should work.
  2. Bryan Hughes 2012-06-12

    Pull Request: https://github.com/appcelerator/titanium_mobile/pull/2380
  3. Bryan Hughes 2012-06-12

    BTW, it's worth noting that most browsers use 96DPI, not 72, so you're comparisons above don't all work.
  4. Lokesh Choudhary 2012-08-07

    Tested On: Titanium studio : 2.1.1.201207271312 SDK version : 2.0.3.v20120806151610 Android 4.0.4 - default ,chrome 18.0 Iphone 4.3.5 - safari mobile Mountain lion(10.8) - chrome 21.0,safari 5.1.4,firefox 14.0.1

JSON Source