3b1b / 3b1b/manim

Brace doesn't work with unicode-math

Offen
#2,288 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
93.8k
Forks
7.7k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

### Describe the bug

When I use `unicode-math` package in `tex_templates.yml` and I use `Brace` to draw a curly brace, an error has occurred.

**Code**:

```yml
# custom_config.yml
tex:
template: "basic"
```
```yml
# tex_templates.yml
# Line 8 and 9 are added
basic:
description: ""
compiler: latex
preamble: |-
\usepackage[english]{babel}
\usepackage[mathrm=sym]{unicode-math}
\setmathfont{Noto Sans Math}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{xcolor}
```
```py
square = Square().set_fill(BLUE_E, 1)
# Here's where the error happens:
brace = Brace(square, UP)
```

**Wrong display or Error traceback**:

```text
Traceback (most recent call last):
...
File "/.../manimlib/scene/scene.py", line 155, in run
self.construct()
~~~~~~~~~~~~~~^^
File "/.../tmp.py", line 5, in construct
brace = Brace(square, UP)
File "/.../manimlib/mobject/svg/brace.py", line 50, in __init__
self.set_initial_width(target_width)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/.../manimlib/mobject/svg/brace.py", line 58, in set_initial_width
for tip, rect, vect in [(self[0], self[1], RIGHT), (self[5], self[4], LEFT)]:
~~~~^^^
File "/.../manimlib/mobject/svg/string_mobject.py", line 551, in __getitem__
return super().__getitem__(value)
~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/.../manimlib/mobject/mobject.py", line 405, in __getitem__
return self.split().__getitem__(value)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range
````

### Additional context

The pack `unicode-math` is a convenient way to set the math font, but it also changes the way curly braces are rendered. LaTeX's original method was to use six characters to adjust the length by stretching, but in this package, the length is spliced according to the desired length, resulting in the subscript of `self` not corresponding.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.