mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
refactor: refactor StringMobject
This commit is contained in:
parent
8bd01d60e4
commit
4dfe8aff86
7 changed files with 701 additions and 429 deletions
|
@ -18,8 +18,6 @@ directories:
|
|||
temporary_storage: ""
|
||||
universal_import_line: "from manimlib import *"
|
||||
style:
|
||||
# "latex" | "xelatex"
|
||||
tex_compiler: "latex"
|
||||
tex_template: "default"
|
||||
font: "Consolas"
|
||||
text_alignment: "LEFT"
|
||||
|
|
|
@ -179,13 +179,8 @@ class MTex(StringMobject):
|
|||
if self.alignment:
|
||||
prefix_lines.append(self.alignment)
|
||||
if self.tex_environment:
|
||||
if isinstance(self.tex_environment, str):
|
||||
env_prefix = f"\\begin{{{self.tex_environment}}}"
|
||||
env_suffix = f"\\end{{{self.tex_environment}}}"
|
||||
else:
|
||||
env_prefix, env_suffix = self.tex_environment
|
||||
prefix_lines.append(env_prefix)
|
||||
suffix_lines.append(env_suffix)
|
||||
prefix_lines.append(f"\\begin{{{self.tex_environment}}}")
|
||||
suffix_lines.append(f"\\end{{{self.tex_environment}}}")
|
||||
return (
|
||||
"".join([line + "\n" for line in prefix_lines]),
|
||||
"".join(["\n" + line for line in suffix_lines])
|
||||
|
|
|
@ -506,13 +506,13 @@ class StringMobject(SVGMobject, ABC):
|
|||
def build_parts_from_indices_lists(
|
||||
self, indices_lists: list[list[int]]
|
||||
) -> VGroup:
|
||||
return VGroup(*[
|
||||
VGroup(*[
|
||||
return VGroup(*(
|
||||
VGroup(*(
|
||||
self.submobjects[submob_index]
|
||||
for submob_index in indices_list
|
||||
])
|
||||
))
|
||||
for indices_list in indices_lists
|
||||
])
|
||||
))
|
||||
|
||||
def build_groups(self) -> VGroup:
|
||||
return self.build_parts_from_indices_lists([
|
||||
|
|
|
@ -279,7 +279,7 @@ class MarkupText(StringMobject):
|
|||
|
||||
@staticmethod
|
||||
def replace_for_matching(match_obj: re.Match) -> str:
|
||||
if match_obj.group("tag"):
|
||||
if match_obj.group("tag") or match_obj.group("passthrough"):
|
||||
return ""
|
||||
if match_obj.group("entity"):
|
||||
if match_obj.group("unicode"):
|
||||
|
@ -311,7 +311,7 @@ class MarkupText(StringMobject):
|
|||
|
||||
def get_configured_items(self) -> list[tuple[Span, dict[str, str]]]:
|
||||
return [
|
||||
*[
|
||||
*(
|
||||
(span, {key: val})
|
||||
for t2x_dict, key in (
|
||||
(self.t2c, "foreground"),
|
||||
|
@ -321,12 +321,12 @@ class MarkupText(StringMobject):
|
|||
)
|
||||
for selector, val in t2x_dict.items()
|
||||
for span in self.find_spans_by_selector(selector)
|
||||
],
|
||||
*[
|
||||
),
|
||||
*(
|
||||
(span, local_config)
|
||||
for selector, local_config in self.local_configs.items()
|
||||
for span in self.find_spans_by_selector(selector)
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
default: |-
|
||||
# Classical TeX templates
|
||||
|
||||
default:
|
||||
description: ""
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage[english]{babel}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
|
@ -20,7 +25,10 @@ default: |-
|
|||
\DisableLigatures{encoding = *, family = * }
|
||||
\linespread{1}
|
||||
|
||||
ctex: |-
|
||||
ctex:
|
||||
description: ""
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage[UTF8]{ctex}
|
||||
\usepackage[english]{babel}
|
||||
\usepackage{amsmath}
|
||||
|
@ -39,64 +47,115 @@ ctex: |-
|
|||
\usepackage{microtype}
|
||||
\linespread{1}
|
||||
|
||||
basic: |-
|
||||
# Simplified TeX templates
|
||||
|
||||
basic:
|
||||
description: ""
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage[english]{babel}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
|
||||
ctex_basic: |-
|
||||
basic_ctex:
|
||||
description: ""
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage[UTF8]{ctex}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
|
||||
none: ""
|
||||
empty:
|
||||
description: ""
|
||||
compiler: latex
|
||||
preamble: ""
|
||||
|
||||
empty_ctex:
|
||||
description: ""
|
||||
compiler: xelatex
|
||||
preamble: ""
|
||||
|
||||
# A collection of TeX templates for the fonts described at
|
||||
# http://jf.burnol.free.fr/showcase.html
|
||||
|
||||
# American Typewriter
|
||||
american_typewriter: |-
|
||||
american_typewriter:
|
||||
description: American Typewriter
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{American Typewriter}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Antykwa Poltawskiego (TX Fonts for Greek and math symbols)
|
||||
antykwa: |-
|
||||
antykwa:
|
||||
description: Antykwa Poltawskiego (TX Fonts for Greek and math symbols)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[OT4,OT1]{fontenc}
|
||||
\usepackage{txfonts}
|
||||
\usepackage[upright]{txgreeks}
|
||||
\usepackage{antpolt}
|
||||
\usepackage[defaultmathsizes,nolessnomore]{mathastext}
|
||||
|
||||
# Apple Chancery
|
||||
apple_chancery: |-
|
||||
apple_chancery:
|
||||
description: Apple Chancery
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Apple Chancery}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Auriocus Kalligraphicus (Symbol Greek)
|
||||
auriocus_kalligraphicus: |-
|
||||
auriocus_kalligraphicus:
|
||||
description: Auriocus Kalligraphicus (Symbol Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{aurical}
|
||||
\renewcommand{\rmdefault}{AuriocusKalligraphicus}
|
||||
\usepackage[symbolgreek]{mathastext}
|
||||
|
||||
# Baskervald ADF with Fourier
|
||||
baskervald_adf_fourier: |-
|
||||
baskervald_adf_fourier:
|
||||
description: Baskervald ADF with Fourier
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[upright]{fourier}
|
||||
\usepackage{baskervald}
|
||||
\usepackage[defaultmathsizes,noasterisk]{mathastext}
|
||||
|
||||
# Baskerville (Italic)
|
||||
baskerville_it: |-
|
||||
baskerville_it:
|
||||
description: Baskerville (Italic)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Baskerville}
|
||||
\usepackage[defaultmathsizes,italic]{mathastext}
|
||||
|
||||
# Biolinum
|
||||
biolinum: |-
|
||||
biolinum:
|
||||
description: Biolinum
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{txfonts}
|
||||
\usepackage[upright]{txgreeks}
|
||||
\usepackage[no-math]{fontspec}
|
||||
|
@ -106,8 +165,13 @@ biolinum: |-
|
|||
\usepackage[defaultmathsizes]{mathastext}
|
||||
\renewcommand\familydefault\rmdefault
|
||||
|
||||
# BrushScriptX-Italic (PX math and Greek)
|
||||
brushscriptx: |-
|
||||
brushscriptx:
|
||||
description: BrushScriptX-Italic (PX math and Greek)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{pxfonts}
|
||||
\renewcommand{\rmdefault}{pbsi}
|
||||
|
@ -116,91 +180,156 @@ brushscriptx: |-
|
|||
\usepackage[defaultmathsizes,noasterisk]{mathastext}
|
||||
\boldmath
|
||||
|
||||
# Chalkboard SE
|
||||
chalkboard_se: |-
|
||||
chalkboard_se:
|
||||
description: Chalkboard SE
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Chalkboard SE}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Chalkduster
|
||||
chalkduster: |-
|
||||
chalkduster:
|
||||
description: Chalkduster
|
||||
compiler: lualatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Chalkduster}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Comfortaa
|
||||
comfortaa: |-
|
||||
comfortaa:
|
||||
description: Comfortaa
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[default]{comfortaa}
|
||||
\usepackage[LGRgreek,defaultmathsizes,noasterisk]{mathastext}
|
||||
\let\varphi\phi
|
||||
\linespread{1.06}
|
||||
|
||||
# Comic Sans MS
|
||||
comic_sans: |-
|
||||
comic_sans:
|
||||
description: Comic Sans MS
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Comic Sans MS}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Droid Sans
|
||||
droid_sans: |-
|
||||
droid_sans:
|
||||
description: Droid Sans
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[default]{droidsans}
|
||||
\usepackage[LGRgreek]{mathastext}
|
||||
\let\varepsilon\epsilon
|
||||
|
||||
# Droid Sans (Italic)
|
||||
droid_sans_it: |-
|
||||
droid_sans_it:
|
||||
description: Droid Sans (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[default]{droidsans}
|
||||
\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}
|
||||
\let\varphi\phi
|
||||
|
||||
# Droid Serif
|
||||
droid_serif: |-
|
||||
droid_serif:
|
||||
description: Droid Serif
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[default]{droidserif}
|
||||
\usepackage[LGRgreek]{mathastext}
|
||||
\let\varepsilon\epsilon
|
||||
|
||||
# Droid Serif (PX math symbols) (Italic)
|
||||
droid_serif_px_it: |-
|
||||
droid_serif_px_it:
|
||||
description: Droid Serif (PX math symbols) (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{pxfonts}
|
||||
\usepackage[default]{droidserif}
|
||||
\usepackage[LGRgreek,defaultmathsizes,italic,basic]{mathastext}
|
||||
\let\varphi\phi
|
||||
|
||||
# ECF Augie (Euler Greek)
|
||||
ecf_augie: |-
|
||||
ecf_augie:
|
||||
description: ECF Augie (Euler Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\renewcommand\familydefault{fau}
|
||||
\usepackage[defaultmathsizes,eulergreek]{mathastext}
|
||||
|
||||
# ECF JD (with TX fonts)
|
||||
ecf_jd: |-
|
||||
ecf_jd:
|
||||
description: ECF JD (with TX fonts)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{txfonts}
|
||||
\usepackage[upright]{txgreeks}
|
||||
\renewcommand\familydefault{fjd}
|
||||
\usepackage{mathastext}
|
||||
\mathversion{bold}
|
||||
|
||||
# ECF Skeetch (CM Greek)
|
||||
ecf_skeetch: |-
|
||||
ecf_skeetch:
|
||||
description: ECF Skeetch (CM Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\DeclareFontFamily{T1}{fsk}{}
|
||||
\DeclareFontShape{T1}{fsk}{m}{n}{<->s*[1.315] fskmw8t}{}
|
||||
\renewcommand\rmdefault{fsk}
|
||||
\usepackage[noendash,defaultmathsizes,nohbar,defaultimath]{mathastext}
|
||||
|
||||
# ECF Tall Paul (with Symbol font)
|
||||
ecf_tall_paul: |-
|
||||
ecf_tall_paul:
|
||||
description: ECF Tall Paul (with Symbol font)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\DeclareFontFamily{T1}{ftp}{}
|
||||
\DeclareFontShape{T1}{ftp}{m}{n}{<->s*[1.4] ftpmw8t}{}
|
||||
\renewcommand\familydefault{ftp}
|
||||
\usepackage[symbol]{mathastext}
|
||||
\let\infty\inftypsy
|
||||
|
||||
# ECF Webster (with TX fonts)
|
||||
ecf_webster: |-
|
||||
ecf_webster:
|
||||
description: ECF Webster (with TX fonts)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{txfonts}
|
||||
\usepackage[upright]{txgreeks}
|
||||
\renewcommand\familydefault{fwb}
|
||||
|
@ -209,66 +338,111 @@ ecf_webster: |-
|
|||
\linespread{1.5}
|
||||
\mathversion{bold}
|
||||
|
||||
# Electrum ADF (CM Greek)
|
||||
electrum_adf: |-
|
||||
electrum_adf:
|
||||
description: Electrum ADF (CM Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[LGRgreek,basic,defaultmathsizes]{mathastext}
|
||||
\usepackage[lf]{electrum}
|
||||
\Mathastext
|
||||
\let\varphi\phi
|
||||
|
||||
# Epigrafica
|
||||
epigrafica: |-
|
||||
epigrafica:
|
||||
description: Epigrafica
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[LGR,OT1]{fontenc}
|
||||
\usepackage{epigrafica}
|
||||
\usepackage[basic,LGRgreek,defaultmathsizes]{mathastext}
|
||||
\let\varphi\phi
|
||||
\linespread{1.2}
|
||||
|
||||
# Fourier Utopia (Fourier upright Greek)
|
||||
fourier_utopia: |-
|
||||
fourier_utopia:
|
||||
description: Fourier Utopia (Fourier upright Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[upright]{fourier}
|
||||
\usepackage{mathastext}
|
||||
|
||||
# French Cursive (Euler Greek)
|
||||
french_cursive: |-
|
||||
french_cursive:
|
||||
description: French Cursive (Euler Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[default]{frcursive}
|
||||
\usepackage[eulergreek,noplusnominus,noequal,nohbar,nolessnomore,noasterisk]{mathastext}
|
||||
|
||||
# GFS Bodoni
|
||||
gfs_bodoni: |-
|
||||
gfs_bodoni:
|
||||
description: GFS Bodoni
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\renewcommand{\rmdefault}{bodoni}
|
||||
\usepackage[LGRgreek]{mathastext}
|
||||
\let\varphi\phi
|
||||
\linespread{1.06}
|
||||
|
||||
# GFS Didot (Italic)
|
||||
gfs_didot: |-
|
||||
gfs_didot:
|
||||
description: GFS Didot (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\renewcommand\rmdefault{udidot}
|
||||
\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}
|
||||
\let\varphi\phi
|
||||
|
||||
# GFS NeoHellenic
|
||||
gfs_neohellenic: |-
|
||||
gfs_neohellenic:
|
||||
description: GFS NeoHellenic
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\renewcommand{\rmdefault}{neohellenic}
|
||||
\usepackage[LGRgreek]{mathastext}
|
||||
\let\varphi\phi
|
||||
\linespread{1.06}
|
||||
|
||||
# GNU FreeSerif (and TX fonts symbols)
|
||||
gnu_freesans_tx: |-
|
||||
gnu_freesans_tx:
|
||||
description: GNU FreeSerif (and TX fonts symbols)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\usepackage{txfonts}
|
||||
\setmainfont[ExternalLocation,Mapping=tex-text,BoldFont=FreeSerifBold,ItalicFont=FreeSerifItalic,BoldItalicFont=FreeSerifBoldItalic]{FreeSerif}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# GNU FreeSerif and FreeSans
|
||||
gnu_freeserif_freesans: |-
|
||||
gnu_freeserif_freesans:
|
||||
description: GNU FreeSerif and FreeSans
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[ExternalLocation,Mapping=tex-text,BoldFont=FreeSerifBold,ItalicFont=FreeSerifItalic,BoldItalicFont=FreeSerifBoldItalic]{FreeSerif}
|
||||
\setsansfont[ExternalLocation,Mapping=tex-text,BoldFont=FreeSansBold,ItalicFont=FreeSansOblique,BoldItalicFont=FreeSansBoldOblique,Scale=MatchLowercase]{FreeSans}
|
||||
|
@ -279,16 +453,26 @@ gnu_freeserif_freesans: |-
|
|||
\let\varphi\phi
|
||||
\renewcommand{\familydefault}{\rmdefault}
|
||||
|
||||
# Helvetica with Fourier (Italic)
|
||||
helvetica_fourier_it: |-
|
||||
helvetica_fourier_it:
|
||||
description: Helvetica with Fourier (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[scaled]{helvet}
|
||||
\usepackage{fourier}
|
||||
\renewcommand{\rmdefault}{phv}
|
||||
\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}
|
||||
|
||||
# Latin Modern Typewriter Proportional
|
||||
latin_modern_tw: |-
|
||||
latin_modern_tw:
|
||||
description: Latin Modern Typewriter Proportional
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[variablett]{lmodern}
|
||||
\renewcommand{\rmdefault}{\ttdefault}
|
||||
|
@ -297,107 +481,182 @@ latin_modern_tw: |-
|
|||
\Mathastext
|
||||
\let\varepsilon\epsilon
|
||||
|
||||
# Latin Modern Typewriter Proportional (CM Greek) (Italic)
|
||||
latin_modern_tw_it: |-
|
||||
latin_modern_tw_it:
|
||||
description: Latin Modern Typewriter Proportional (CM Greek) (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[variablett,nomath]{lmodern}
|
||||
\renewcommand{\familydefault}{\ttdefault}
|
||||
\usepackage[frenchmath]{mathastext}
|
||||
\linespread{1.08}
|
||||
|
||||
# Libertine
|
||||
libertine: |-
|
||||
libertine:
|
||||
description: Libertine
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{libertine}
|
||||
\usepackage[greek=n]{libgreek}
|
||||
\usepackage[noasterisk,defaultmathsizes]{mathastext}
|
||||
|
||||
# Libris ADF with Fourier
|
||||
libris_adf_fourier: |-
|
||||
libris_adf_fourier:
|
||||
description: Libris ADF with Fourier
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[upright]{fourier}
|
||||
\usepackage{libris}
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
\usepackage[noasterisk]{mathastext}
|
||||
|
||||
# Minion Pro and Myriad Pro (and TX fonts symbols)
|
||||
minion_pro_myriad_pro: |-
|
||||
minion_pro_myriad_pro:
|
||||
description: Minion Pro and Myriad Pro (and TX fonts symbols)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[default]{droidserif}
|
||||
\usepackage[LGRgreek]{mathastext}
|
||||
\let\varepsilon\epsilon
|
||||
|
||||
# Minion Pro (and TX fonts symbols)
|
||||
minion_pro_tx: |-
|
||||
minion_pro_tx:
|
||||
description: Minion Pro (and TX fonts symbols)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{txfonts}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Minion Pro}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# New Century Schoolbook (Symbol Greek)
|
||||
new_century_schoolbook: |-
|
||||
new_century_schoolbook:
|
||||
description: New Century Schoolbook (Symbol Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{newcent}
|
||||
\usepackage[symbolgreek]{mathastext}
|
||||
\linespread{1.1}
|
||||
|
||||
# New Century Schoolbook (Symbol Greek, PX math symbols)
|
||||
new_century_schoolbook_px: |-
|
||||
new_century_schoolbook_px:
|
||||
description: New Century Schoolbook (Symbol Greek, PX math symbols)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{pxfonts}
|
||||
\usepackage{newcent}
|
||||
\usepackage[symbolgreek,defaultmathsizes]{mathastext}
|
||||
\linespread{1.06}
|
||||
|
||||
# Noteworthy Light
|
||||
noteworthy_light: |-
|
||||
noteworthy_light:
|
||||
description: Noteworthy Light
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Noteworthy Light}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Palatino (Symbol Greek)
|
||||
palatino: |-
|
||||
palatino:
|
||||
description: Palatino (Symbol Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{palatino}
|
||||
\usepackage[symbolmax,defaultmathsizes]{mathastext}
|
||||
|
||||
# Papyrus
|
||||
papyrus: |-
|
||||
papyrus:
|
||||
description: Papyrus
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Papyrus}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Romande ADF with Fourier (Italic)
|
||||
romande_adf_fourier_it: |-
|
||||
romande_adf_fourier_it:
|
||||
description: Romande ADF with Fourier (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{fourier}
|
||||
\usepackage{romande}
|
||||
\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}
|
||||
\renewcommand{\itshape}{\swashstyle}
|
||||
|
||||
# SliTeX (Euler Greek)
|
||||
slitex: |-
|
||||
slitex:
|
||||
description: SliTeX (Euler Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{tpslifonts}
|
||||
\usepackage[eulergreek,defaultmathsizes]{mathastext}
|
||||
\MTEulerScale{1.06}
|
||||
\linespread{1.2}
|
||||
|
||||
# Times with Fourier (Italic)
|
||||
times_fourier_it: |-
|
||||
times_fourier_it:
|
||||
description: Times with Fourier (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{fourier}
|
||||
\renewcommand{\rmdefault}{ptm}
|
||||
\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}
|
||||
|
||||
# URW Avant Garde (Symbol Greek)
|
||||
urw_avant_garde: |-
|
||||
urw_avant_garde:
|
||||
description: URW Avant Garde (Symbol Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{avant}
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
\usepackage[symbolgreek,defaultmathsizes]{mathastext}
|
||||
|
||||
# URW Zapf Chancery (CM Greek)
|
||||
urw_zapf_chancery: |-
|
||||
urw_zapf_chancery:
|
||||
description: URW Zapf Chancery (CM Greek)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\DeclareFontFamily{T1}{pzc}{}
|
||||
\DeclareFontShape{T1}{pzc}{mb}{it}{<->s*[1.2] pzcmi8t}{}
|
||||
|
@ -410,34 +669,59 @@ urw_zapf_chancery: |-
|
|||
\linespread{1.05}
|
||||
\boldmath
|
||||
|
||||
# Venturis ADF with Fourier (Italic)
|
||||
venturis_adf_fourier_it: |-
|
||||
venturis_adf_fourier_it:
|
||||
description: Venturis ADF with Fourier (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{fourier}
|
||||
\usepackage[lf]{venturis}
|
||||
\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}
|
||||
|
||||
# Verdana (Italic)
|
||||
verdana_it: |-
|
||||
verdana_it:
|
||||
description: Verdana (Italic)
|
||||
compiler: xelatex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[no-math]{fontspec}
|
||||
\setmainfont[Mapping=tex-text]{Verdana}
|
||||
\usepackage[defaultmathsizes,italic]{mathastext}
|
||||
|
||||
# Vollkorn (TX fonts for Greek and math symbols)
|
||||
vollkorn: |-
|
||||
vollkorn:
|
||||
description: Vollkorn (TX fonts for Greek and math symbols)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage{txfonts}
|
||||
\usepackage[upright]{txgreeks}
|
||||
\usepackage{vollkorn}
|
||||
\usepackage[defaultmathsizes]{mathastext}
|
||||
|
||||
# Vollkorn with Fourier (Italic)
|
||||
vollkorn_fourier_it: |-
|
||||
vollkorn_fourier_it:
|
||||
description: Vollkorn with Fourier (Italic)
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{fourier}
|
||||
\usepackage{vollkorn}
|
||||
\usepackage[italic,nohbar]{mathastext}
|
||||
|
||||
# Zapf Chancery
|
||||
zapf_chancery: |-
|
||||
zapf_chancery:
|
||||
description: Zapf Chancery
|
||||
compiler: latex
|
||||
preamble: |-
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{xcolor}
|
||||
\DeclareFontFamily{T1}{pzc}{}
|
||||
\DeclareFontShape{T1}{pzc}{mb}{it}{<->s*[1.2] pzcmi8t}{}
|
||||
\DeclareFontShape{T1}{pzc}{m}{it}{<->ssub * pzc/mb/it}{}
|
||||
|
|
|
@ -44,7 +44,6 @@ def init_customization() -> None:
|
|||
},
|
||||
"universal_import_line": "from manimlib import *",
|
||||
"style": {
|
||||
"tex_compiler": "",
|
||||
"tex_template": "",
|
||||
"font": "Consolas",
|
||||
"background_color": "",
|
||||
|
@ -107,16 +106,11 @@ def init_customization() -> None:
|
|||
|
||||
console.print("[bold]Styles:[/bold]")
|
||||
style_config = configuration["style"]
|
||||
compiler = Prompt.ask(
|
||||
" Select an executable program to use to compile a LaTeX source file",
|
||||
choices=["latex", "xelatex"],
|
||||
default="latex"
|
||||
tex_template = Prompt.ask(
|
||||
" Select a TeX template to compile a LaTeX source file",
|
||||
default="default"
|
||||
)
|
||||
style_config["tex_compiler"] = compiler
|
||||
if compiler == "latex":
|
||||
style_config["tex_template"] = "default"
|
||||
else:
|
||||
style_config["tex_template"] = "ctex"
|
||||
style_config["tex_template"] = tex_template
|
||||
style_config["background_color"] = Prompt.ask(
|
||||
" Which [bold]background color[/bold] do you want [italic](hex code)",
|
||||
default="#333333"
|
||||
|
|
|
@ -15,7 +15,7 @@ from manimlib.utils.simple_functions import hash_string
|
|||
SAVED_TEX_CONFIG = {}
|
||||
|
||||
|
||||
def get_tex_preamble(template_name: str) -> str:
|
||||
def get_tex_template_config(template_name: str) -> dict[str, str]:
|
||||
name = template_name.replace(" ", "_").lower()
|
||||
with open(os.path.join(
|
||||
get_manim_dir(), "manimlib", "tex_templates.yml"
|
||||
|
@ -27,28 +27,26 @@ def get_tex_preamble(template_name: str) -> str:
|
|||
name
|
||||
)
|
||||
name = "default"
|
||||
result = templates_dict[name]
|
||||
if name not in ("default", "ctex", "basic", "ctex_basic", "blank"):
|
||||
result = templates_dict["basic"] + "\n" + result
|
||||
return result
|
||||
return templates_dict[name]
|
||||
|
||||
|
||||
def get_tex_config() -> dict[str, str]:
|
||||
"""
|
||||
Returns a dict which should look something like this:
|
||||
{
|
||||
"compiler": "latex",
|
||||
"template": "default",
|
||||
"compiler": "latex",
|
||||
"preamble": "..."
|
||||
}
|
||||
"""
|
||||
# Only load once, then save thereafter
|
||||
if not SAVED_TEX_CONFIG:
|
||||
style_config = get_custom_config()["style"]
|
||||
template_name = get_custom_config()["style"]["tex_template"]
|
||||
template_config = get_tex_template_config(template_name)
|
||||
SAVED_TEX_CONFIG.update({
|
||||
"compiler": style_config["tex_compiler"],
|
||||
"template": style_config["tex_template"],
|
||||
"preamble": get_tex_preamble(style_config["tex_template"])
|
||||
"template": template_name,
|
||||
"compiler": template_config["compiler"],
|
||||
"preamble": template_config["preamble"]
|
||||
})
|
||||
return SAVED_TEX_CONFIG
|
||||
|
||||
|
@ -58,9 +56,12 @@ def tex_content_to_svg_file(
|
|||
) -> str:
|
||||
tex_config = get_tex_config()
|
||||
if not template or template == tex_config["template"]:
|
||||
compiler = tex_config["compiler"]
|
||||
preamble = tex_config["preamble"]
|
||||
else:
|
||||
preamble = get_tex_preamble(template)
|
||||
config = get_tex_template_config(template)
|
||||
compiler = config["compiler"]
|
||||
preamble = config["preamble"]
|
||||
|
||||
if additional_preamble:
|
||||
preamble += "\n" + additional_preamble
|
||||
|
@ -77,7 +78,7 @@ def tex_content_to_svg_file(
|
|||
)
|
||||
if not os.path.exists(svg_file):
|
||||
# If svg doesn't exist, create it
|
||||
create_tex_svg(full_tex, svg_file, tex_config["compiler"])
|
||||
create_tex_svg(full_tex, svg_file, compiler)
|
||||
return svg_file
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue