diff --git a/galleries/users_explain/text/fonts.py b/galleries/users_explain/text/fonts.py index 40cc9eaa93eb..c985a044bc0c 100644 --- a/galleries/users_explain/text/fonts.py +++ b/galleries/users_explain/text/fonts.py @@ -29,22 +29,22 @@ .. table:: Types of Fonts - +--------------------------+----------------------------+-------------------------------+ - | Type 1 (PDF with usetex) | Type 3 (PDF/PS) | TrueType (PDF) / Type 42 (PS) | - +==========================+============================+===============================+ - | Old font types introduced by Adobe. | Newer font type introduced by | - | | Apple; commonly used today. | - +--------------------------+----------------------------+-------------------------------+ - | Restricted subset of | Full PostScript language, | Includes a virtual machine | - | PostScript, charstrings | allows embedding arbitrary | that can execute code. | - | are in bytecode. | code. | | - +--------------------------+----------------------------+-------------------------------+ - | Supports font hinting. | Does not support font | Supports font hinting, | - | | hinting. | through the virtual machine. | - +--------------------------+----------------------------+-------------------------------+ - | Subsetted by code in | Subsetted via external module | - | `matplotlib._type1font`. | `fontTools `__. | - +--------------------------+----------------------------+-------------------------------+ + +------------------------+--------------------------+-----------------------------+ + | Type 1 (PDF usetex) | Type 3 (PDF/PS) | TrueType (PDF) / Type 42 PS | + +========================+==========================+=============================+ + | Old font types introduced by Adobe. | Newer font type introduced | + | | by Apple; commonly used. | + +------------------------+--------------------------+-----------------------------+ + | Restricted subset of | Full PostScript language,| Includes a virtual machine | + | PostScript, | allows embedding | that can execute code. | + | charstrings in bytecode| arbitrary code. | | + +------------------------+--------------------------+-----------------------------+ + | Supports font hinting. | Does not support font | Supports font hinting, via | + | | hinting. | the virtual machine. | + +------------------------+--------------------------+-----------------------------+ + | Subsetted by code in | Subsetted via external module | + | `_type1font`. | `fontTools `__. | + +------------------------+--------------------------+-----------------------------+ .. note:: @@ -155,32 +155,25 @@ Font fallback ------------- -There is no font that covers the entire Unicode space thus it is possible for the -users to require a mix of glyphs that cannot be satisfied from a single font. -While it has been possible to use multiple fonts within a Figure, on distinct -`.Text` instances, it was not previous possible to use multiple fonts in the -same `.Text` instance (as a web browser does). As of Matplotlib 3.6 the Agg, -SVG, PDF, and PS backends will "fallback" through multiple fonts in a single -`.Text` instance: - -.. plot:: - :include-source: - :caption: The string "There are 几个汉字 in between!" rendered with 2 fonts. - - fig, ax = plt.subplots() - ax.text( - .5, .5, "There are 几个汉字 in between!", - family=['DejaVu Sans', 'Noto Sans CJK JP', 'Noto Sans TC'], - ha='center' - ) - -Internally this is implemented by setting The "font family" on -`.FontProperties` objects to a list of font families. A (currently) -private API extracts a list of paths to all of the fonts found and then -constructs a single `.ft2font.FT2Font` object that is aware of all of the fonts. -Each glyph of the string is rendered using the first font in the list that -contains that glyph. - -A majority of this work was done by Aitik Gupta supported by Google Summer of -Code 2021. +As of Matplotlib 3.6 the Agg, SVG, PDF, and PS backends will "fallback" through multiple fonts in a single `.Text` instance. For example, the string "There are 几个汉字 in between!" is rendered with 2 fonts: """ # noqa: E501 + +import matplotlib.pyplot as plt + +fig, ax = plt.subplots() +ax.text( + .5, .5, "There are 几个汉字 in between!", + family=['DejaVu Sans', 'Noto Sans CJK JP', 'Noto Sans TC'], + ha='center' +) + +# %% +# Internally this is implemented by setting The "font family" on +# `.FontProperties` objects to a list of font families. A (currently) +# private API extracts a list of paths to all of the fonts found and then +# constructs a single `.ft2font.FT2Font` object that is aware of all of the fonts. +# Each glyph of the string is rendered using the first font in the list that +# contains that glyph. +# +# A majority of this work was done by Aitik Gupta supported by Google Summer of +# Code 2021. diff --git a/galleries/users_explain/text/pgf.py b/galleries/users_explain/text/pgf.py index c5fa16f35ce7..54861b5b0c7f 100644 --- a/galleries/users_explain/text/pgf.py +++ b/galleries/users_explain/text/pgf.py @@ -263,3 +263,4 @@ .. _LaTeX: http://www.tug.org .. _TeXLive: http://www.tug.org/texlive/ """ +# sphinx_gallery_thumbnail_path = '_static/pgf_preamble.png' diff --git a/galleries/users_explain/text/usetex.py b/galleries/users_explain/text/usetex.py index e687ec7af5bf..78b121e0b0a9 100644 --- a/galleries/users_explain/text/usetex.py +++ b/galleries/users_explain/text/usetex.py @@ -165,3 +165,5 @@ .. _underscore: https://ctan.org/pkg/underscore .. _Xpdf: http://www.xpdfreader.com/ """ +# sphinx_gallery_thumbnail_path = ( +# '/gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png')