New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GUI] Support drawing text on canvas #1070
Conversation
Can't we just use the platform provided API to draw text? (e.g. |
Thanks! Brain fried today but I'll take a look first thing tomorrow.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! Please address the comments.
To make this feature available to users, please
- Add a submodule containing https://github.com/yuanming-hu/taichi_assets/tree/master/fonts/go
- Fix the font path:
Line 394 in 30701fc
auto ttf_path = root_dir + std::string("/assets/fonts/go/Go-Regular.ttf"); - Make sure the font file is available in release mode. See the shipping of
examples
as an example: https://github.com/taichi-dev/taichi/pull/1010/files - Add doc
Can't we just load the system default font, or compile the font into libtaichi.so? It's tricky to copytree/rmtree nested-dir like |
Problem: |
Now I just use |
How to test in release mode? |
Thanks for implementing everything here!
Loading a system font (for all platforms) can be tricky...
Please use
Usually I do cd python
python3 build.py test |
Why it needs PYPI_PWD? Wasn't it just |
Oh, my bad. Please use any value for that environment variable for now. In the future let's fix this on |
FYI it also needs
|
Maybe you have an existing v0.6.6 installation via pip? Please remove that first. |
Fixed. Now comes to:
|
taichi/taichi/llvm/llvm_context.cpp Lines 165 to 175 in 8502f82
Btw, we should avoid committing huge binary files in the repo. Could you make the font file a submodule? Also how about sticking to the font file in Thanks for working on this! |
I added https://github.com/taichi-dev/taichi_assets for storing font files, and may have other binary files in future (that's why I want the name Btw, I'll add rm -rf ~/.local/lib/python3.8/site-packages/taichi{,-0*.dist-info}/ && nc && (pushd python; PYPI_PWD=233 CXX=clang++ python build.py test; popd) after #1085. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Feel free to merge after committing the RGB conversion suggestion and adding brief documentation on this new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Some final nits. Feel free to merge after applying them.
docs/gui.rst
Outdated
.. function:: gui.text(context, pos, font_size = 15, color = 0xFFFFFF) | ||
|
||
:parameter gui: (GUI) the window object | ||
:parameter pow: (tuple of 2) the top-left point position of the fonts / texts | ||
:parameter font_size: (optional, scalar) the size of font (in height) | ||
:parameter color: (optional, RGB hex) the foreground color of text | ||
|
||
Draw a line of text on screen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. function:: gui.text(context, pos, font_size = 15, color = 0xFFFFFF) | |
:parameter gui: (GUI) the window object | |
:parameter pow: (tuple of 2) the top-left point position of the fonts / texts | |
:parameter font_size: (optional, scalar) the size of font (in height) | |
:parameter color: (optional, RGB hex) the foreground color of text | |
Draw a line of text on screen. | |
.. function:: gui.text(content, font_size = 15, color = 0xFFFFFF) | |
:parameter gui: (GUI) the GUI object | |
:parameter content: (``str``) the text to print | |
:parameter pos: (tuple of 2) the top-left anchor position of the text | |
:parameter font_size: (optional, scalar) font size (height, in pixels) | |
:parameter color: (optional, RGB hex) text foreground color | |
Draw text on the screen. |
Related issue = close #1045
[Click here for the format server]