-
Notifications
You must be signed in to change notification settings - Fork 112
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
Refactor #206
Conversation
Ah, it's just clicked for me that "scrolling" in cosmic text is supposed to be understood in the context of something like an editor where you have a fixed-sized area (not dependent on the content) and you can approximate scroll height without shaping by counting newlines. It previously hadn't made any sense to me why you'd only want to shape until scroll, or why cosmic text was involved with scrolling at all. Somewhat relatedly to this, I've been thinking about what it would take to implement support for CSS floats on top of cosmic-text (on the assumption that cosmic-text would be unlikely to want to support them itself). And my conclusion so far is that it would require the following:
This would allow yielding at the locations of floated content, running some external logic to insert a new excluded area and move placed text runs so that they do not overlap this area, and then resuming text layout from that point. |
- Scroll is identified by line index and layout index, instead of just layout index - Shaping has the option to prune, where caches outside of the scroll view are cleared - Syntax editor no longer requires layout of all lines, only of lines inside scroll - BufferLine has a metadata field that can be used by other abstractions to know when text was changed
A combination of some ideas: * Try all Monospace fonts before giving up. * Relax exact weight restriction on font matching when trying Monospace fall-back. Try smaller weights if needed. * Make the fall-back try order weight-offset aware, AND script-aware. * And finally, add the option to adjust the font size of glyphs using fall-back Monospace fonts, so the width of them matches the default font width. For my use-case, the current fall-back attempt always fails with Arabic script. And none of the Arabic-supporting Monospace fonts in my system also support medium weight. So, if my default font is set to medium weight, script-aware fall-back alone will still not work. Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
Includes various performance improvements, refactor of cursor motion so it can be done outside of Editor, refactoring of scroll so that previous lines do not have to be shaped, and the ability to prune caches to reduce memory usage.
The most important change is to allow shaping parts of a buffer, by changing scroll to include both an index in Buffer::lines and the layout line. This lets only the part currently within the scrolled view of the buffer to be shaped and laid out. This greatly improves performance when scrolling as it does not have to shape and lay out lines that were never shown.
The shaping functions for Buffer and Editor now take a
prune
parameter, which when set to true, will drop the shaping and layout information of all lines outside of the scrolled view. This greatly decreases memory usage at the cost of reshaping when scrolling.