{"action":"closed","issue":{"url":"https://api.github.com/repos/faiface/pixel/issues/12","repository_url":"https://api.github.com/repos/faiface/pixel","labels_url":"https://api.github.com/repos/faiface/pixel/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/faiface/pixel/issues/12/comments","events_url":"https://api.github.com/repos/faiface/pixel/issues/12/events","html_url":"https://github.com/faiface/pixel/issues/12","id":225317362,"number":12,"title":"Add text drawing","user":{"login":"faiface","id":3924105,"avatar_url":"https://avatars3.githubusercontent.com/u/3924105?v=3","gravatar_id":"","url":"https://api.github.com/users/faiface","html_url":"https://github.com/faiface","followers_url":"https://api.github.com/users/faiface/followers","following_url":"https://api.github.com/users/faiface/following{/other_user}","gists_url":"https://api.github.com/users/faiface/gists{/gist_id}","starred_url":"https://api.github.com/users/faiface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faiface/subscriptions","organizations_url":"https://api.github.com/users/faiface/orgs","repos_url":"https://api.github.com/users/faiface/repos","events_url":"https://api.github.com/users/faiface/events{/privacy}","received_events_url":"https://api.github.com/users/faiface/received_events","type":"User","site_admin":false},"labels":[{"id":594941036,"url":"https://api.github.com/repos/faiface/pixel/labels/feature","name":"feature","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":{"login":"faiface","id":3924105,"avatar_url":"https://avatars3.githubusercontent.com/u/3924105?v=3","gravatar_id":"","url":"https://api.github.com/users/faiface","html_url":"https://github.com/faiface","followers_url":"https://api.github.com/users/faiface/followers","following_url":"https://api.github.com/users/faiface/following{/other_user}","gists_url":"https://api.github.com/users/faiface/gists{/gist_id}","starred_url":"https://api.github.com/users/faiface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faiface/subscriptions","organizations_url":"https://api.github.com/users/faiface/orgs","repos_url":"https://api.github.com/users/faiface/repos","events_url":"https://api.github.com/users/faiface/events{/privacy}","received_events_url":"https://api.github.com/users/faiface/received_events","type":"User","site_admin":false},"assignees":[{"login":"faiface","id":3924105,"avatar_url":"https://avatars3.githubusercontent.com/u/3924105?v=3","gravatar_id":"","url":"https://api.github.com/users/faiface","html_url":"https://github.com/faiface","followers_url":"https://api.github.com/users/faiface/followers","following_url":"https://api.github.com/users/faiface/following{/other_user}","gists_url":"https://api.github.com/users/faiface/gists{/gist_id}","starred_url":"https://api.github.com/users/faiface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faiface/subscriptions","organizations_url":"https://api.github.com/users/faiface/orgs","repos_url":"https://api.github.com/users/faiface/repos","events_url":"https://api.github.com/users/faiface/events{/privacy}","received_events_url":"https://api.github.com/users/faiface/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/faiface/pixel/milestones/1","html_url":"https://github.com/faiface/pixel/milestone/1","labels_url":"https://api.github.com/repos/faiface/pixel/milestones/1/labels","id":2490313,"number":1,"title":"v0.6","description":"","creator":{"login":"faiface","id":3924105,"avatar_url":"https://avatars3.githubusercontent.com/u/3924105?v=3","gravatar_id":"","url":"https://api.github.com/users/faiface","html_url":"https://github.com/faiface","followers_url":"https://api.github.com/users/faiface/followers","following_url":"https://api.github.com/users/faiface/following{/other_user}","gists_url":"https://api.github.com/users/faiface/gists{/gist_id}","starred_url":"https://api.github.com/users/faiface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faiface/subscriptions","organizations_url":"https://api.github.com/users/faiface/orgs","repos_url":"https://api.github.com/users/faiface/repos","events_url":"https://api.github.com/users/faiface/events{/privacy}","received_events_url":"https://api.github.com/users/faiface/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":3,"state":"open","created_at":"2017-04-30T09:35:23Z","updated_at":"2017-05-09T14:53:54Z","due_on":"2017-05-14T07:00:00Z","closed_at":null},"comments":20,"created_at":"2017-04-30T10:00:39Z","updated_at":"2017-05-09T14:53:54Z","closed_at":"2017-05-09T14:53:53Z","body":"Currently, Pixel doesn't support drawing text. This needs to be changed. Implementing text drawing in Go is actually way simpler than I thought it would be.\r\n\r\nFirst of all, there's an awesome package https://godoc.org/golang.org/x/image/font, which implements standard font face interface, which is well designed and very useful. Subpackages implement several font types and https://godoc.org/github.com/golang/freetype/truetype implements TrueType font loading with support of the standard font face interface. So we've got all we need.\r\n\r\nNow, the design of text drawing in Pixel.\r\n\r\nText drawing should be done in a not-yet-existing `\"github.com/faiface/pixel/text\"` package. This package should export (at least) one type: `Text`. Creating one should be done by `text.New(face)`, where `face` is a `font.Face` value. The `*Text` value returned from `New` will use that specific font face.\r\n\r\n`Text` type should implement `io.Writer` interface, so drawing text to it is as simple as `fmt.Sprintf(txt, \"hello world\")`. Printing to `Text` draws text \"to the `Text` object\". To draw the printed text to another target (such as a window, canvas, batch, ...), simply use `txt.Draw(target)`. Clearing needs to be supported too (`txt.Clear()`).\r\n\r\nDrawing text needs to be fast. There should be no problem drawing a full screen of random text using a tiny font face at 60 FPS without a performance hit. This is something that many other libraries fail to accomplish, but it's actually not very hard. It's easily achievable by caching glyphs.\r\n\r\nSo, to recap the interface.\r\n\r\n- `\"github.com/faiface/pixel/text\"`\r\n  - `New(font.Face) *Text`\r\n  - `type Text`\r\n    - `Clear()`\r\n    - `Draw(pixel.Target)`\r\n    - `Write(b []byte) (n int, err error)`\r\n\r\nThis is the basis for the interface. More methods will probably be added, such as `WriteString`, or `SetDot` (the position of the text line)."}}
{"actor":{"display_login":"faiface"}}