{ "id": "147087", "key": "AC-91", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2015-11-10T05:58:56.000+0000", "created": "2015-04-20T09:17:14.000+0000", "labels": [ "android", "attributedstring" ], "versions": [], "issuelinks": [ { "id": "47448", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "146809", "key": "TIMOB-18853", "fields": { "summary": "Android: Custom Fonts not working in Attributed Strings", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "updated": "2015-11-10T16:18:48.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Ti.UI.ATTRIBUTE_FONT with custom font family doesn't work.\r\n\r\n{code:title=TestCase}\r\nvar win = Titanium.UI.createWindow({\r\n backgroundColor: '#ddd',\r\n});\r\n\r\nwin.open();\r\n\r\nvar text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.';\r\n\r\nvar attr = Titanium.UI.createAttributedString({\r\n text: text,\r\n attributes: [\r\n // Underlines text\r\n {\r\n type: Titanium.UI.ATTRIBUTE_FONT,\r\n value: {\r\n fontFamily: \"ANY_FONT_UNDER_RESOURCES\",\r\n fontSize: 15\r\n }\r\n range: [0, 20]\r\n }\r\n ]\r\n});\r\n\r\nvar label = Titanium.UI.createLabel({\r\n left: 20,\r\n right: 20,\r\n height: Titanium.UI.SIZE,\r\n attributedString: attr\r\n});\r\n\r\nwin.add(label);\r\nAdds attributes, one by one.\r\nvar win = Titanium.UI.createWindow({\r\n backgroundColor: '#ddd',\r\n});\r\n\r\nwin.open();\r\n\r\nvar text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.';\r\n\r\nvar attr = Titanium.UI.createAttributedString({\r\n text: text\r\n});\r\n\r\n// Underlines text\r\nattr.addAttribute({\r\n type: Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE,\r\n range: [0, text.length]\r\n});\r\n\r\nvar label = Titanium.UI.createLabel({\r\n left: 20,\r\n right: 20,\r\n height: Titanium.UI.SIZE,\r\n attributedString: attr\r\n});\r\n\r\nwin.add(label);\r\n{code}\r\n\r\nThe reason could be in AttributedStringProxy.java TypefaceSpan is directly set to spannable string. \r\n\r\n{code:title=AttributedStringProxy.java}\r\nspannableText.setSpan(new TypefaceSpan(fontProperties[TiUIHelper.FONT_FAMILY_POSITION]), range[0], range[0] + range[1], Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);\r\n{code}\r\n\r\nSeems actionbar extras module handles it perfectly with extended TypefaceSpan class.\r\n\r\nhttps://github.com/ricardoalcocer/actionbarextras/blob/master/src/com/alcoapps/actionbarextras/TypefaceSpan.java", "attachment": [], "flagged": false, "summary": "Android: Custom font with attributedString doesn't work", "creator": { "name": "mano_mykingdom", "key": "mano_mykingdom", "displayName": "Manojkumar Murugesan", "active": true, "timeZone": "Asia/Kolkata" }, "subtasks": [], "reporter": { "name": "mano_mykingdom", "key": "mano_mykingdom", "displayName": "Manojkumar Murugesan", "active": true, "timeZone": "Asia/Kolkata" }, "environment": "Titanium 4.0.0-beta", "comment": { "comments": [ { "id": "350171", "author": { "name": "athorne", "key": "athorne", "displayName": "Alex Bernier", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is a dupe of AC-70, but AC-70 was just closed as unsupported. However, if you look at my last comment, you can see the current platform documentation states Android is, in fact, documented as supporting Ti.UI.ATTRIBUTE_FONT since SDK 3.6.", "updateAuthor": { "name": "athorne", "key": "athorne", "displayName": "Alex Bernier", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-04-20T21:18:44.000+0000", "updated": "2015-04-20T21:18:44.000+0000" }, { "id": "369381", "author": { "name": "jnaher", "key": "jnaher", "displayName": "Jebun Naher", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello\r\n\r\nWe couldn't reproduce this issue as a bug in our environment. Custom font with attributedString works as expected.\r\n\r\n[Screenshot|http://postimg.org/image/bec8sr3dz/]\r\n\r\n*Testing Environment:*\r\nAppcelerator Command-Line Interface, version 5.0.4\r\nAppcelerator Studio, build: 4.3.3.201510212245\r\nTi SDK Version :5.0.2.GA\r\nEmulator : Nexus 7 - 5.1.0 - API 22 - 800x1280\r\nNode.js Version :0.10.37\r\nMac OS X,Version :10.10.1\r\nJdk version : 1.7.0_80.jdk\r\n\r\n*Test Case:*\r\n{code}\r\nvar win = Titanium.UI.createWindow({\r\n\tbackgroundColor : '#ddd',\r\n});\r\nwin.open();\r\nvar text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.';\r\nvar attr = Titanium.UI.createAttributedString({\r\n\ttext : text,\r\n\tattributes : [\r\n\t// Underlines text\r\n\t{\r\n\t\ttype : Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE,\r\n\t\trange : [0, text.length]\r\n\t},\r\n\t// Sets a background color\r\n\t{\r\n\t\ttype : Titanium.UI.ATTRIBUTE_BACKGROUND_COLOR,\r\n\t\tvalue : \"red\",\r\n\t\trange : [text.indexOf('Appcelerator'), ('Appcelerator').length]\r\n\t}, {\r\n\t\ttype : Titanium.UI.ATTRIBUTE_BACKGROUND_COLOR,\r\n\t\tvalue : \"blue\",\r\n\t\trange : [text.indexOf('Titanium'), ('Titanium').length]\r\n\t}, {\r\n\t\ttype : Titanium.UI.ATTRIBUTE_BACKGROUND_COLOR,\r\n\t\tvalue : \"yellow\",\r\n\t\trange : [text.indexOf('rocks!'), ('rocks!').length]\r\n\t},\r\n\t// Sets a foreground color\r\n\t{\r\n\t\ttype : Titanium.UI.ATTRIBUTE_FOREGROUND_COLOR,\r\n\t\tvalue : \"orange\",\r\n\t\trange : [0, text.length]\r\n\t}, {\r\n\t\ttype : Titanium.UI.ATTRIBUTE_FOREGROUND_COLOR,\r\n\t\tvalue : \"black\",\r\n\t\trange : [text.indexOf('rocks!'), ('rocks!').length]\r\n}]\r\n});\r\nvar label = Titanium.UI.createLabel({\r\n\tleft : 20,\r\n\tright : 20,\r\n\tfont : {\r\n\t\tfontFamily : \"Your Custom Font Goes Here\"\r\n},\r\n\theight : Titanium.UI.SIZE,\r\n\tattributedString : attr\r\n});\r\n win.add(label);\r\n{code}\r\n\r\n*Steps to test:*\r\n1. Create a classic project.\r\n2. Inside the resource folder, create a new folder and name it fonts.\r\n3. Download a custom font and place it inside the fonts folder.\r\n4. Copy below code, specify the font name in the fontFamily attribute.\r\n5. Run the project.\r\n\r\nThanks", "updateAuthor": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2015-11-09T09:16:06.000+0000", "updated": "2015-11-10T05:58:38.000+0000" }, { "id": "369557", "author": { "name": "athorne", "key": "athorne", "displayName": "Alex Bernier", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thank you [~jnaher] for following up! Great the issue is resolved.", "updateAuthor": { "name": "athorne", "key": "athorne", "displayName": "Alex Bernier", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-11-10T16:18:48.000+0000", "updated": "2015-11-10T16:18:48.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }