{ "id": "142094", "key": "TIMOB-18291", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "2014-12-26T20:22:27.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "2019-cl" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2019-03-04T21:51:08.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h6.Feature Request\r\nCreate a font form from file which is really required to load the dynamic font downloaded from our server or at least if the mCustomTypeFaces variable is declared as public.\r\n\r\nh6.Android API\r\nCreate a new typeface from the specified font file.\r\nhttp://developer.android.com/reference/android/graphics/Typeface.html#createFromFile(java.lang.String)\r\n\r\nh6.Use Case\r\nOur requirement is to download the fonts (TTF) files form server and put them inside app directory, then use it. So if we like to change the fonts tomorrow after app release, we don't have to make a new release. ", "attachment": [], "flagged": false, "summary": "Android: Feature Request to Expose Typeface.createFromFile to dynamically include the fonts", "creator": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "338845", "author": { "name": "mano.mykingdom", "key": "mano.mykingdom", "displayName": "Manoj Kumar", "active": true, "timeZone": "Asia/Kolkata" }, "body": "It is doable on iOS too - http://stackoverflow.com/questions/14048549/how-to-dynamically-load-a-font-under-ios-for-real", "updateAuthor": { "name": "mano.mykingdom", "key": "mano.mykingdom", "displayName": "Manoj Kumar", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2015-01-13T07:22:57.000+0000", "updated": "2015-01-13T07:22:57.000+0000" }, { "id": "433846", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I see a much larger issue here.\r\n\r\nCurrently, Titanium only supports loading fonts by \"family name\". But loading by font family name is not portable between different platforms (ie: Android, iOS, Windows). Even from the same font file. In fact, our sample code on the following guide shows this exact problem and how to deal with it...\r\nhttp://docs.appcelerator.com/platform/latest/#!/guide/Custom_Fonts\r\n\r\nAlso, it's a bit of a guessing game to figure out which name to load per platform, which can cause tech-support issues. Tt can take several builds of guessing at the name to figure it out (very inconvenient and tedious). The following guide indicates this exact problem...\r\nhttp://docs.appcelerator.com/platform/latest/#!/guide/Custom_Fonts-section-src-29004935_safe-id-Q3VzdG9tRm9udHMtRmluZGluZ2Fmb250J3NQb3N0U2NyaXB0bmFtZQ\r\n\r\nThe best and most portable solution is to offer the ability to load fonts by file name (just as easy as loading image files; no guide required). This should be favored over loading them by family name due to the issues mentioned above. So, I recommend that our \"font{}\" dictionary also support a \"fontFilePath\" field. Titanium should then select the first font found within the font file, but typically TTF and OTF font files only contain one font within them. If there are multiple fonts contained in the file, then the \"fontFamilyName\" can be used to select it.\r\n\r\n{code:javascript}\r\nTi.UI.createLabel(\r\n{\r\n\ttext: \"Hello World\",\r\n\tfont:\r\n\t{\r\n\t\tsize: 20,\r\n\t\tfontFilePath: \"/assets/fonts/MyCustomFont.ttf\",\r\n\t},\r\n});\r\n{code}\r\n\r\nI think a separate JIRA case should be written for the above.\r\n\r\n[~hknoechel], [~kiguchi], what do you think?\r\n(I've done the above in a previous SDK I used to work on and found that this method worked best.)\r\n\r\nAlso, [~kiguchi], we may need to double check if there is a WinRT API for fetching family names within a font file. Back when I worked on Windows Phone 8.0 Silverlight, there was no API to do this and I had to load a font by \"#\", where the \"\" part was a required field. Is there now a WinRT API for doing this?", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-01-30T19:11:53.000+0000", "updated": "2018-01-31T01:19:24.000+0000" }, { "id": "433862", "author": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "body": "I would think that we might want to use {{path}} instead of {{fontFilePath}}, it may sound a bit redundant.\r\n\r\n{code:javascript}\r\nTi.UI.createLabel(\r\n{\r\n\ttext: \"Hello World\",\r\n\tfont:\r\n\t{\r\n\t\tsize: 20,\r\n\t\tpath: \"/assets/fonts/MyCustomFont.ttf\",\r\n\t},\r\n});\r\n{code}\r\n\r\nOr, we could follow how Microsoft does it...On Windows, you can use {{\\[FontFilePath]#\\[FontName]}} format for {{fontFamily}} property like below. (TIMOB-24299)\r\n\r\n{code:javascript}\r\nTi.UI.createLabel({\r\n text: 'Hello World, Bold',\r\n font: {\r\n fontSize: 36,\r\n fontFamily: 'segoeuib.ttf#Segoe UI 8'\r\n }\r\n});\r\n{code}\r\n\r\nMaybe we could introduce same format for {{fontFamily}} on other platforms?", "updateAuthor": { "name": "kiguchi", "key": "kota", "displayName": "Kota Iguchi", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-01-31T00:25:14.000+0000", "updated": "2018-01-31T00:25:14.000+0000" }, { "id": "433863", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~kiguchi], thanks for your feedback.\r\n\r\nThe advantage of having a separate font \"path\" field is so that it can also be assigned a file object returned by our Ti.Filesystem API. We currently have a customer who is interested in loading downloaded fonts and this would enable them to do so.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-01-31T01:22:14.000+0000", "updated": "2018-01-31T01:22:14.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }