Skip to content

Conversation

@behackl
Copy link
Member

@behackl behackl commented Dec 1, 2020

Motivation

In some instances, Pango and Text works in a weird way due to the fact that it does some things in a rather different way when compared to Cairo and CairoText. The class Code is one of those that relied on certain behavior of CairoText that changed when switching to Pango -- and has not yet been fixed. In order to have a working version of Code again, this PR makes Paragraph use CairoText instead of Text and thus restores the old behavior.

Explanation for Changes

One thing that was changed in particular was how whitespace is counted: Text currently does not add invisible mobjects for spaces, which is why the coloring that Code applies to a given code snippet is off.

Testing Status

With this PR, Code("snippet.py", background="window", font="Roboto Mono") renders as this:
image

Acknowledgement

@behackl
Copy link
Member Author

behackl commented Dec 1, 2020

I could also add the changes from #476 and some additional changes to make sure the canvas size for CairoText is set dynamically based on the width and height of the passed string. (This caused problems for Pango, unfortunately, otherwise we could have merged #476...)

@behackl behackl added pr:easy review There is nothing particular (i.e, it's about a general/small thing) to know for review! enhancement Additions and improvements in general labels Dec 1, 2020
@behackl behackl added this to the Release v0.1.1 milestone Dec 1, 2020
@behackl behackl linked an issue Dec 1, 2020 that may be closed by this pull request
@leotrs leotrs merged commit a5a107c into ManimCommunity:master Dec 1, 2020
naveen521kk added a commit to naveen521kk/manim that referenced this pull request Dec 1, 2020
@behackl behackl deleted the cairotext-paragraph branch May 16, 2022 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Additions and improvements in general pr:easy review There is nothing particular (i.e, it's about a general/small thing) to know for review!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG-General] Code mobject colors are broken

2 participants