{"action":"created","comment":{"url":"https://api.github.com/repos/fireball-x/engine/pulls/comments/23282712","id":23282712,"diff_hunk":"@@ -0,0 +1,184 @@\n+﻿\n+var PixiBitmapFontUtil = {};\n+\n+var emptyFont = {\n+    name: \"None\",\n+    text: '',\n+    size: 0,\n+};\n+\n+function _getAlignType(align) {\n+    var alignType = \"left\";\n+    switch (align) {\n+        case 1:\n+            alignType = \"center\";\n+            break;\n+        case 2:\n+            alignType = \"right\";\n+            break;\n+        default:\n+            break;\n+    }\n+    return alignType;\n+}\n+\n+function _setStyle(target, style, hasSceneView) {\n+    if (target._renderObj) {\n+        target._renderObj.setStyle(style);\n+    }\n+    if (hasSceneView && target._renderObjInScene) {\n+        target._renderObjInScene.setStyle(style);\n+    }\n+}\n+\n+function _getNewMatrix23(child, tempMatrix) {\n+    var mat = new Fire.Matrix23();\n+    mat.a = child.scale.x;\n+    mat.b = 0;\n+    mat.c = 0;\n+    mat.d = child.scale.y;\n+    mat.tx = child.position.x;\n+    mat.ty = -child.position.y;\n+    mat.prepend(tempMatrix);\n+    mat.b = -mat.b;\n+    mat.c = -mat.c;\n+    mat.ty = Fire.Engine._curRenderContext.renderer.height - mat.ty;\n+    return mat;\n+}\n+\n+function _createTexture(target) {\n+    if (target && target.texture) {\n+        var img = new PIXI.BaseTexture(target.texture.image);\n+        var frame = new PIXI.Rectangle(target.x, target.y, Math.min(img.width - target.x, target.width), Math.min(img.height - target.y, target.height));\n+        return new PIXI.Texture(img, frame);\n+    }\n+    else {\n+        return null;\n+    }\n+}\n+\n+function _registerFont(bitmapFont) {\n+    var data = {};\n+    if (!bitmapFont) {\n+        data.font = 'None';\n+        data.size = 0;\n+        data.lineHeight = 0;\n+        data.chars = {};\n+    }\n+    else {\n+        data.font = bitmapFont.face;\n+        data.size = bitmapFont.size;\n+        data.lineHeight = bitmapFont.lineHeight;\n+        data.chars = {};\n+        for (var i = 0; i < bitmapFont.charInfos.length; i++) {\n+            var charInfo = bitmapFont.charInfos[i];\n+            var id = charInfo.id;\n+            var textureRect = new PIXI.Rectangle(\n+                Math.floor(charInfo.x),\n+                Math.floor(charInfo.y),\n+                Math.floor(charInfo.width),\n+                Math.floor(charInfo.height)\n+            );\n+            data.chars[id] = {\n+                xOffset: Math.floor(charInfo.xOffset),\n+                yOffset: Math.floor(charInfo.yOffset),\n+                xAdvance: Math.floor(charInfo.xAdvance),\n+                kerning: {},\n+                texture: PIXI.TextureCache[id] = new PIXI.Texture(_createTexture(bitmapFont), textureRect)","path":"src/bitmapfont/pixi-bitmap-font-util.js","position":87,"original_position":87,"commit_id":"53e31b58bcac22ee156ee4d45b13d523969466e2","original_commit_id":"53e31b58bcac22ee156ee4d45b13d523969466e2","user":{"login":"jareguo","id":1503156,"avatar_url":"https://avatars.githubusercontent.com/u/1503156?v=3","gravatar_id":"","url":"https://api.github.com/users/jareguo","html_url":"https://github.com/jareguo","followers_url":"https://api.github.com/users/jareguo/followers","following_url":"https://api.github.com/users/jareguo/following{/other_user}","gists_url":"https://api.github.com/users/jareguo/gists{/gist_id}","starred_url":"https://api.github.com/users/jareguo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jareguo/subscriptions","organizations_url":"https://api.github.com/users/jareguo/orgs","repos_url":"https://api.github.com/users/jareguo/repos","events_url":"https://api.github.com/users/jareguo/events{/privacy}","received_events_url":"https://api.github.com/users/jareguo/received_events","type":"User","site_admin":false},"body":"_createTexutre 已经是创建了 PIXI.Texture 了，为什么调用者还要再 new 一次 Texture ?","created_at":"2015-01-21T07:49:20Z","updated_at":"2015-01-21T07:49:20Z","html_url":"https://github.com/fireball-x/engine/pull/39#discussion_r23282712","pull_request_url":"https://api.github.com/repos/fireball-x/engine/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/fireball-x/engine/pulls/comments/23282712"},"html":{"href":"https://github.com/fireball-x/engine/pull/39#discussion_r23282712"},"pull_request":{"href":"https://api.github.com/repos/fireball-x/engine/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/fireball-x/engine/pulls/39","id":27738888,"html_url":"https://github.com/fireball-x/engine/pull/39","diff_url":"https://github.com/fireball-x/engine/pull/39.diff","patch_url":"https://github.com/fireball-x/engine/pull/39.patch","issue_url":"https://api.github.com/repos/fireball-x/engine/issues/39","number":39,"state":"open","locked":false,"title":"实现 BitmapFont 渲染功能","user":{"login":"knoxHuang","id":7564028,"avatar_url":"https://avatars.githubusercontent.com/u/7564028?v=3","gravatar_id":"","url":"https://api.github.com/users/knoxHuang","html_url":"https://github.com/knoxHuang","followers_url":"https://api.github.com/users/knoxHuang/followers","following_url":"https://api.github.com/users/knoxHuang/following{/other_user}","gists_url":"https://api.github.com/users/knoxHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxHuang/subscriptions","organizations_url":"https://api.github.com/users/knoxHuang/orgs","repos_url":"https://api.github.com/users/knoxHuang/repos","events_url":"https://api.github.com/users/knoxHuang/events{/privacy}","received_events_url":"https://api.github.com/users/knoxHuang/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-21T06:51:56Z","updated_at":"2015-01-21T07:49:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b0babfc259936ced28be6e8927f43fd81241542","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fireball-x/engine/pulls/39/commits","review_comments_url":"https://api.github.com/repos/fireball-x/engine/pulls/39/comments","review_comment_url":"https://api.github.com/repos/fireball-x/engine/pulls/comments/{number}","comments_url":"https://api.github.com/repos/fireball-x/engine/issues/39/comments","statuses_url":"https://api.github.com/repos/fireball-x/engine/statuses/53e31b58bcac22ee156ee4d45b13d523969466e2","head":{"label":"knoxHuang:master","ref":"master","sha":"53e31b58bcac22ee156ee4d45b13d523969466e2","user":{"login":"knoxHuang","id":7564028,"avatar_url":"https://avatars.githubusercontent.com/u/7564028?v=3","gravatar_id":"","url":"https://api.github.com/users/knoxHuang","html_url":"https://github.com/knoxHuang","followers_url":"https://api.github.com/users/knoxHuang/followers","following_url":"https://api.github.com/users/knoxHuang/following{/other_user}","gists_url":"https://api.github.com/users/knoxHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxHuang/subscriptions","organizations_url":"https://api.github.com/users/knoxHuang/orgs","repos_url":"https://api.github.com/users/knoxHuang/repos","events_url":"https://api.github.com/users/knoxHuang/events{/privacy}","received_events_url":"https://api.github.com/users/knoxHuang/received_events","type":"User","site_admin":false},"repo":{"id":28794247,"name":"engine","full_name":"knoxHuang/engine","owner":{"login":"knoxHuang","id":7564028,"avatar_url":"https://avatars.githubusercontent.com/u/7564028?v=3","gravatar_id":"","url":"https://api.github.com/users/knoxHuang","html_url":"https://github.com/knoxHuang","followers_url":"https://api.github.com/users/knoxHuang/followers","following_url":"https://api.github.com/users/knoxHuang/following{/other_user}","gists_url":"https://api.github.com/users/knoxHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxHuang/subscriptions","organizations_url":"https://api.github.com/users/knoxHuang/orgs","repos_url":"https://api.github.com/users/knoxHuang/repos","events_url":"https://api.github.com/users/knoxHuang/events{/privacy}","received_events_url":"https://api.github.com/users/knoxHuang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/knoxHuang/engine","description":"The fireball engine","fork":true,"url":"https://api.github.com/repos/knoxHuang/engine","forks_url":"https://api.github.com/repos/knoxHuang/engine/forks","keys_url":"https://api.github.com/repos/knoxHuang/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/knoxHuang/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/knoxHuang/engine/teams","hooks_url":"https://api.github.com/repos/knoxHuang/engine/hooks","issue_events_url":"https://api.github.com/repos/knoxHuang/engine/issues/events{/number}","events_url":"https://api.github.com/repos/knoxHuang/engine/events","assignees_url":"https://api.github.com/repos/knoxHuang/engine/assignees{/user}","branches_url":"https://api.github.com/repos/knoxHuang/engine/branches{/branch}","tags_url":"https://api.github.com/repos/knoxHuang/engine/tags","blobs_url":"https://api.github.com/repos/knoxHuang/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/knoxHuang/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/knoxHuang/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/knoxHuang/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/knoxHuang/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/knoxHuang/engine/languages","stargazers_url":"https://api.github.com/repos/knoxHuang/engine/stargazers","contributors_url":"https://api.github.com/repos/knoxHuang/engine/contributors","subscribers_url":"https://api.github.com/repos/knoxHuang/engine/subscribers","subscription_url":"https://api.github.com/repos/knoxHuang/engine/subscription","commits_url":"https://api.github.com/repos/knoxHuang/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/knoxHuang/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/knoxHuang/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/knoxHuang/engine/issues/comments/{number}","contents_url":"https://api.github.com/repos/knoxHuang/engine/contents/{+path}","compare_url":"https://api.github.com/repos/knoxHuang/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/knoxHuang/engine/merges","archive_url":"https://api.github.com/repos/knoxHuang/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/knoxHuang/engine/downloads","issues_url":"https://api.github.com/repos/knoxHuang/engine/issues{/number}","pulls_url":"https://api.github.com/repos/knoxHuang/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/knoxHuang/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/knoxHuang/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/knoxHuang/engine/labels{/name}","releases_url":"https://api.github.com/repos/knoxHuang/engine/releases{/id}","created_at":"2015-01-05T02:38:04Z","updated_at":"2015-01-21T06:51:26Z","pushed_at":"2015-01-21T06:51:26Z","git_url":"git://github.com/knoxHuang/engine.git","ssh_url":"git@github.com:knoxHuang/engine.git","clone_url":"https://github.com/knoxHuang/engine.git","svn_url":"https://github.com/knoxHuang/engine","homepage":null,"size":684,"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":"fireball-x:master","ref":"master","sha":"1f57d81b63f13147d8eb4e36a5e5b0718ea8797d","user":{"login":"fireball-x","id":6937061,"avatar_url":"https://avatars.githubusercontent.com/u/6937061?v=3","gravatar_id":"","url":"https://api.github.com/users/fireball-x","html_url":"https://github.com/fireball-x","followers_url":"https://api.github.com/users/fireball-x/followers","following_url":"https://api.github.com/users/fireball-x/following{/other_user}","gists_url":"https://api.github.com/users/fireball-x/gists{/gist_id}","starred_url":"https://api.github.com/users/fireball-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fireball-x/subscriptions","organizations_url":"https://api.github.com/users/fireball-x/orgs","repos_url":"https://api.github.com/users/fireball-x/repos","events_url":"https://api.github.com/users/fireball-x/events{/privacy}","received_events_url":"https://api.github.com/users/fireball-x/received_events","type":"Organization","site_admin":false},"repo":{"id":19685533,"name":"engine","full_name":"fireball-x/engine","owner":{"login":"fireball-x","id":6937061,"avatar_url":"https://avatars.githubusercontent.com/u/6937061?v=3","gravatar_id":"","url":"https://api.github.com/users/fireball-x","html_url":"https://github.com/fireball-x","followers_url":"https://api.github.com/users/fireball-x/followers","following_url":"https://api.github.com/users/fireball-x/following{/other_user}","gists_url":"https://api.github.com/users/fireball-x/gists{/gist_id}","starred_url":"https://api.github.com/users/fireball-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fireball-x/subscriptions","organizations_url":"https://api.github.com/users/fireball-x/orgs","repos_url":"https://api.github.com/users/fireball-x/repos","events_url":"https://api.github.com/users/fireball-x/events{/privacy}","received_events_url":"https://api.github.com/users/fireball-x/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fireball-x/engine","description":"The fireball engine","fork":false,"url":"https://api.github.com/repos/fireball-x/engine","forks_url":"https://api.github.com/repos/fireball-x/engine/forks","keys_url":"https://api.github.com/repos/fireball-x/engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fireball-x/engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fireball-x/engine/teams","hooks_url":"https://api.github.com/repos/fireball-x/engine/hooks","issue_events_url":"https://api.github.com/repos/fireball-x/engine/issues/events{/number}","events_url":"https://api.github.com/repos/fireball-x/engine/events","assignees_url":"https://api.github.com/repos/fireball-x/engine/assignees{/user}","branches_url":"https://api.github.com/repos/fireball-x/engine/branches{/branch}","tags_url":"https://api.github.com/repos/fireball-x/engine/tags","blobs_url":"https://api.github.com/repos/fireball-x/engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fireball-x/engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fireball-x/engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/fireball-x/engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fireball-x/engine/statuses/{sha}","languages_url":"https://api.github.com/repos/fireball-x/engine/languages","stargazers_url":"https://api.github.com/repos/fireball-x/engine/stargazers","contributors_url":"https://api.github.com/repos/fireball-x/engine/contributors","subscribers_url":"https://api.github.com/repos/fireball-x/engine/subscribers","subscription_url":"https://api.github.com/repos/fireball-x/engine/subscription","commits_url":"https://api.github.com/repos/fireball-x/engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/fireball-x/engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/fireball-x/engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/fireball-x/engine/issues/comments/{number}","contents_url":"https://api.github.com/repos/fireball-x/engine/contents/{+path}","compare_url":"https://api.github.com/repos/fireball-x/engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fireball-x/engine/merges","archive_url":"https://api.github.com/repos/fireball-x/engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fireball-x/engine/downloads","issues_url":"https://api.github.com/repos/fireball-x/engine/issues{/number}","pulls_url":"https://api.github.com/repos/fireball-x/engine/pulls{/number}","milestones_url":"https://api.github.com/repos/fireball-x/engine/milestones{/number}","notifications_url":"https://api.github.com/repos/fireball-x/engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fireball-x/engine/labels{/name}","releases_url":"https://api.github.com/repos/fireball-x/engine/releases{/id}","created_at":"2014-05-12T04:10:28Z","updated_at":"2015-01-20T17:31:40Z","pushed_at":"2015-01-20T17:31:38Z","git_url":"git://github.com/fireball-x/engine.git","ssh_url":"git@github.com:fireball-x/engine.git","clone_url":"https://github.com/fireball-x/engine.git","svn_url":"https://github.com/fireball-x/engine","homepage":null,"size":1549,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fireball-x/engine/pulls/39"},"html":{"href":"https://github.com/fireball-x/engine/pull/39"},"issue":{"href":"https://api.github.com/repos/fireball-x/engine/issues/39"},"comments":{"href":"https://api.github.com/repos/fireball-x/engine/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/fireball-x/engine/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/fireball-x/engine/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/fireball-x/engine/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/fireball-x/engine/statuses/53e31b58bcac22ee156ee4d45b13d523969466e2"}}}}