|
| 1 | +from manim import * |
| 2 | + |
| 3 | +# French Cursive LaTeX font example from http://jf.burnol.free.fr/showcase.html |
| 4 | + |
| 5 | +# Example 1 Manually creating a Template |
| 6 | + |
| 7 | +TemplateForFrenchCursive = TexTemplate( |
| 8 | + preamble=r""" |
| 9 | +\usepackage[english]{babel} |
| 10 | +\usepackage{amsmath} |
| 11 | +\usepackage{amssymb} |
| 12 | +\usepackage[T1]{fontenc} |
| 13 | +\usepackage[default]{frcursive} |
| 14 | +\usepackage[eulergreek,noplusnominus,noequal,nohbar,% |
| 15 | +nolessnomore,noasterisk]{mathastext} |
| 16 | +""" |
| 17 | +) |
| 18 | + |
| 19 | + |
| 20 | +def FrenchCursive(*tex_strings, **kwargs): |
| 21 | + return Tex(*tex_strings, tex_template=TemplateForFrenchCursive, **kwargs) |
| 22 | + |
| 23 | + |
| 24 | +class TexFontTemplateManual(Scene): |
| 25 | + """An example scene that uses a manually defined TexTemplate() object to create |
| 26 | + LaTeX output in French Cursive font""" |
| 27 | + |
| 28 | + def construct(self): |
| 29 | + self.add(Tex("Tex Font Example").to_edge(UL)) |
| 30 | + self.play(ShowCreation(FrenchCursive("$f: A \\longrightarrow B$").shift(UP))) |
| 31 | + self.play( |
| 32 | + ShowCreation(FrenchCursive("Behold! We can write math in French Cursive")) |
| 33 | + ) |
| 34 | + self.wait(1) |
| 35 | + self.play( |
| 36 | + ShowCreation( |
| 37 | + Tex( |
| 38 | + "See more font templates at \\\\ http://jf.burnol.free.fr/showcase.html" |
| 39 | + ).shift(2 * DOWN) |
| 40 | + ) |
| 41 | + ) |
| 42 | + self.wait(2) |
| 43 | + |
| 44 | + |
| 45 | +# Example 2, using a Template from the collection |
| 46 | + |
| 47 | + |
| 48 | +class TexFontTemplateLibrary(Scene): |
| 49 | + """An example scene that uses TexTemplate objects from the TexFontTemplates collection |
| 50 | + to create sample LaTeX output in every font that will compile on the local system. |
| 51 | +
|
| 52 | + Please Note: |
| 53 | + Many of the in the TexFontTemplates collection require that specific fonts |
| 54 | + are installed on your local machine. |
| 55 | + For example, choosing the template TexFontTemplates.comic_sans will |
| 56 | + not compile if the Comic Sans Micrososft font is not installed. |
| 57 | +
|
| 58 | + This scene will only render those Templates that do not cause a TeX |
| 59 | + compilation error on your system. Furthermore, some of the ones that do render, |
| 60 | + may still render incorrectly. This is beyond the scope of manim. |
| 61 | + Feel free to experiment. |
| 62 | + """ |
| 63 | + |
| 64 | + def construct(self): |
| 65 | + def write_one_line(template): |
| 66 | + x = Tex(template.description, tex_template=template).shift(UP) |
| 67 | + self.play(ShowCreation(x)) |
| 68 | + self.wait(1) |
| 69 | + self.play(FadeOut(x)) |
| 70 | + |
| 71 | + examples = [ |
| 72 | + TexFontTemplates.american_typewriter, # "American Typewriter" |
| 73 | + TexFontTemplates.antykwa, # "Antykwa Półtawskiego (TX Fonts for Greek and math symbols)" |
| 74 | + TexFontTemplates.apple_chancery, # "Apple Chancery" |
| 75 | + TexFontTemplates.auriocus_kalligraphicus, # "Auriocus Kalligraphicus (Symbol Greek)" |
| 76 | + TexFontTemplates.baskervald_adf_fourier, # "Baskervald ADF with Fourier" |
| 77 | + TexFontTemplates.baskerville_it, # "Baskerville (Italic)" |
| 78 | + TexFontTemplates.biolinum, # "Biolinum" |
| 79 | + TexFontTemplates.brushscriptx, # "BrushScriptX-Italic (PX math and Greek)" |
| 80 | + TexFontTemplates.chalkboard_se, # "Chalkboard SE" |
| 81 | + TexFontTemplates.chalkduster, # "Chalkduster" |
| 82 | + TexFontTemplates.comfortaa, # "Comfortaa" |
| 83 | + TexFontTemplates.comic_sans, # "Comic Sans MS" |
| 84 | + TexFontTemplates.droid_sans, # "Droid Sans" |
| 85 | + TexFontTemplates.droid_sans_it, # "Droid Sans (Italic)" |
| 86 | + TexFontTemplates.droid_serif, # "Droid Serif" |
| 87 | + TexFontTemplates.droid_serif_px_it, # "Droid Serif (PX math symbols) (Italic)" |
| 88 | + TexFontTemplates.ecf_augie, # "ECF Augie (Euler Greek)" |
| 89 | + TexFontTemplates.ecf_jd, # "ECF JD (with TX fonts)" |
| 90 | + TexFontTemplates.ecf_skeetch, # "ECF Skeetch (CM Greek)" |
| 91 | + TexFontTemplates.ecf_tall_paul, # "ECF Tall Paul (with Symbol font)" |
| 92 | + TexFontTemplates.ecf_webster, # "ECF Webster (with TX fonts)" |
| 93 | + TexFontTemplates.electrum_adf, # "Electrum ADF (CM Greek)" |
| 94 | + TexFontTemplates.epigrafica, # Epigrafica |
| 95 | + TexFontTemplates.fourier_utopia, # "Fourier Utopia (Fourier upright Greek)" |
| 96 | + TexFontTemplates.french_cursive, # "French Cursive (Euler Greek)" |
| 97 | + TexFontTemplates.gfs_bodoni, # "GFS Bodoni" |
| 98 | + TexFontTemplates.gfs_didot, # "GFS Didot (Italic)" |
| 99 | + TexFontTemplates.gfs_neoHellenic, # "GFS NeoHellenic" |
| 100 | + TexFontTemplates.gnu_freesans_tx, # "GNU FreeSerif (and TX fonts symbols)" |
| 101 | + TexFontTemplates.gnu_freeserif_freesans, # "GNU FreeSerif and FreeSans" |
| 102 | + TexFontTemplates.helvetica_fourier_it, # "Helvetica with Fourier (Italic)" |
| 103 | + TexFontTemplates.latin_modern_tw_it, # "Latin Modern Typewriter Proportional (CM Greek) (Italic)" |
| 104 | + TexFontTemplates.latin_modern_tw, # "Latin Modern Typewriter Proportional" |
| 105 | + TexFontTemplates.libertine, # "Libertine" |
| 106 | + TexFontTemplates.libris_adf_fourier, # "Libris ADF with Fourier" |
| 107 | + TexFontTemplates.minion_pro_myriad_pro, # "Minion Pro and Myriad Pro (and TX fonts symbols)" |
| 108 | + TexFontTemplates.minion_pro_tx, # "Minion Pro (and TX fonts symbols)" |
| 109 | + TexFontTemplates.new_century_schoolbook, # "New Century Schoolbook (Symbol Greek)" |
| 110 | + TexFontTemplates.new_century_schoolbook_px, # "New Century Schoolbook (Symbol Greek, PX math symbols)" |
| 111 | + TexFontTemplates.noteworthy_light, # "Noteworthy Light" |
| 112 | + TexFontTemplates.palatino, # "Palatino (Symbol Greek)" |
| 113 | + TexFontTemplates.papyrus, # "Papyrus" |
| 114 | + TexFontTemplates.romande_adf_fourier_it, # "Romande ADF with Fourier (Italic)" |
| 115 | + TexFontTemplates.slitex, # "SliTeX (Euler Greek)" |
| 116 | + TexFontTemplates.times_fourier_it, # "Times with Fourier (Italic)" |
| 117 | + TexFontTemplates.urw_avant_garde, # "URW Avant Garde (Symbol Greek)" |
| 118 | + TexFontTemplates.urw_zapf_chancery, # "URW Zapf Chancery (CM Greek)" |
| 119 | + TexFontTemplates.venturis_adf_fourier_it, # "Venturis ADF with Fourier (Italic)" |
| 120 | + TexFontTemplates.verdana_it, # "Verdana (Italic)" |
| 121 | + TexFontTemplates.vollkorn_fourier_it, # "Vollkorn with Fourier (Italic)" |
| 122 | + TexFontTemplates.vollkorn, # "Vollkorn (TX fonts for Greek and math symbols)" |
| 123 | + TexFontTemplates.zapf_chancery, # "Zapf Chancery" |
| 124 | + ] |
| 125 | + |
| 126 | + self.add(Tex("Tex Font Template Example").to_edge(UL)) |
| 127 | + |
| 128 | + for font in examples: |
| 129 | + try: |
| 130 | + write_one_line(font) |
| 131 | + except: |
| 132 | + print("FAILURE on ", font.description, " - skipping.") |
| 133 | + |
| 134 | + self.play( |
| 135 | + ShowCreation( |
| 136 | + Tex( |
| 137 | + "See more font templates at \\\\ http://jf.burnol.free.fr/showcase.html" |
| 138 | + ).shift(2 * DOWN) |
| 139 | + ) |
| 140 | + ) |
| 141 | + self.wait(2) |
0 commit comments