-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
RFC: New Text API #2355
Comments
This seems fairly reasonable, and like a good development to me. Some comments and questions:
|
👍. Looks good, probably a dataclass representing them would be better.
Should be possible but I guess only for
The size of "hello" would depend on the
As explained above width/height would make difference only for long sentences or paragraphs I think it's better to have
|
I like the approach very much, it has several very good points:
|
What would be the better approach here to avoid confusion? |
I do not have one. I even doubt there is one, because one might expect several things and all of them could be reasonable. One thing I can see is that we might distinguish between attributes that have been explicitly set (those should persist) and attributes that have their default value (they should be superseded by the existing value):
However, one might argue that this is not to be expected either, because |
Specifically fixes ManimCommunity#2366 by correcting the shape of the `VGroup` of `VGroup`s. Attempted to balance keeping all names and methods intact, while still cleaning things up since we're expecting this class to eventually be aliased in the rework for `Text` (ManimCommunity#2355).
Some personal opinions on the new implementation of
intro_words = Text("""
The original motivation for manim was to
better illustrate mathematical functions
as transformations.
""")
self.add(intro_words) |
Yes. We should not reinvent the wheel with SVG parsing given how complex it is. Replacing the current parser with a third-party library would without a doubt be healthy for the library! |
Yeah, I plan to drop support for slicing, instead, users can use the Markup or use
I think it would be better to wrap the lines if it exceeds the screen size, rather than a fixed width as done currently. Also, there would be a parameter to not automatically wrap lines in
I don't think |
Oh, I regarded
|
Another idea for this |
I think it would break the |
Just to post some updates here, I have done some work on ManimPango; see https://github.com/ManimCommunity/ManimPango/milestone/1. It is a huge refactor, would take a lot of time and is still a WIP. |
Currently, the text API which uses Pango isn't great and I would like to refactor it. Here is my proposal:
New Class:
FormattedString
- It's similar to a list of strings but would give more control over the formatting of each string. Initialising it would require the following optional parameters:text
: The text to show. This would be added as the first in the list.font
: The fonts of the strings. Default when not overridden individually. (much like howtext
inMarkupText
current is)font_size
: The size of the font. Default when not overridden individually.fallback_font
: Font to fall back to when the main one isn't available or doesn't contain a specific character. This can also be overridden individually.color
: The color of the text. Default to white. Probably should be overridden by themes.strikethrough
: whether to strikethroughstrikethrough_color
: the color of strikethroughinsert_hypens
: use hyphens when breaking a work (default to True)underline
: Underline the text.overline
: Draw an overline on text.underline_color
: Color of underlineoverline_color
: Color of overlinebaseline_shift
: Set's baseline shift for a given textopen_type_features
: which features to enablelanguage
: The language of the textindent
: the indent of the parastyle
: styles of textweight
: Font weightletter_spacing
: Space between lettersand more see https://gnome.pages.gitlab.gnome.org/gtk/Pango/enum.AttrType.html
The
FormattedString
will have the functions:clear
: clear all the texts storedappend
: Add a new text. Accepts all arguments from__init__()
.Addition should be possible with
FormattedString
. If the addition isFormattedString
andFormattedString
it should add items from second to the first one. If the addition isFormattedString
andstr
a new text should be added to the original one.The
Text
class which exists should accept anstr
and aFormattedString
. The string passed here will be considered as Pango Markup.The
MarkupText
class will be deprecated.All the
t2*
parameters are deprecated and removed from theText
class.Paragraph
will be aliased toText
Text
will have new parameterswidth
andheight
which will be considered when creating text and paragraphs would be broken based on this. By defaultwidth
andheight
should be full screen.Text
will be treated as a paragraph, which means it has parameters like-
justify
: Justify paragraph-
align
: Align the text should beleft
,right
,center
-
line_height
: Height of each line.Text
should also accept parameters fromFormattedString
for backwards compatibility.Example Code
CC: @PhilippImhof
The text was updated successfully, but these errors were encountered: