-
Notifications
You must be signed in to change notification settings - Fork 61
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
Support basic text/glyph rendering #25
Comments
Doing some research previously I found that rendering freetype glyphs is not enough for correct text rendering; you to use Harfbuzz for shaping Unicode code point sequences, which gives positioned glyphs from the font including chains of accents. Harfbuzz is the only complete open source implementation of this and almost everything uses it. I don't know if freetype-py uses Harfbuzz itself, but there are Python bindings for Harfbuzz available. |
Considering adding a simple bitmapped monospaced text rendere using veramono just so we have something for now. |
After ManimCommunity/ManimPango#28 it should be possible to use ManimPango :) |
Yep! That would be fun to try out. After this is done :) |
If I may join this conversation, does text rendering have to be a feature of moderngl? Would user code be able to alternatively use any particular other (python) library to draw text into a bitmap, then embed it in a texture provided to moderngl for actual rendering? or will that fall short of handling all the concerns inherent to getting clean text on a display? |
Text rendering will never be a part of moderngl. You can of course use any library you want to implement this yourself. This repository is not moderngl, but moderngl-window. it's a windowing and utility library for moderngl. Making a good text renderer in moderngl would have the same challenges as any other library or language. I did already make a bitmapped text renderer and the plan was at least to use freetype-py to get something started. It would use the (incomplete) texture atlas in the master branch (or a specific variant for glyphs) |
Thanks for commenting and I guess I had missed the most related thread in moderngl which was probably moderngl/moderngl#203. I guess you mean that perhaps (or at most) moderngl would go one step in the direction of enabling better text rendering performance by implementing a texture atlas, which would allow user code to choose a font library such as freetype-py and throw its outputs into the atlas. And that one can currently, without such a feature added in moderngl, and at the cost of (especially in dynamic scenes) incurring less than optimal performance, cast fonts rendered with other libraries, into a plain moderngl texture if they are okay with having less optimal performance. And that this all without something like harfbuzz, would probably work in a visually correct, or in a visually pleasing way, only for orthographically feature-poor languages like English and not for many/most other of the world's languages that have character adjoining rules and/or accents that need to be laid out in specific orders from their unicode representations. Maybe I'm a bit behind on rendering pipelines and architectures though, so I may well suffice with what I learned from your earlier comment. |
Just wanted to comment in this thread that to get towards state of the art font rendering you need harfbuzz, sure, but you should be looking towards something like msdf-atlas-gen to generate the atlases. |
It would be nice to support basic text rendering. I already have a very simple version in demosys-py that could be ported over and possibly improved: https://github.com/Contraz/demosys-py/tree/master/demosys/effects/text
Right now it's just using a texture generated with
freetype-py
loaded as aTextureArray
.This part is pretty interesting:
This means we could provide cross platform support for generating text on the fly in moderngl_window. Still it should probably be an optional dependency.
https://github.com/rougier/freetype-py
The text was updated successfully, but these errors were encountered: