compas-dev / compas_view2

Standalone viewer for COMPAS
https://compas.dev/compas_view2/
MIT License
6 stars 8 forks source link

Font and Style setting for Text #165

Closed ZacZhangzhuo closed 10 months ago

ZacZhangzhuo commented 1 year ago

Feature Request

COPY OF: https://forum.compas-framework.org/t/font-and-style-setting-for-text/721

As a user, I want the Text object to be customizable in font and style.

Details

image

Hope they can be improved!

petrasvestartas commented 1 year ago

Context to your problem and fonts in OpenGL

The issue with the text is that it is displayed through shader as a glyph (simple texture, more about this: https://learnopengl.com/In-Practice/Text-Rendering): https://github.com/compas-dev/compas_view2/blob/6a9d915507652e62db77372c9b55be9f00a0e8bd/src/compas_view2/objects/textobject.py#L52


How to change the font?

For now, I think you can only change the font:


Font orientation

For text orientation, you need to modify vertex shader, which means it is makes sense to have 2 shaders one for camera facing text and another for user given orientation: https://github.com/compas-dev/compas_view2/blob/main/src/compas_view2/shaders/120/text.vert In the line 15 you can see that it takes transformation matrices from python code to OpenGL. image


If you have time, I suggest to try it yourself, making shaders, is an interesting thing to learn about computer graphics. I do not know if @Licini has currently time for it :)

ZacZhangzhuo commented 1 year ago

Thanks for the very cool and detailed explanation!

Surely I am happy to look at the source code and try to modify it! I will also very look forward to the official update about it!

ZacZhangzhuo commented 10 months ago

sloved by #170