{"action":"created","comment":{"url":"https://api.github.com/repos/tangrams/tangram-es/pulls/comments/88745117","pull_request_review_id":9286764,"id":88745117,"diff_hunk":"@@ -126,14 +132,115 @@ bool isContinuousRendering() {\n     return ptr;\n }\n \n-// No system fonts implementation (yet!)\n-std::string systemFontPath(const std::string& _name, const std::string& _weight, const std::string& _face) {\n-    return \"\";\n+unsigned char* loadUIFont(UIFont* _font, size_t* _size) {\n+\n+    CGFontRef fontRef = CGFontCreateWithFontName((CFStringRef)_font.fontName);\n+\n+    if (!fontRef) {\n+        *_size = 0;\n+        return nullptr;\n+    }\n+\n+    unsigned char* data = [CGFontConverter fontDataForCGFont:fontRef size:_size];\n+\n+    CGFontRelease(fontRef);\n+\n+    if (!data) {\n+        LOG(\"CoreGraphics font failed to decode\");\n+\n+        *_size = 0;\n+        return nullptr;\n+    }\n+\n+    return data;\n+}\n+\n+std::vector<FontSourceHandle> systemFontFallbacksHandle() {\n+    NSArray* fallbacks = [UIFont familyNames];\n+\n+    std::vector<FontSourceHandle> handles;\n+\n+    for (id fallback in fallbacks) {\n+\n+        UIFont* font = [UIFont fontWithName:fallback size:1.0];\n+\n+        size_t dataSize = 0;\n+        auto cdata = loadUIFont(font, &dataSize);\n+\n+        if (!cdata) { continue; }\n+\n+        FontSourceHandle fontSourceHandle = [cdata, dataSize](size_t* _size) -> unsigned char* {\n+            *_size = dataSize;\n+\n+            return cdata;\n+        };\n+\n+        handles.push_back(fontSourceHandle);\n+    }\n+\n+    return handles;\n }\n \n-// No system fonts fallback implementation (yet!)\n-std::string systemFontFallbackPath(int _importance, int _weightHint) {\n-    return \"\";\n+unsigned char* systemFont(const std::string& _name, const std::string& _weight, const std::string& _face, size_t* _size) {\n+\n+    static std::map<int, CGFloat> weightTraits = {\n+        {100, UIFontWeightUltraLight},\n+        {200, UIFontWeightThin},\n+        {300, UIFontWeightLight},\n+        {400, UIFontWeightRegular},\n+        {500, UIFontWeightMedium},\n+        {600, UIFontWeightSemibold},\n+        {700, UIFontWeightBold},\n+        {800, UIFontWeightHeavy},\n+        {900, UIFontWeightBlack},\n+    };\n+\n+    static std::map<std::string, UIFontDescriptorSymbolicTraits> fontTraits = {\n+        {\"italic\", UIFontDescriptorTraitItalic},\n+        {\"oblique\", UIFontDescriptorTraitItalic},\n+        {\"bold\", UIFontDescriptorTraitBold},\n+        {\"expanded\", UIFontDescriptorTraitExpanded},\n+        {\"condensed\", UIFontDescriptorTraitCondensed},\n+        {\"monospace\", UIFontDescriptorTraitMonoSpace},\n+    };\n+\n+    UIFont* font = [UIFont fontWithName:[NSString stringWithUTF8String:_name.c_str()] size:1.0];\n+\n+    if (font == nil) {\n+        // Get the default system font\n+        if (_weight.empty()) {\n+            font = [UIFont systemFontOfSize:0.0];\n+        } else {\n+            int weight = std::atoi(_weight.c_str());\n+\n+            // Default to 400 boldness\n+            weight = (weight == 0) ? 400 : weight;\n+\n+            // Map weight value to range [100..900]\n+            weight = std::min(std::max(100, (int)floor(weight / 100.0 + 0.5) * 100), 900);\n+\n+            font = [UIFont systemFontOfSize:0.0 weight:weightTraits[weight]];\n+        }\n+    }\n+\n+    if (_face != \"normal\") {\n+        UIFontDescriptorSymbolicTraits traits;\n+        UIFontDescriptor* descriptor = [font fontDescriptor];\n+\n+        auto it = fontTraits.find(_face);\n+        if (it != fontTraits.end()) {\n+            traits = it->second;\n+\n+            // Create a new descriptor with the symbolic traits\n+            descriptor = [descriptor fontDescriptorWithSymbolicTraits:traits];\n+\n+            if (descriptor != nil) {\n+                font = [UIFont fontWithDescriptor:descriptor size:0.0];","path":"ios/src/platform_ios.mm","position":136,"original_position":136,"commit_id":"7869be31720fec5ad552dd31961f2f0de82e6fdd","original_commit_id":"7869be31720fec5ad552dd31961f2f0de82e6fdd","user":{"login":"msmollin","id":1163880,"avatar_url":"https://avatars.githubusercontent.com/u/1163880?v=3","gravatar_id":"","url":"https://api.github.com/users/msmollin","html_url":"https://github.com/msmollin","followers_url":"https://api.github.com/users/msmollin/followers","following_url":"https://api.github.com/users/msmollin/following{/other_user}","gists_url":"https://api.github.com/users/msmollin/gists{/gist_id}","starred_url":"https://api.github.com/users/msmollin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msmollin/subscriptions","organizations_url":"https://api.github.com/users/msmollin/orgs","repos_url":"https://api.github.com/users/msmollin/repos","events_url":"https://api.github.com/users/msmollin/events{/privacy}","received_events_url":"https://api.github.com/users/msmollin/received_events","type":"User","site_admin":false},"body":"Also here re: 0.0","created_at":"2016-11-18T21:42:41Z","updated_at":"2016-11-18T21:45:59Z","html_url":"https://github.com/tangrams/tangram-es/pull/1092#discussion_r88745117","pull_request_url":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092","_links":{"self":{"href":"https://api.github.com/repos/tangrams/tangram-es/pulls/comments/88745117"},"html":{"href":"https://github.com/tangrams/tangram-es/pull/1092#discussion_r88745117"},"pull_request":{"href":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092"}}},"pull_request":{"url":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092","id":93869512,"html_url":"https://github.com/tangrams/tangram-es/pull/1092","diff_url":"https://github.com/tangrams/tangram-es/pull/1092.diff","patch_url":"https://github.com/tangrams/tangram-es/pull/1092.patch","issue_url":"https://api.github.com/repos/tangrams/tangram-es/issues/1092","number":1092,"state":"open","locked":false,"title":"System fonts","user":{"login":"karimnaaji","id":7061573,"avatar_url":"https://avatars.githubusercontent.com/u/7061573?v=3","gravatar_id":"","url":"https://api.github.com/users/karimnaaji","html_url":"https://github.com/karimnaaji","followers_url":"https://api.github.com/users/karimnaaji/followers","following_url":"https://api.github.com/users/karimnaaji/following{/other_user}","gists_url":"https://api.github.com/users/karimnaaji/gists{/gist_id}","starred_url":"https://api.github.com/users/karimnaaji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karimnaaji/subscriptions","organizations_url":"https://api.github.com/users/karimnaaji/orgs","repos_url":"https://api.github.com/users/karimnaaji/repos","events_url":"https://api.github.com/users/karimnaaji/events{/privacy}","received_events_url":"https://api.github.com/users/karimnaaji/received_events","type":"User","site_admin":false},"body":"- Add iOS system font interface.\r\n- Refactor how system fonts are being handled on all the platforms and simplify interface.\r\n\r\nDependent work on alfons https://github.com/hjanetzek/alfons/pull/9\r\n\r\nTo test carefully!","created_at":"2016-11-15T23:19:21Z","updated_at":"2016-11-18T21:45:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f5963e2f74e445f5149f45d7d3f2fd786f081ea","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092/commits","review_comments_url":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092/comments","review_comment_url":"https://api.github.com/repos/tangrams/tangram-es/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tangrams/tangram-es/issues/1092/comments","statuses_url":"https://api.github.com/repos/tangrams/tangram-es/statuses/7869be31720fec5ad552dd31961f2f0de82e6fdd","head":{"label":"tangrams:system-fonts","ref":"system-fonts","sha":"7869be31720fec5ad552dd31961f2f0de82e6fdd","user":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"repo":{"id":23391501,"name":"tangram-es","full_name":"tangrams/tangram-es","owner":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tangrams/tangram-es","description":"2D and 3D map renderer using OpenGL ES","fork":false,"url":"https://api.github.com/repos/tangrams/tangram-es","forks_url":"https://api.github.com/repos/tangrams/tangram-es/forks","keys_url":"https://api.github.com/repos/tangrams/tangram-es/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tangrams/tangram-es/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tangrams/tangram-es/teams","hooks_url":"https://api.github.com/repos/tangrams/tangram-es/hooks","issue_events_url":"https://api.github.com/repos/tangrams/tangram-es/issues/events{/number}","events_url":"https://api.github.com/repos/tangrams/tangram-es/events","assignees_url":"https://api.github.com/repos/tangrams/tangram-es/assignees{/user}","branches_url":"https://api.github.com/repos/tangrams/tangram-es/branches{/branch}","tags_url":"https://api.github.com/repos/tangrams/tangram-es/tags","blobs_url":"https://api.github.com/repos/tangrams/tangram-es/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tangrams/tangram-es/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tangrams/tangram-es/git/refs{/sha}","trees_url":"https://api.github.com/repos/tangrams/tangram-es/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tangrams/tangram-es/statuses/{sha}","languages_url":"https://api.github.com/repos/tangrams/tangram-es/languages","stargazers_url":"https://api.github.com/repos/tangrams/tangram-es/stargazers","contributors_url":"https://api.github.com/repos/tangrams/tangram-es/contributors","subscribers_url":"https://api.github.com/repos/tangrams/tangram-es/subscribers","subscription_url":"https://api.github.com/repos/tangrams/tangram-es/subscription","commits_url":"https://api.github.com/repos/tangrams/tangram-es/commits{/sha}","git_commits_url":"https://api.github.com/repos/tangrams/tangram-es/git/commits{/sha}","comments_url":"https://api.github.com/repos/tangrams/tangram-es/comments{/number}","issue_comment_url":"https://api.github.com/repos/tangrams/tangram-es/issues/comments{/number}","contents_url":"https://api.github.com/repos/tangrams/tangram-es/contents/{+path}","compare_url":"https://api.github.com/repos/tangrams/tangram-es/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tangrams/tangram-es/merges","archive_url":"https://api.github.com/repos/tangrams/tangram-es/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tangrams/tangram-es/downloads","issues_url":"https://api.github.com/repos/tangrams/tangram-es/issues{/number}","pulls_url":"https://api.github.com/repos/tangrams/tangram-es/pulls{/number}","milestones_url":"https://api.github.com/repos/tangrams/tangram-es/milestones{/number}","notifications_url":"https://api.github.com/repos/tangrams/tangram-es/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tangrams/tangram-es/labels{/name}","releases_url":"https://api.github.com/repos/tangrams/tangram-es/releases{/id}","deployments_url":"https://api.github.com/repos/tangrams/tangram-es/deployments","created_at":"2014-08-27T13:56:56Z","updated_at":"2016-11-18T09:37:04Z","pushed_at":"2016-11-18T15:02:57Z","git_url":"git://github.com/tangrams/tangram-es.git","ssh_url":"git@github.com:tangrams/tangram-es.git","clone_url":"https://github.com/tangrams/tangram-es.git","svn_url":"https://github.com/tangrams/tangram-es","homepage":"","size":41898,"stargazers_count":191,"watchers_count":191,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":67,"mirror_url":null,"open_issues_count":110,"forks":67,"open_issues":110,"watchers":191,"default_branch":"master"}},"base":{"label":"tangrams:master","ref":"master","sha":"0dde008a61cb36d3cf53f0173550cdca17b21aa6","user":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"repo":{"id":23391501,"name":"tangram-es","full_name":"tangrams/tangram-es","owner":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tangrams/tangram-es","description":"2D and 3D map renderer using OpenGL ES","fork":false,"url":"https://api.github.com/repos/tangrams/tangram-es","forks_url":"https://api.github.com/repos/tangrams/tangram-es/forks","keys_url":"https://api.github.com/repos/tangrams/tangram-es/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tangrams/tangram-es/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tangrams/tangram-es/teams","hooks_url":"https://api.github.com/repos/tangrams/tangram-es/hooks","issue_events_url":"https://api.github.com/repos/tangrams/tangram-es/issues/events{/number}","events_url":"https://api.github.com/repos/tangrams/tangram-es/events","assignees_url":"https://api.github.com/repos/tangrams/tangram-es/assignees{/user}","branches_url":"https://api.github.com/repos/tangrams/tangram-es/branches{/branch}","tags_url":"https://api.github.com/repos/tangrams/tangram-es/tags","blobs_url":"https://api.github.com/repos/tangrams/tangram-es/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tangrams/tangram-es/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tangrams/tangram-es/git/refs{/sha}","trees_url":"https://api.github.com/repos/tangrams/tangram-es/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tangrams/tangram-es/statuses/{sha}","languages_url":"https://api.github.com/repos/tangrams/tangram-es/languages","stargazers_url":"https://api.github.com/repos/tangrams/tangram-es/stargazers","contributors_url":"https://api.github.com/repos/tangrams/tangram-es/contributors","subscribers_url":"https://api.github.com/repos/tangrams/tangram-es/subscribers","subscription_url":"https://api.github.com/repos/tangrams/tangram-es/subscription","commits_url":"https://api.github.com/repos/tangrams/tangram-es/commits{/sha}","git_commits_url":"https://api.github.com/repos/tangrams/tangram-es/git/commits{/sha}","comments_url":"https://api.github.com/repos/tangrams/tangram-es/comments{/number}","issue_comment_url":"https://api.github.com/repos/tangrams/tangram-es/issues/comments{/number}","contents_url":"https://api.github.com/repos/tangrams/tangram-es/contents/{+path}","compare_url":"https://api.github.com/repos/tangrams/tangram-es/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tangrams/tangram-es/merges","archive_url":"https://api.github.com/repos/tangrams/tangram-es/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tangrams/tangram-es/downloads","issues_url":"https://api.github.com/repos/tangrams/tangram-es/issues{/number}","pulls_url":"https://api.github.com/repos/tangrams/tangram-es/pulls{/number}","milestones_url":"https://api.github.com/repos/tangrams/tangram-es/milestones{/number}","notifications_url":"https://api.github.com/repos/tangrams/tangram-es/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tangrams/tangram-es/labels{/name}","releases_url":"https://api.github.com/repos/tangrams/tangram-es/releases{/id}","deployments_url":"https://api.github.com/repos/tangrams/tangram-es/deployments","created_at":"2014-08-27T13:56:56Z","updated_at":"2016-11-18T09:37:04Z","pushed_at":"2016-11-18T15:02:57Z","git_url":"git://github.com/tangrams/tangram-es.git","ssh_url":"git@github.com:tangrams/tangram-es.git","clone_url":"https://github.com/tangrams/tangram-es.git","svn_url":"https://github.com/tangrams/tangram-es","homepage":"","size":41898,"stargazers_count":191,"watchers_count":191,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":67,"mirror_url":null,"open_issues_count":110,"forks":67,"open_issues":110,"watchers":191,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092"},"html":{"href":"https://github.com/tangrams/tangram-es/pull/1092"},"issue":{"href":"https://api.github.com/repos/tangrams/tangram-es/issues/1092"},"comments":{"href":"https://api.github.com/repos/tangrams/tangram-es/issues/1092/comments"},"review_comments":{"href":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092/comments"},"review_comment":{"href":"https://api.github.com/repos/tangrams/tangram-es/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tangrams/tangram-es/pulls/1092/commits"},"statuses":{"href":"https://api.github.com/repos/tangrams/tangram-es/statuses/7869be31720fec5ad552dd31961f2f0de82e6fdd"}}}}
{"actor":{"display_login":"msmollin"}}