fix initialization for :class:~.Paragraph #2014
Closed
UraniumCronorum wants to merge 5 commits intoManimCommunity:mainfrom
Closed
fix initialization for :class:~.Paragraph #2014UraniumCronorum wants to merge 5 commits intoManimCommunity:mainfrom
~.Paragraph #2014UraniumCronorum wants to merge 5 commits intoManimCommunity:mainfrom
Conversation
…Text class changes in the future
for more information, see https://pre-commit.ci
k4pran
reviewed
Sep 8, 2021
| ] | ||
| ) | ||
| char_index_counter += lines_str_list[line_no].__len__() + 1 | ||
| char_index_counter += len(Text(lines_str_list[line_no])) |
Collaborator
There was a problem hiding this comment.
Seems this is only created to get the length of the Text right? Is there a way to avoid creating this? It seems to impact performance for the opengl renderer (that already has performance issues). Same with the other places where Text is created only to check the length
k4pran
suggested changes
Sep 8, 2021
Collaborator
k4pran
left a comment
There was a problem hiding this comment.
Thank you for this fix. Tested locally and the fix works, I am concerned though with performance impacts of creating multiple Text objects to check the lengths
Member
|
This is probably fixed by this PR too. Correct me if im wrong and reopen but i will close this for now! |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview: What does this pull request change?
The current implementation of Paragraph's initialization erroneously counts whitespace when initializing internal variables, leading to line division in
self.linesandself.charsbeing off. This in turn causes unexpected behavior when attempting to set or change the alignment of those lines.This PR corrects this behavior by basing calculation of line lengths on the length of the corresponding
Textobject instead of the length of the string.Motivation and Explanation: Why and how do your changes improve the library?
Before:


After:
Links to added or changed documentation pages
Further Information and Comments
Reviewer Checklist