{ "id": "119748", "key": "TIMOB-15619", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2013-09-10T16:01:05.000+0000", "priority": null, "labels": [ "Label", "getSize", "height", "toImage", "width" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:20.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{code}\r\nfunction labelHeight2(sOutText, daFont, iWidth, win, doImageView)\r\n{\r\n\tif (typeof sOutText === undefined || sOutText === null || sOutText == '')\r\n\t\treturn 0;\r\n\r\n\tvar daLabel = Ti.UI.createLabel(\r\n\t{\r\n\t\tfont: daFont,\r\n\t\tcolor: 'black',\r\n backgroundColor:'transparent',\r\n layout: 'vertical', \r\n height: 'auto',\r\n width: iWidth + 'dp',\r\n text: sOutText,\r\n horizontalWrap: true,\r\n textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,\r\n verticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP\r\n\t});\r\n\tif (doImageView)\r\n\t{\r\n\t var blob = daLabel.toImage();\r\n\t var iWidth = blob.width; // This value return 988 on my machine, it should be 200 or less since I limited the width of the label to 200\r\n\t Ti.API.info('labelHeight2 width ' + iWidth);\r\n\t var image = Ti.UI.createImageView({image: blob});\r\n\t win.add(image);\r\n\t}\r\n\telse\r\n\t win.add(daLabel);\r\n\tvar asize = daLabel.getSize();\r\n\tvar iHeight = asize.height; // Return 30 when rasterizing to image and 150 when rasterizing to a window (150 is the correct answer).\r\n\tTi.API.info('labelHeight2 height ' + iWidth);\r\n\r\n\treturn iHeight;\r\n}\r\n\r\nfunction doOnOpen()\r\n{\r\n\tvar s = \"Now is the time for all good cows to come to the aid of their farmers. Now is the time for all good cows to come to the aid of their farmers. Now is the time for all good cows to come to the aid of their farmers. Now is the time for all good cows to come to the aid of their farmers. Now is the time for all good cows to come to the aid of their farmers.\";\r\n\tvar iHeight = labelHeight2(s, {fontFamily: 'Helvetice Neue', fontSize: '12dp', fontWeight: 'normal'}, 200, win, false);\r\n\tiHeight = labelHeight2(s, {fontFamily: 'Helvetice Neue', fontSize: '12dp', fontWeight: 'normal'}, 200, win, true);\r\n\tiHeight = labelHeight2('Testing', {fontFamily: 'Helvetice Neue', fontSize: '12dp', fontWeight: 'normal'}, 200, win, false);\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "toImage does not honor 'width' when rasterizing a Label. Rasterizing to a window works properly.", "creator": { "name": "dspells", "key": "dspells", "displayName": "Henry David Spells III", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "dspells", "key": "dspells", "displayName": "Henry David Spells III", "active": true, "timeZone": "America/Chicago" }, "environment": "1. Application type: iOS (my tests were on iOS, I haven't tested this with Android yet).\r\n2. Titanium SDK: Titanium Command-Line Interface, CLI version 3.1.2, Titanium SDK version 3.1.2.GA\r\n3. Platform & Version: iOS 6.1\r\n4. Device: iOS simulator for iPhone\r\n5: Host OS: OS X 10.8.4\r\n6: Titanium Studio: 3.1.2.201308091617\r\n", "comment": { "comments": [ { "id": "273593", "author": { "name": "dspells", "key": "dspells", "displayName": "Henry David Spells III", "active": true, "timeZone": "America/Chicago" }, "body": "This seems to work properly on Android. This is still active in Ti SDK 3.1.3GA on iOS.", "updateAuthor": { "name": "dspells", "key": "dspells", "displayName": "Henry David Spells III", "active": true, "timeZone": "America/Chicago" }, "created": "2013-10-02T13:16:25.000+0000", "updated": "2013-10-02T14:15:18.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }