{"action":"created","comment":{"url":"https://api.github.com/repos/akashic-games/akashic-label/pulls/comments/109614790","pull_request_review_id":30726491,"id":109614790,"diff_hunk":"@@ -619,4 +621,143 @@ describe(\"test Label\", function() {\n \n \t});\n \n+\tit(\"widthAutoAdjust - options\", function(){\n+\t\tvar createLabel = function(text){\n+\t\t\tvar mlabel = new Label({\n+\t\t\t\tscene: runtime.scene,\n+\t\t\t\ttext: text,\n+\t\t\t\ttextAlign :  g.TextAlign.Left,\n+\t\t\t\tfont: bmpfont,\n+\t\t\t\tfontSize: 10,\n+\t\t\t\twidth: 105,\n+\t\t\t\tlineBreak: true,\n+\t\t\t\twidthAutoAdjust: true\n+\t\t\t});\n+\t\t\treturn mlabel;\n+\t\t};\n+\t\tvar label = createLabel(\"thefoxisjumpingoverthelazydog\");\n+\t\texpect(label.width).toBe(100); // 105以下かつfontSize(10)の倍数の値\n+\t\texpect(label._lineBreakWidth).toBe(105);\n+\t\texpect(label._lines.length).toBe(3);\n+\n+\t\tlabel.text = \"thefox\";\n+\t\tlabel.invalidate();\n+\t\texpect(label.width).toBe(60); // text幅に応じて調整される\n+\t\texpect(label._lineBreakWidth).toBe(105); // 変化しない\n+\t\texpect(label._lines.length).toBe(1);\n+\n+\t\tlabel.text = \"thefoxisjumpingoverthelazydog\";\n+\t\tlabel.invalidate();\n+\t\texpect(label.width).toBe(100); // textを戻した場合描画内容も再現する\n+\t\texpect(label._lineBreakWidth).toBe(105);\n+\t\texpect(label._lines.length).toBe(3);\n+\n+\t\tlabel.width = 205;\n+\t\tlabel.invalidate();\n+\t\texpect(label.width).toBe(200); // 205以下かつfontSize(10)の倍数の値\n+\t\texpect(label._lineBreakWidth).toBe(205); // this.widthの更新に追従する\n+\t\texpect(label._lines.length).toBe(2);\n+\t});\n+\n+\tit(\"trimMarginTop - options\", function(){\n+\t\tvar createLabel = function(text){\n+\t\t\tvar mlabel = new Label({\n+\t\t\t\tscene: runtime.scene,\n+\t\t\t\ttext: text,\n+\t\t\t\ttextAlign :  g.TextAlign.Left,\n+\t\t\t\tfont: bmpfont,\n+\t\t\t\tfontSize: 10,\n+\t\t\t\twidth: 105,\n+\t\t\t\tlineBreak: false,\n+\t\t\t\tlineGap: 2,\n+\t\t\t\tfixLineGap: false,\n+\t\t\t\twidthAutoAdjust: true,\n+\t\t\t\ttrimMarginTop: true\n+\t\t\t});\n+\t\t\treturn mlabel;\n+\t\t};\n+\t\tvar label = createLabel(\"label\");\n+\t\tvar RubyHeightInfo;\n+\t\tvar state = {\n+\t\t\tresultLines: [],\n+\t\t\tcurrentStringDrawInfo: {\n+\t\t\t\ttext: \"\",\n+\t\t\t\twidth: 0,\n+\t\t\t\tglyphs: []\n+\t\t\t},\n+\t\t\tcurrentLineInfo: {\n+\t\t\t\tsourceText: \"\",\n+\t\t\t\twidth: 0,\n+\t\t\t\theight: 0,\n+\t\t\t\tminMinusOffsetY: 0,\n+\t\t\t\tsurface: undefined,\n+\t\t\t\tfragmentDrawInfoArray: [\n+\t\t\t\t\t{\n+\t\t\t\t\t\ttext: \"a\",\n+\t\t\t\t\t\twidth: 1,\n+\t\t\t\t\t\tglyphs: [\n+\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\tcode: 97, // a code\n+\t\t\t\t\t\t\t\tx: 0,\n+\t\t\t\t\t\t\t\ty: 0,\n+\t\t\t\t\t\t\t\twidth: 1,\n+\t\t\t\t\t\t\t\theight: 2,\n+\t\t\t\t\t\t\t\tsurface: undefined,\n+\t\t\t\t\t\t\t\toffsetX: 3,\n+\t\t\t\t\t\t\t\toffsetY: -4,\n+\t\t\t\t\t\t\t\tadvanceWidth: 5,\n+\t\t\t\t\t\t\t\tisSurfaceValid: false,\n+\t\t\t\t\t\t\t\t_atlas: undefined\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t]\n+\t\t\t\t\t}\n+\t\t\t\t]\n+\t\t\t}\n+\t\t};\n+\t\t// state と全く同じ\n+\t\tvar state2 = {","path":"spec/LabelSpec.js","position":107,"original_position":107,"commit_id":"4bb8b5685a2555cba85ca87ca0a9575608a59dff","original_commit_id":"4bb8b5685a2555cba85ca87ca0a9575608a59dff","user":{"login":"yu-ogi","id":16933898,"avatar_url":"https://avatars1.githubusercontent.com/u/16933898?v=3","gravatar_id":"","url":"https://api.github.com/users/yu-ogi","html_url":"https://github.com/yu-ogi","followers_url":"https://api.github.com/users/yu-ogi/followers","following_url":"https://api.github.com/users/yu-ogi/following{/other_user}","gists_url":"https://api.github.com/users/yu-ogi/gists{/gist_id}","starred_url":"https://api.github.com/users/yu-ogi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yu-ogi/subscriptions","organizations_url":"https://api.github.com/users/yu-ogi/orgs","repos_url":"https://api.github.com/users/yu-ogi/repos","events_url":"https://api.github.com/users/yu-ogi/events{/privacy}","received_events_url":"https://api.github.com/users/yu-ogi/received_events","type":"User","site_admin":false},"body":"(imo) オブジェクトの単純なコピーなら`JSON.parse(JSON.stringify())` や `Object.create()`を使っても良さそうです。","created_at":"2017-04-04T09:24:29Z","updated_at":"2017-04-04T09:24:29Z","html_url":"https://github.com/akashic-games/akashic-label/pull/6#discussion_r109614790","pull_request_url":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/akashic-games/akashic-label/pulls/comments/109614790"},"html":{"href":"https://github.com/akashic-games/akashic-label/pull/6#discussion_r109614790"},"pull_request":{"href":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6","id":113403791,"html_url":"https://github.com/akashic-games/akashic-label/pull/6","diff_url":"https://github.com/akashic-games/akashic-label/pull/6.diff","patch_url":"https://github.com/akashic-games/akashic-label/pull/6.patch","issue_url":"https://api.github.com/repos/akashic-games/akashic-label/issues/6","number":6,"state":"open","locked":false,"title":"add fixMarginTop option","user":{"login":"kamakiri01","id":3122541,"avatar_url":"https://avatars1.githubusercontent.com/u/3122541?v=3","gravatar_id":"","url":"https://api.github.com/users/kamakiri01","html_url":"https://github.com/kamakiri01","followers_url":"https://api.github.com/users/kamakiri01/followers","following_url":"https://api.github.com/users/kamakiri01/following{/other_user}","gists_url":"https://api.github.com/users/kamakiri01/gists{/gist_id}","starred_url":"https://api.github.com/users/kamakiri01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamakiri01/subscriptions","organizations_url":"https://api.github.com/users/kamakiri01/orgs","repos_url":"https://api.github.com/users/kamakiri01/repos","events_url":"https://api.github.com/users/kamakiri01/events{/privacy}","received_events_url":"https://api.github.com/users/kamakiri01/received_events","type":"User","site_admin":false},"body":"## このpull requestが解決する内容\r\n\r\nコンストラクタ引数に `fixMarginTop?: boolean` を追加します。\r\nこのオプションを有効にした場合、 本文およびルビの文字は上端の余白を確保せずに描画されます。\r\n\r\n元々 akashic-engine のフォントには上下に余白があり、その幅は文字によって異なります。\r\nまた、 `g.DyanmicFont` を有効にした場合、フォントはコンテンツの動作環境に依存するため、コンテンツは余白の正確な値を事前に知ることができません（この問題は `g.BitmapFont` を利用することでも解決できます）。\r\nこのため、文字描画の縦方向センタリングを正確に行うことができませんでした。\r\n\r\nこのオプションを有効にした場合、 akashic-label のインスタンスは描画に不要な余白を持たなくなるため、コンテンツはインスタンスの height メンバを参照して縦方向の描画位置を調整できます。\r\n\r\n## 実行例\r\n\r\n以下のスクリーンショットは、左側がfixMarginTopを適用したもの、右側が従来のものです。\r\n<img src=\"https://cloud.githubusercontent.com/assets/3122541/24542328/33f01942-1636-11e7-9e12-a1db7dc4a605.png\" width=\"300\">\r\ny=0 `'_Akashic'`\r\ny=100 `'{\"rb\": \"Akashic\", \"rt\": \"Akashic\"}'`\r\ny=200 `'{\"rb\": \"Akashic\", \"rt\": \"あかしっく\"}\\r{\"rb\": \"Engine\", \"rt\": \"えんじん\"}'`\r\ny=400 `'_-.,'`\r\nをそれぞれ描画しています。\r\nfixMarginTopを適用したラベルは、100px刻みのグリッド線に接するようになります。\r\n\r\nこのうち、y=400のラベルは上端にまだ余白がありますが、上端に寄せすぎて `-` と `_` の区別がつかなくなることが無いよう、一般的なアルファベットの大文字に相当する高さを最低限確保しています。\r\n\r\n## 破壊的な変更を含んでいるか?\r\nなし","created_at":"2017-03-30T11:16:45Z","updated_at":"2017-04-04T09:24:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a2d90fbe314049be5df771d656299223984f47e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6/commits","review_comments_url":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6/comments","review_comment_url":"https://api.github.com/repos/akashic-games/akashic-label/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akashic-games/akashic-label/issues/6/comments","statuses_url":"https://api.github.com/repos/akashic-games/akashic-label/statuses/4bb8b5685a2555cba85ca87ca0a9575608a59dff","head":{"label":"akashic-games:issue-3","ref":"issue-3","sha":"4bb8b5685a2555cba85ca87ca0a9575608a59dff","user":{"login":"akashic-games","id":16815486,"avatar_url":"https://avatars2.githubusercontent.com/u/16815486?v=3","gravatar_id":"","url":"https://api.github.com/users/akashic-games","html_url":"https://github.com/akashic-games","followers_url":"https://api.github.com/users/akashic-games/followers","following_url":"https://api.github.com/users/akashic-games/following{/other_user}","gists_url":"https://api.github.com/users/akashic-games/gists{/gist_id}","starred_url":"https://api.github.com/users/akashic-games/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akashic-games/subscriptions","organizations_url":"https://api.github.com/users/akashic-games/orgs","repos_url":"https://api.github.com/users/akashic-games/repos","events_url":"https://api.github.com/users/akashic-games/events{/privacy}","received_events_url":"https://api.github.com/users/akashic-games/received_events","type":"Organization","site_admin":false},"repo":{"id":80603142,"name":"akashic-label","full_name":"akashic-games/akashic-label","owner":{"login":"akashic-games","id":16815486,"avatar_url":"https://avatars2.githubusercontent.com/u/16815486?v=3","gravatar_id":"","url":"https://api.github.com/users/akashic-games","html_url":"https://github.com/akashic-games","followers_url":"https://api.github.com/users/akashic-games/followers","following_url":"https://api.github.com/users/akashic-games/following{/other_user}","gists_url":"https://api.github.com/users/akashic-games/gists{/gist_id}","starred_url":"https://api.github.com/users/akashic-games/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akashic-games/subscriptions","organizations_url":"https://api.github.com/users/akashic-games/orgs","repos_url":"https://api.github.com/users/akashic-games/repos","events_url":"https://api.github.com/users/akashic-games/events{/privacy}","received_events_url":"https://api.github.com/users/akashic-games/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akashic-games/akashic-label","description":null,"fork":false,"url":"https://api.github.com/repos/akashic-games/akashic-label","forks_url":"https://api.github.com/repos/akashic-games/akashic-label/forks","keys_url":"https://api.github.com/repos/akashic-games/akashic-label/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akashic-games/akashic-label/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akashic-games/akashic-label/teams","hooks_url":"https://api.github.com/repos/akashic-games/akashic-label/hooks","issue_events_url":"https://api.github.com/repos/akashic-games/akashic-label/issues/events{/number}","events_url":"https://api.github.com/repos/akashic-games/akashic-label/events","assignees_url":"https://api.github.com/repos/akashic-games/akashic-label/assignees{/user}","branches_url":"https://api.github.com/repos/akashic-games/akashic-label/branches{/branch}","tags_url":"https://api.github.com/repos/akashic-games/akashic-label/tags","blobs_url":"https://api.github.com/repos/akashic-games/akashic-label/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akashic-games/akashic-label/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akashic-games/akashic-label/git/refs{/sha}","trees_url":"https://api.github.com/repos/akashic-games/akashic-label/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akashic-games/akashic-label/statuses/{sha}","languages_url":"https://api.github.com/repos/akashic-games/akashic-label/languages","stargazers_url":"https://api.github.com/repos/akashic-games/akashic-label/stargazers","contributors_url":"https://api.github.com/repos/akashic-games/akashic-label/contributors","subscribers_url":"https://api.github.com/repos/akashic-games/akashic-label/subscribers","subscription_url":"https://api.github.com/repos/akashic-games/akashic-label/subscription","commits_url":"https://api.github.com/repos/akashic-games/akashic-label/commits{/sha}","git_commits_url":"https://api.github.com/repos/akashic-games/akashic-label/git/commits{/sha}","comments_url":"https://api.github.com/repos/akashic-games/akashic-label/comments{/number}","issue_comment_url":"https://api.github.com/repos/akashic-games/akashic-label/issues/comments{/number}","contents_url":"https://api.github.com/repos/akashic-games/akashic-label/contents/{+path}","compare_url":"https://api.github.com/repos/akashic-games/akashic-label/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akashic-games/akashic-label/merges","archive_url":"https://api.github.com/repos/akashic-games/akashic-label/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akashic-games/akashic-label/downloads","issues_url":"https://api.github.com/repos/akashic-games/akashic-label/issues{/number}","pulls_url":"https://api.github.com/repos/akashic-games/akashic-label/pulls{/number}","milestones_url":"https://api.github.com/repos/akashic-games/akashic-label/milestones{/number}","notifications_url":"https://api.github.com/repos/akashic-games/akashic-label/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akashic-games/akashic-label/labels{/name}","releases_url":"https://api.github.com/repos/akashic-games/akashic-label/releases{/id}","deployments_url":"https://api.github.com/repos/akashic-games/akashic-label/deployments","created_at":"2017-02-01T08:53:26Z","updated_at":"2017-02-01T08:56:11Z","pushed_at":"2017-04-04T08:44:20Z","git_url":"git://github.com/akashic-games/akashic-label.git","ssh_url":"git@github.com:akashic-games/akashic-label.git","clone_url":"https://github.com/akashic-games/akashic-label.git","svn_url":"https://github.com/akashic-games/akashic-label","homepage":null,"size":426,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"akashic-games:master","ref":"master","sha":"bf79941cee842148d51dad2a75071b66965f3554","user":{"login":"akashic-games","id":16815486,"avatar_url":"https://avatars2.githubusercontent.com/u/16815486?v=3","gravatar_id":"","url":"https://api.github.com/users/akashic-games","html_url":"https://github.com/akashic-games","followers_url":"https://api.github.com/users/akashic-games/followers","following_url":"https://api.github.com/users/akashic-games/following{/other_user}","gists_url":"https://api.github.com/users/akashic-games/gists{/gist_id}","starred_url":"https://api.github.com/users/akashic-games/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akashic-games/subscriptions","organizations_url":"https://api.github.com/users/akashic-games/orgs","repos_url":"https://api.github.com/users/akashic-games/repos","events_url":"https://api.github.com/users/akashic-games/events{/privacy}","received_events_url":"https://api.github.com/users/akashic-games/received_events","type":"Organization","site_admin":false},"repo":{"id":80603142,"name":"akashic-label","full_name":"akashic-games/akashic-label","owner":{"login":"akashic-games","id":16815486,"avatar_url":"https://avatars2.githubusercontent.com/u/16815486?v=3","gravatar_id":"","url":"https://api.github.com/users/akashic-games","html_url":"https://github.com/akashic-games","followers_url":"https://api.github.com/users/akashic-games/followers","following_url":"https://api.github.com/users/akashic-games/following{/other_user}","gists_url":"https://api.github.com/users/akashic-games/gists{/gist_id}","starred_url":"https://api.github.com/users/akashic-games/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akashic-games/subscriptions","organizations_url":"https://api.github.com/users/akashic-games/orgs","repos_url":"https://api.github.com/users/akashic-games/repos","events_url":"https://api.github.com/users/akashic-games/events{/privacy}","received_events_url":"https://api.github.com/users/akashic-games/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akashic-games/akashic-label","description":null,"fork":false,"url":"https://api.github.com/repos/akashic-games/akashic-label","forks_url":"https://api.github.com/repos/akashic-games/akashic-label/forks","keys_url":"https://api.github.com/repos/akashic-games/akashic-label/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akashic-games/akashic-label/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akashic-games/akashic-label/teams","hooks_url":"https://api.github.com/repos/akashic-games/akashic-label/hooks","issue_events_url":"https://api.github.com/repos/akashic-games/akashic-label/issues/events{/number}","events_url":"https://api.github.com/repos/akashic-games/akashic-label/events","assignees_url":"https://api.github.com/repos/akashic-games/akashic-label/assignees{/user}","branches_url":"https://api.github.com/repos/akashic-games/akashic-label/branches{/branch}","tags_url":"https://api.github.com/repos/akashic-games/akashic-label/tags","blobs_url":"https://api.github.com/repos/akashic-games/akashic-label/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akashic-games/akashic-label/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akashic-games/akashic-label/git/refs{/sha}","trees_url":"https://api.github.com/repos/akashic-games/akashic-label/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akashic-games/akashic-label/statuses/{sha}","languages_url":"https://api.github.com/repos/akashic-games/akashic-label/languages","stargazers_url":"https://api.github.com/repos/akashic-games/akashic-label/stargazers","contributors_url":"https://api.github.com/repos/akashic-games/akashic-label/contributors","subscribers_url":"https://api.github.com/repos/akashic-games/akashic-label/subscribers","subscription_url":"https://api.github.com/repos/akashic-games/akashic-label/subscription","commits_url":"https://api.github.com/repos/akashic-games/akashic-label/commits{/sha}","git_commits_url":"https://api.github.com/repos/akashic-games/akashic-label/git/commits{/sha}","comments_url":"https://api.github.com/repos/akashic-games/akashic-label/comments{/number}","issue_comment_url":"https://api.github.com/repos/akashic-games/akashic-label/issues/comments{/number}","contents_url":"https://api.github.com/repos/akashic-games/akashic-label/contents/{+path}","compare_url":"https://api.github.com/repos/akashic-games/akashic-label/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akashic-games/akashic-label/merges","archive_url":"https://api.github.com/repos/akashic-games/akashic-label/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akashic-games/akashic-label/downloads","issues_url":"https://api.github.com/repos/akashic-games/akashic-label/issues{/number}","pulls_url":"https://api.github.com/repos/akashic-games/akashic-label/pulls{/number}","milestones_url":"https://api.github.com/repos/akashic-games/akashic-label/milestones{/number}","notifications_url":"https://api.github.com/repos/akashic-games/akashic-label/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akashic-games/akashic-label/labels{/name}","releases_url":"https://api.github.com/repos/akashic-games/akashic-label/releases{/id}","deployments_url":"https://api.github.com/repos/akashic-games/akashic-label/deployments","created_at":"2017-02-01T08:53:26Z","updated_at":"2017-02-01T08:56:11Z","pushed_at":"2017-04-04T08:44:20Z","git_url":"git://github.com/akashic-games/akashic-label.git","ssh_url":"git@github.com:akashic-games/akashic-label.git","clone_url":"https://github.com/akashic-games/akashic-label.git","svn_url":"https://github.com/akashic-games/akashic-label","homepage":null,"size":426,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6"},"html":{"href":"https://github.com/akashic-games/akashic-label/pull/6"},"issue":{"href":"https://api.github.com/repos/akashic-games/akashic-label/issues/6"},"comments":{"href":"https://api.github.com/repos/akashic-games/akashic-label/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/akashic-games/akashic-label/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akashic-games/akashic-label/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/akashic-games/akashic-label/statuses/4bb8b5685a2555cba85ca87ca0a9575608a59dff"}}}}
{"actor":{"display_login":"yu-ogi"}}