{"action":"created","issue":{"url":"https://api.github.com/repos/godotengine/godot/issues/21791","repository_url":"https://api.github.com/repos/godotengine/godot","labels_url":"https://api.github.com/repos/godotengine/godot/issues/21791/labels{/name}","comments_url":"https://api.github.com/repos/godotengine/godot/issues/21791/comments","events_url":"https://api.github.com/repos/godotengine/godot/issues/21791/events","html_url":"https://github.com/godotengine/godot/pull/21791","id":357527941,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzNTE5MjYy","number":21791,"title":"BiDi and shaping support for Font::draw/Font::get_string_size","user":{"login":"bruvzg","id":7645683,"node_id":"MDQ6VXNlcjc2NDU2ODM=","avatar_url":"https://avatars0.githubusercontent.com/u/7645683?v=4","gravatar_id":"","url":"https://api.github.com/users/bruvzg","html_url":"https://github.com/bruvzg","followers_url":"https://api.github.com/users/bruvzg/followers","following_url":"https://api.github.com/users/bruvzg/following{/other_user}","gists_url":"https://api.github.com/users/bruvzg/gists{/gist_id}","starred_url":"https://api.github.com/users/bruvzg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruvzg/subscriptions","organizations_url":"https://api.github.com/users/bruvzg/orgs","repos_url":"https://api.github.com/users/bruvzg/repos","events_url":"https://api.github.com/users/bruvzg/events{/privacy}","received_events_url":"https://api.github.com/users/bruvzg/received_events","type":"User","site_admin":false},"labels":[{"id":73330068,"node_id":"MDU6TGFiZWw3MzMzMDA2OA==","url":"https://api.github.com/repos/godotengine/godot/labels/feature%20proposal","name":"feature proposal","color":"1144ff","default":false},{"id":279097966,"node_id":"MDU6TGFiZWwyNzkwOTc5NjY=","url":"https://api.github.com/repos/godotengine/godot/labels/topic:core","name":"topic:core","color":"ffdd44","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/godotengine/godot/milestones/7","html_url":"https://github.com/godotengine/godot/milestone/7","labels_url":"https://api.github.com/repos/godotengine/godot/milestones/7/labels","id":2529217,"node_id":"MDk6TWlsZXN0b25lMjUyOTIxNw==","number":7,"title":"3.1","description":"","creator":{"login":"akien-mga","id":4701338,"node_id":"MDQ6VXNlcjQ3MDEzMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/4701338?v=4","gravatar_id":"","url":"https://api.github.com/users/akien-mga","html_url":"https://github.com/akien-mga","followers_url":"https://api.github.com/users/akien-mga/followers","following_url":"https://api.github.com/users/akien-mga/following{/other_user}","gists_url":"https://api.github.com/users/akien-mga/gists{/gist_id}","starred_url":"https://api.github.com/users/akien-mga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akien-mga/subscriptions","organizations_url":"https://api.github.com/users/akien-mga/orgs","repos_url":"https://api.github.com/users/akien-mga/repos","events_url":"https://api.github.com/users/akien-mga/events{/privacy}","received_events_url":"https://api.github.com/users/akien-mga/received_events","type":"User","site_admin":false},"open_issues":920,"closed_issues":3579,"state":"open","created_at":"2017-05-18T13:33:56Z","updated_at":"2018-09-27T10:22:33Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2018-09-06T07:25:50Z","updated_at":"2018-09-27T10:28:40Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/godotengine/godot/pulls/21791","html_url":"https://github.com/godotengine/godot/pull/21791","diff_url":"https://github.com/godotengine/godot/pull/21791.diff","patch_url":"https://github.com/godotengine/godot/pull/21791.patch"},"body":"Updates `Font::draw`, `Font::draw_halign`, `Font::get_string_size` to support bi-directional text and complex scripts using [ICU](http://site.icu-project.org/) and [HarfBuzz](https://www.freedesktop.org/wiki/Software/HarfBuzz/) libraries.\r\nAdds `Font::draw_paragraph`, `Font::draw_rich_paragraph` and some helper function for input.\r\n\r\n<details>\r\n<summary>\r\n:small_blue_diamond: Third-party libraries\r\n</summary>\r\n<br/>\r\n\r\n- [HarfBuzz](https://www.freedesktop.org/wiki/Software/HarfBuzz/) (full library except non-relevant font backends (CoreText, Uniscribe) and built-in UCDN), 1.8.8, Old-MIT\r\n- [ICU4C](http://site.icu-project.org/) (\"common\" library part and built-in unicode base data), 62.1, Unicode License\r\n</details>\r\n\r\n<details>\r\n<summary>\r\n:small_orange_diamond: Additional functions implemented\r\n</summary>\r\n<br/>\r\n\r\n```\r\nbool Font::shape_string(Font::TextDirection p_base_direction, const String &p_string, /*out*/ Font::Line &p_line, /*out*/ Font::ShapingContext *p_context = nullptr) const;\r\n```\r\nBiDi reorders and shapes input plain string.\r\nReturns `Line` containing `Vector` of grapheme clusters in visual order and line metrics. And optional intermediate shaping data required for line breaking and justification.\r\n\r\n```\r\nbool Font::shape_spans(Font::TextDirection p_base_direction, const Vector<Ref<TextSpan> > &p_spans, /*out*/ Font::Line &p_line, /*out*/ Font::ShapingContext *p_context = nullptr) const;\r\n```\r\nBiDi reorders and shapes input Vector of spans.\r\nReturns `Line` containing `Vector` of grapheme clusters in visual order and line metrics. And optional intermediate shaping data required for line breaking and justification.\r\n\r\n```\r\nbool Font::break_lines(const Font::ShapingContext *p_context, const Font::Line &p_line, float p_width, Font::TextBreak p_flags, const String &p_lang, /*out*/ Vector<Font::Line> &p_lines) const;\r\n```\r\nBreaks with or without ICU break iterator data.\r\nReturns `Vector` of `Line`s\r\n\r\n```\r\nbool Font::justify_line(const Font::ShapingContext *p_context, float p_width, Font::TextJustification p_flags, const String &p_lang, /*out*/ Font::Line &p_line) const;\r\n```\r\nExtends line to specified using kashidas and whitespace elongation.\r\n\r\n```\r\nVector2 Font::draw_cluster(RID p_canvas_item, const Point2 &p_pos, const Font::Cluster &p_cluster, const Color &p_modulate = Color(1, 1, 1), bool p_outline = false) const;\r\n```\r\nDraws single grapheme cluster returned be `shape_string`.\r\nReturns advance.\r\n\r\n```\r\nVector<float> Font::get_cursor_positions(const Font::Line &p_line, int p_position) const;\r\n```\r\nHelper for drawing cursor.\r\nReturns `Vector` of cursor X offsets.\r\n\r\n```\r\nVector<Vector2> Font::get_selection_ranges(const Font::Line &p_line, int p_start, int p_end) const;\r\n```\r\nHelper for drawing highlight/selection rectangles.\r\nReturns `Vector` of selection elements in `Vector2(X offset, width)` format.\r\n</details>\r\n\r\n<details>\r\n<summary>\r\n:small_orange_diamond: Updates\r\n</summary>\r\n<br/>\r\n\r\n7 Sep 2018 - Fixed build for ARMv7 Linux, added glyph offsets to `get_string_size` calculation.\r\n27 Sep 2018 - Added multiline and rich text shaping APIs.\r\n</details>\r\n<br/>\r\n\r\nRelated:\r\n#10546, #3081, #9961, #982\r\n"},"comment":{"url":"https://api.github.com/repos/godotengine/godot/issues/comments/425040469","html_url":"https://github.com/godotengine/godot/pull/21791#issuecomment-425040469","issue_url":"https://api.github.com/repos/godotengine/godot/issues/21791","id":425040469,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTA0MDQ2OQ==","user":{"login":"bruvzg","id":7645683,"node_id":"MDQ6VXNlcjc2NDU2ODM=","avatar_url":"https://avatars0.githubusercontent.com/u/7645683?v=4","gravatar_id":"","url":"https://api.github.com/users/bruvzg","html_url":"https://github.com/bruvzg","followers_url":"https://api.github.com/users/bruvzg/followers","following_url":"https://api.github.com/users/bruvzg/following{/other_user}","gists_url":"https://api.github.com/users/bruvzg/gists{/gist_id}","starred_url":"https://api.github.com/users/bruvzg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruvzg/subscriptions","organizations_url":"https://api.github.com/users/bruvzg/orgs","repos_url":"https://api.github.com/users/bruvzg/repos","events_url":"https://api.github.com/users/bruvzg/events{/privacy}","received_events_url":"https://api.github.com/users/bruvzg/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T10:28:40Z","updated_at":"2018-09-27T10:28:40Z","author_association":"CONTRIBUTOR","body":"> How do you want to continue from here? I can imagine Label and RichTextlabel will need more complex code.\r\n\r\nI have added separate functions to break lines and justify for Label, and separate `shape_spans` for RichText. But didn't do anything to controls itself yet.\r\n\r\n> Also, one thing I was never too clear about is how big is ICU. I suppose in the range of <1mb it could be compiled in with the option to compile out. If larger, it could be built-in for the editor, but loaded via gdnative on exported projects (or optionally compiled in on an export template).\r\n\r\nCurrently total size impact of HarfBuzz and ICU on macOS release export template without LTO is 1.42 MB, some parts of ICU probably could be removed.\r\n\r\nICU break iterator data is about 6 MB for all languages, full data is 26MB, but it is optional (only used for breaking lines and justification of some languages) and can be loaded as resource when needed (Can be set in `application/config/icudata` project setting). Also full ICU distribution includes tool to customize data file.\r\n\r\nWith ICU data:\r\n![screenshot 2018-09-27 at 12 39 11](https://user-images.githubusercontent.com/7645683/46137851-22663d80-c253-11e8-9024-f8abdf8dd017.png)\r\n\r\nWithout ICU data:\r\n![screenshot 2018-09-27 at 12 40 02](https://user-images.githubusercontent.com/7645683/46137867-2d20d280-c253-11e8-80fc-4819d5f1379c.png)\r\n\r\n> I don't see any LGPL text in src/hb-graphite2.{cc,h}, it has the same copyright header as HarfBuzz.\r\n\r\nI didn't included actual library (`libgraphite2`) code itself, since it's LGPL in most cases lib should be linked dynamically if someone need it.\r\n\r\nNot sure how to handle this best, graphite won't be useful for most users, it's only used for rare languages and require special smart fonts.\r\n\r\n\r\n"}}
{"actor":{"display_login":"bruvzg"}}