ManimCommunity / ManimCommunity/manim

Character spacing/overlap/kerning bug after escape characters in `Paragraph` when using non-default `alignment` argument

Open
#2,673 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

issue:bug
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

When using `alignment` in the arguments for `Paragraph` (e.g. `alignment='left'`), character overlap occurs after escaped characters (e.g. `\n`, `\t`). This doesn't occur when omitting the `alignment` argument entirely (although this **still left aligns text** by default - that is to say, omitting `alignment` and using `alignment='left'` should have the same effect but don't).

## Expected behavior

No character overlap after newlines, tabs, etc. when using non-default `alignment` arguments.

## How to reproduce the issue

Code for reproducing the problem

```py
class UsingParagraph(Scene):
def construct(self):
paragraph = Paragraph('nothing', 'With \nNewlines', '\tWith Tabs')

self.play(Create(paragraph))
self.wait()
self.play(Uncreate(paragraph))

paragraph = Paragraph('alignment=""', 'With \nNewlines', '\tWith Tabs', alignment='')

self.play(Create(paragraph))
self.wait()
self.play(Uncreate(paragraph))

paragraph = Paragraph('alignment="left"', 'With \nNewlines', '\tWith Tabs', alignment='left')

self.play(Create(paragraph)) # HERE WE GET THE BUG WITH CHARACTER OVERLAP
self.wait()
self.play(Uncreate(paragraph))

paragraph = Paragraph('alignment="right"', 'With \nNewlines', '\tWith Tabs', alignment='right')

self.play(Create(paragraph)) # THIS WOULD ALSO APPEAR TO BE A VARIATION OF THE BUG
self.wait()
self.play(Uncreate(paragraph))

paragraph = Paragraph('alignment="left", no ligatures', 'With \nNewlines', '\tWith Tabs', alignment='left', disable_ligatures=True)

self.play(Create(paragraph)) # NEWLINES AND TABS ENTIRELY REMOVED BY DISABLE LIGATURES AS EXPECTED
self.wait()
self.play(Uncreate(paragraph))
```

## Additional media files

Images/GIFs

![Output of rendering UsingParagraph scene above](https://user-images.githubusercontent.com/30503695/163378107-bcd215b7-36c3-4c93-a003-c3856501d6f9.gif)

## Additional comments

It's highly likely this bug is related to #2366 and would likely be solved in the rewrite proposed in #2355

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied UsingParagraph scene, then inspect Paragraph handling for explicit alignment and escaped newlines or tabs while comparing it with the omitted-alignment case. Review related issues #2366 and #2355; done means the scene renders without character overlap for the demonstrated alignments.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.