{"action":"created","comment":{"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments/78219329","id":78219329,"diff_hunk":"@@ -215,46 +215,91 @@ define([\n     var glyphPixelOffset = new Cartesian2();\n \n     function repositionAllGlyphs(label, resolutionScale) {\n+        \n         var glyphs = label._glyphs;\n+        var text = label._text;\n+\n         var glyph;\n         var dimensions;\n-        var totalWidth = 0;\n-        var maxHeight = 0;\n+\n+        var lineWidth = 0;\n+        var maxLineWidth = 0;\n+\n+        var maxGlyphHeight = 0;\n+        var maxGlyphDescent = 0;\n+\n+        var numberOfLines = 1;\n \n         var glyphIndex = 0;\n         var glyphLength = glyphs.length;\n         for (glyphIndex = 0; glyphIndex < glyphLength; ++glyphIndex) {\n             glyph = glyphs[glyphIndex];\n             dimensions = glyph.dimensions;\n-            totalWidth += dimensions.computedWidth;\n-            maxHeight = Math.max(maxHeight, dimensions.height);\n+            \n+            lineWidth += dimensions.width;\n+            maxLineWidth = Math.max(maxLineWidth, lineWidth);\n+            maxGlyphHeight = Math.max(maxGlyphHeight, dimensions.height);\n+            maxGlyphDescent = Math.max(maxGlyphDescent, dimensions.descent);\n+\n+            if (text.charAt(glyphIndex) === '\\n') {\n+                numberOfLines += 1;\n+                lineWidth = 0;\n+            }\n         }\n \n         var scale = label._scale;\n         var horizontalOrigin = label._horizontalOrigin;\n         var widthOffset = 0;\n         if (horizontalOrigin === HorizontalOrigin.CENTER) {\n-            widthOffset -= totalWidth / 2 * scale;\n+            widthOffset -= maxLineWidth / 2 * scale;\n         } else if (horizontalOrigin === HorizontalOrigin.RIGHT) {\n-            widthOffset -= totalWidth * scale;\n+            widthOffset -= maxLineWidth * scale;\n+        }\n+\n+        var heightOffset = 0;\n+\n+\n+        var totalHeight = (maxGlyphHeight * numberOfLines) + (maxGlyphDescent * (numberOfLines-1));\n+\n+        var heightReference = label._heightReference;\n+        var verticalOrigin = (heightReference === HeightReference.NONE) ? label._verticalOrigin : VerticalOrigin.BOTTOM;\n+        if (verticalOrigin === VerticalOrigin.CENTER) {\n+            // Subtract maxGlyphDescent for backwards compatibility\n+            heightOffset += (totalHeight / 2 * scale) - maxGlyphDescent;\n+        }\n+        else if (verticalOrigin === VerticalOrigin.BOTTOM) {\n+            // Subtract maxGlyphHeight for backwards compatibility\n+            heightOffset += (totalHeight * scale) - maxGlyphHeight;\n+        }\n+        else if (verticalOrigin === VerticalOrigin.TOP) {","path":"Source/Scene/LabelCollection.js","position":66,"original_position":66,"commit_id":"1afb9a948bc1fa4b1d0a2b00dee1d0d75051c9e8","original_commit_id":"1afb9a948bc1fa4b1d0a2b00dee1d0d75051c9e8","user":{"login":"hpinkos","id":3451886,"avatar_url":"https://avatars.githubusercontent.com/u/3451886?v=3","gravatar_id":"","url":"https://api.github.com/users/hpinkos","html_url":"https://github.com/hpinkos","followers_url":"https://api.github.com/users/hpinkos/followers","following_url":"https://api.github.com/users/hpinkos/following{/other_user}","gists_url":"https://api.github.com/users/hpinkos/gists{/gist_id}","starred_url":"https://api.github.com/users/hpinkos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hpinkos/subscriptions","organizations_url":"https://api.github.com/users/hpinkos/orgs","repos_url":"https://api.github.com/users/hpinkos/repos","events_url":"https://api.github.com/users/hpinkos/events{/privacy}","received_events_url":"https://api.github.com/users/hpinkos/received_events","type":"User","site_admin":false},"body":"@dwhipps this is causing the jsHint error, because this block is empty.  You can just remove it.\r\n\r\nYou can run jsHint with `npm run jsHint`","created_at":"2016-09-09T17:39:30Z","updated_at":"2016-09-09T17:39:30Z","html_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4306#discussion_r78219329","pull_request_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306","_links":{"self":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments/78219329"},"html":{"href":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4306#discussion_r78219329"},"pull_request":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306"}}},"pull_request":{"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306","id":84683395,"html_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4306","diff_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4306.diff","patch_url":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4306.patch","issue_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4306","number":4306,"state":"open","locked":false,"title":"Added support for multiline labels using explicit newline character.","user":{"login":"dwhipps","id":2326464,"avatar_url":"https://avatars.githubusercontent.com/u/2326464?v=3","gravatar_id":"","url":"https://api.github.com/users/dwhipps","html_url":"https://github.com/dwhipps","followers_url":"https://api.github.com/users/dwhipps/followers","following_url":"https://api.github.com/users/dwhipps/following{/other_user}","gists_url":"https://api.github.com/users/dwhipps/gists{/gist_id}","starred_url":"https://api.github.com/users/dwhipps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwhipps/subscriptions","organizations_url":"https://api.github.com/users/dwhipps/orgs","repos_url":"https://api.github.com/users/dwhipps/repos","events_url":"https://api.github.com/users/dwhipps/events{/privacy}","received_events_url":"https://api.github.com/users/dwhipps/received_events","type":"User","site_admin":false},"body":"I've added support for multiline text in Labels using explicit newline characters, per this issue:\r\n\r\nhttps://github.com/AnalyticalGraphicsInc/cesium/issues/2402\r\n\r\nI revived and (very slightly) improved the code written by @andre-nunes in this pull request:\r\n\r\nhttps://github.com/AnalyticalGraphicsInc/cesium/pull/2575\r\n\r\nI've tested and ensured that single-line labels have the same positioning (i.e. this maintains backwards compatibility) ","created_at":"2016-09-09T16:55:26Z","updated_at":"2016-09-09T17:39:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a80bf737de3840ec8e6f60d080ee8e8b2e76be11","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306/commits","review_comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306/comments","review_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4306/comments","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/1afb9a948bc1fa4b1d0a2b00dee1d0d75051c9e8","head":{"label":"simcur:feature/label-newline-support","ref":"feature/label-newline-support","sha":"1afb9a948bc1fa4b1d0a2b00dee1d0d75051c9e8","user":{"login":"simcur","id":2326781,"avatar_url":"https://avatars.githubusercontent.com/u/2326781?v=3","gravatar_id":"","url":"https://api.github.com/users/simcur","html_url":"https://github.com/simcur","followers_url":"https://api.github.com/users/simcur/followers","following_url":"https://api.github.com/users/simcur/following{/other_user}","gists_url":"https://api.github.com/users/simcur/gists{/gist_id}","starred_url":"https://api.github.com/users/simcur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simcur/subscriptions","organizations_url":"https://api.github.com/users/simcur/orgs","repos_url":"https://api.github.com/users/simcur/repos","events_url":"https://api.github.com/users/simcur/events{/privacy}","received_events_url":"https://api.github.com/users/simcur/received_events","type":"Organization","site_admin":false},"repo":{"id":61139909,"name":"cesium","full_name":"simcur/cesium","owner":{"login":"simcur","id":2326781,"avatar_url":"https://avatars.githubusercontent.com/u/2326781?v=3","gravatar_id":"","url":"https://api.github.com/users/simcur","html_url":"https://github.com/simcur","followers_url":"https://api.github.com/users/simcur/followers","following_url":"https://api.github.com/users/simcur/following{/other_user}","gists_url":"https://api.github.com/users/simcur/gists{/gist_id}","starred_url":"https://api.github.com/users/simcur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simcur/subscriptions","organizations_url":"https://api.github.com/users/simcur/orgs","repos_url":"https://api.github.com/users/simcur/repos","events_url":"https://api.github.com/users/simcur/events{/privacy}","received_events_url":"https://api.github.com/users/simcur/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simcur/cesium","description":"WebGL virtual globe and map engine","fork":true,"url":"https://api.github.com/repos/simcur/cesium","forks_url":"https://api.github.com/repos/simcur/cesium/forks","keys_url":"https://api.github.com/repos/simcur/cesium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simcur/cesium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simcur/cesium/teams","hooks_url":"https://api.github.com/repos/simcur/cesium/hooks","issue_events_url":"https://api.github.com/repos/simcur/cesium/issues/events{/number}","events_url":"https://api.github.com/repos/simcur/cesium/events","assignees_url":"https://api.github.com/repos/simcur/cesium/assignees{/user}","branches_url":"https://api.github.com/repos/simcur/cesium/branches{/branch}","tags_url":"https://api.github.com/repos/simcur/cesium/tags","blobs_url":"https://api.github.com/repos/simcur/cesium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simcur/cesium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simcur/cesium/git/refs{/sha}","trees_url":"https://api.github.com/repos/simcur/cesium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simcur/cesium/statuses/{sha}","languages_url":"https://api.github.com/repos/simcur/cesium/languages","stargazers_url":"https://api.github.com/repos/simcur/cesium/stargazers","contributors_url":"https://api.github.com/repos/simcur/cesium/contributors","subscribers_url":"https://api.github.com/repos/simcur/cesium/subscribers","subscription_url":"https://api.github.com/repos/simcur/cesium/subscription","commits_url":"https://api.github.com/repos/simcur/cesium/commits{/sha}","git_commits_url":"https://api.github.com/repos/simcur/cesium/git/commits{/sha}","comments_url":"https://api.github.com/repos/simcur/cesium/comments{/number}","issue_comment_url":"https://api.github.com/repos/simcur/cesium/issues/comments{/number}","contents_url":"https://api.github.com/repos/simcur/cesium/contents/{+path}","compare_url":"https://api.github.com/repos/simcur/cesium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simcur/cesium/merges","archive_url":"https://api.github.com/repos/simcur/cesium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simcur/cesium/downloads","issues_url":"https://api.github.com/repos/simcur/cesium/issues{/number}","pulls_url":"https://api.github.com/repos/simcur/cesium/pulls{/number}","milestones_url":"https://api.github.com/repos/simcur/cesium/milestones{/number}","notifications_url":"https://api.github.com/repos/simcur/cesium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simcur/cesium/labels{/name}","releases_url":"https://api.github.com/repos/simcur/cesium/releases{/id}","deployments_url":"https://api.github.com/repos/simcur/cesium/deployments","created_at":"2016-06-14T16:49:33Z","updated_at":"2016-06-14T16:49:46Z","pushed_at":"2016-09-09T16:51:08Z","git_url":"git://github.com/simcur/cesium.git","ssh_url":"git@github.com:simcur/cesium.git","clone_url":"https://github.com/simcur/cesium.git","svn_url":"https://github.com/simcur/cesium","homepage":"cesiumjs.org","size":245940,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"AnalyticalGraphicsInc:master","ref":"master","sha":"aa7c37efc6c1c207b56dde2ff8498a90b98c7968","user":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"repo":{"id":3606738,"name":"cesium","full_name":"AnalyticalGraphicsInc/cesium","owner":{"login":"AnalyticalGraphicsInc","id":1490220,"avatar_url":"https://avatars.githubusercontent.com/u/1490220?v=3","gravatar_id":"","url":"https://api.github.com/users/AnalyticalGraphicsInc","html_url":"https://github.com/AnalyticalGraphicsInc","followers_url":"https://api.github.com/users/AnalyticalGraphicsInc/followers","following_url":"https://api.github.com/users/AnalyticalGraphicsInc/following{/other_user}","gists_url":"https://api.github.com/users/AnalyticalGraphicsInc/gists{/gist_id}","starred_url":"https://api.github.com/users/AnalyticalGraphicsInc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnalyticalGraphicsInc/subscriptions","organizations_url":"https://api.github.com/users/AnalyticalGraphicsInc/orgs","repos_url":"https://api.github.com/users/AnalyticalGraphicsInc/repos","events_url":"https://api.github.com/users/AnalyticalGraphicsInc/events{/privacy}","received_events_url":"https://api.github.com/users/AnalyticalGraphicsInc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AnalyticalGraphicsInc/cesium","description":"An open-source JavaScript library for world-class 3D globes and maps :earth_americas:","fork":false,"url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium","forks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/forks","keys_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/teams","hooks_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/hooks","issue_events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/events{/number}","events_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/events","assignees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/assignees{/user}","branches_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/branches{/branch}","tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/tags","blobs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/{sha}","languages_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/languages","stargazers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/stargazers","contributors_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/contributors","subscribers_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/subscribers","subscription_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/subscription","commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/contents/{+path}","compare_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/merges","archive_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/downloads","issues_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues{/number}","pulls_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls{/number}","milestones_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/milestones{/number}","notifications_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/labels{/name}","releases_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/releases{/id}","deployments_url":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/deployments","created_at":"2012-03-02T22:27:14Z","updated_at":"2016-09-09T17:21:43Z","pushed_at":"2016-09-09T16:55:26Z","git_url":"git://github.com/AnalyticalGraphicsInc/cesium.git","ssh_url":"git@github.com:AnalyticalGraphicsInc/cesium.git","clone_url":"https://github.com/AnalyticalGraphicsInc/cesium.git","svn_url":"https://github.com/AnalyticalGraphicsInc/cesium","homepage":"http://cesiumjs.org/","size":404114,"stargazers_count":1684,"watchers_count":1684,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":817,"mirror_url":null,"open_issues_count":462,"forks":817,"open_issues":462,"watchers":1684,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306"},"html":{"href":"https://github.com/AnalyticalGraphicsInc/cesium/pull/4306"},"issue":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4306"},"comments":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/issues/4306/comments"},"review_comments":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306/comments"},"review_comment":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/pulls/4306/commits"},"statuses":{"href":"https://api.github.com/repos/AnalyticalGraphicsInc/cesium/statuses/1afb9a948bc1fa4b1d0a2b00dee1d0d75051c9e8"}}}}
{"actor":{"display_login":"hpinkos"}}