A community-maintained Python framework for creating mathematical animations.
Merge branch 'master' of https://github.com/manimcommunity/manim into fix-liga
Syrus Darka98f422ce361
diff --cc docs/source/changelog.rstindex d4c6e676a,2e18c49d2..97405a60e--- a/docs/source/changelog.rst+++ b/docs/source/changelog.rst@@@ -24,8 -24,12 +24,12 @@@ New FeatureBugfixes========-- There is nothing here yet, check back later.+#. Add ``disable_ligatures`` to Text ( :class:`Text` ). (via :pr:`804`)+ Other Changes+ =============++ #. Removed temp partial movie file from SceneFileWriter (ffmpeg directly renders partial movie files instead of temp files)******v0.1.1diff --cc manim/mobject/svg/text_mobject.pyindex f56e0a48e,6c7bae094..2bc1d47d4--- a/manim/mobject/svg/text_mobject.py+++ b/manim/mobject/svg/text_mobject.py@@@ -49,6 -49,6 +49,8 @@@ import copimport hashlibimport osimport re++from typing import Dict++from xml.sax.saxutils import escapeimport cairoimport cairocffi@@@ -686,41 -721,65 +718,68 @@@ class Text(SVGMobject)"""- CONFIG = {+ def __init__(+ self,+ text: str,- fill_opacity=1,- stroke_width=0,- color=WHITE,- size=1,- line_spacing=-1,- font="",++ fill_opacity:int=1,++ stroke_width:int=0,++ color=WHITE, # what should be this type?++ size:int=1,++ line_spacing:int=-1,++ font:str="",+ slant=NORMAL,+ weight=NORMAL,- t2c=None,- t2f=None,- t2g=None,- t2s=None,- t2w=None,- gradient=None,- tab_width=4,++ t2c:Dict[str, str]=None,++ t2f:Dict[str, str]=None,++ t2g:Dict[str, tuple]=None,++ t2s:Dict[str, str]=None,++ t2w:Dict[str, str]=None,++ gradient:tuple=None,++ tab_width:int=4,# Mobject- "color": WHITE,- "height": None,- "width": None,- "fill_opacity": 1,- "stroke_width": 0,- "should_center": True,- "unpack_groups": True,- # Text- "font": "",- "gradient": None,- "line_spacing": -1,- "size": 1,- "slant": NORMAL,- "weight": NORMAL,- "t2c": {},- "t2f": {},- "t2g": {},- "t2s": {},- "t2w": {},- "tab_width": 4,- }- height=None,- width=None,- should_center=True,- unpack_groups=True,++ height:int=None,++ width:int=None,++ should_center:bool=True,++ unpack_groups:bool=True,++ disable_ligatures: bool = False,+ **kwargs,+ ):+- def __init__(- self, text: str, disable_ligatures: bool = False, **config- ): # pylint: disable=redefined-outer-namelogger.info("Text now uses Pango for rendering. ""In case of problems, the old implementation is available as CairoText.")- self.full2short(config)- digest_config(self, config)+ self.size = size+ self.line_spacing = line_spacing+ self.font = font+ self.slant = slant+ self.weight = weight+ self.gradient = gradient+ self.tab_width = tab_width+ if t2c is None:+ t2c = {}+ if t2f is None:+ t2f = {}+ if t2g is None:+ t2g = {}+ if t2s is None:+ t2s = {}+ if t2w is None:+ t2w = {}+ # If long form arguments are present, they take precedence+ t2c = kwargs.pop("text2color", t2c)+ t2f = kwargs.pop("text2font", t2f)+ t2g = kwargs.pop("text2gradient", t2g)+ t2s = kwargs.pop("text2slant", t2s)+ t2w = kwargs.pop("text2weight", t2w)+ self.t2c = t2c+ self.t2f = t2f+ self.t2g = t2g+ self.t2s = t2s+ self.t2w = t2w+self.original_text = text+ self.disable_ligatures = disable_ligaturestext_without_tabs = textif text.find("\t") != -1:text_without_tabs = text.replace("\t", " " * self.tab_width)@@@ -731,11 -790,19 +790,22 @@@self.line_spacing = self.size + self.size * self.line_spacingfile_name = self.text2svg()self.remove_last_M(file_name)- SVGMobject.__init__(self, file_name, **config)+ SVGMobject.__init__(+ self,+ file_name,+ color=color,+ fill_opacity=fill_opacity,+ stroke_width=stroke_width,+ height=height,+ width=width,+ should_center=should_center,+ unpack_groups=unpack_groups,+ **kwargs,+ )self.text = text+ if self.disable_ligatures:+ self.submobjects = [*self.gen_chars()]+ self.chars = VGroup(*self.submobjects)self.chars = VGroup(*self.submobjects)self.text = text_without_tabs.replace(" ", "").replace("\n", "")nppc = self.n_points_per_cubic_curve