.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_gallery_text_labels_and_annotations_stix_fonts_demo.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_text_labels_and_annotations_stix_fonts_demo.py:


===============
STIX Fonts Demo
===============





.. image:: /gallery/text_labels_and_annotations/images/sphx_glr_stix_fonts_demo_001.png
    :class: sphx-glr-single-img





.. code-block:: python

    from __future__ import unicode_literals

    import subprocess
    import sys
    import re
    import gc
    import matplotlib.pyplot as plt
    import numpy as np

    stests = [
        r'$\mathcircled{123} \mathrm{\mathcircled{123}}'
        r' \mathbf{\mathcircled{123}}$',
        r'$\mathsf{Sans \Omega} \mathrm{\mathsf{Sans \Omega}}'
        r' \mathbf{\mathsf{Sans \Omega}}$',
        r'$\mathtt{Monospace}$',
        r'$\mathcal{CALLIGRAPHIC}$',
        r'$\mathbb{Blackboard \pi}$',
        r'$\mathrm{\mathbb{Blackboard \pi}}$',
        r'$\mathbf{\mathbb{Blackboard \pi}}$',
        r'$\mathfrak{Fraktur} \mathbf{\mathfrak{Fraktur}}$',
        r'$\mathscr{Script}$']

    if sys.maxunicode > 0xffff:
        s = r'Direct Unicode: $\u23ce \mathrm{\ue0f2 \U0001D538}$'


    def doall():
        tests = stests

        plt.figure(figsize=(8, (len(tests) * 1) + 2))
        plt.plot([0, 0], 'r')
        plt.grid(False)
        plt.axis([0, 3, -len(tests), 0])
        plt.yticks(np.arange(len(tests)) * -1)
        for i, s in enumerate(tests):
            plt.text(0.1, -i, s, fontsize=32)

        plt.savefig('stix_fonts_example')
        plt.show()


    if '--latex' in sys.argv:
        fd = open("stix_fonts_examples.ltx", "w")
        fd.write("\\documentclass{article}\n")
        fd.write("\\begin{document}\n")
        fd.write("\\begin{enumerate}\n")

        for i, s in enumerate(stests):
            s = re.sub(r"(?<!\\)\$", "$$", s)
            fd.write("\\item %s\n" % s)

        fd.write("\\end{enumerate}\n")
        fd.write("\\end{document}\n")
        fd.close()

        subprocess.call(["pdflatex", "stix_fonts_examples.ltx"])
    else:
        doall()


.. _sphx_glr_download_gallery_text_labels_and_annotations_stix_fonts_demo.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download

     :download:`Download Python source code: stix_fonts_demo.py <stix_fonts_demo.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: stix_fonts_demo.ipynb <stix_fonts_demo.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
