
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/misc/ftface_props.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

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

        :ref:`Go to the end <sphx_glr_download_gallery_misc_ftface_props.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_misc_ftface_props.py:


===============
Font properties
===============

This example lists the attributes of an `.FT2Font` object, which describe
global font properties.  For individual character metrics, use the `.Glyph`
object, as returned by `.load_char`.

.. GENERATED FROM PYTHON SOURCE LINES 10-57




.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Num instances:   0
    Num faces:       1
    Num glyphs:      5343
    Family name:     DejaVu Sans
    Style name:      Oblique
    PS name:         DejaVuSans-Oblique
    Num fixed:       0
    Bbox:                (-2080, -717, 3398, 2187)
    EM:                  2048
    Ascender:            1901
    Descender:           -483
    Height:              2384
    Max adv width:       3461
    Max adv height:      2384
    Underline pos:       -175
    Underline thickness: 90
    Italic:           True
    Bold:             False
    Scalable:         True
    Fixed Sizes:      False
    Fixed Width:      False
    Sfnt:             True
    Horizontal:       True
    Vertical:         False
    Kerning:          True
    Fast Glyphs:      False
    Multiple Masters: False
    Glyph Names:      True
    External Stream:  True
    Hinter:           True
    Cid Keyed:        False
    Tricky:           False
    Color:            False






|

.. code-block:: Python


    import os

    import matplotlib
    import matplotlib.ft2font as ft

    font = ft.FT2Font(
        # Use a font shipped with Matplotlib.
        os.path.join(matplotlib.get_data_path(),
                     'fonts/ttf/DejaVuSans-Oblique.ttf'))

    print('Num instances:  ', font.num_named_instances)  # number of named instances in file
    print('Num faces:      ', font.num_faces)            # number of faces in file
    print('Num glyphs:     ', font.num_glyphs)           # number of glyphs in the face
    print('Family name:    ', font.family_name)          # face family name
    print('Style name:     ', font.style_name)           # face style name
    print('PS name:        ', font.postscript_name)      # the postscript name
    print('Num fixed:      ', font.num_fixed_sizes)      # number of embedded bitmaps

    # the following are only available if face.scalable
    if font.scalable:
        # the face global bounding box (xmin, ymin, xmax, ymax)
        print('Bbox:               ', font.bbox)
        # number of font units covered by the EM
        print('EM:                 ', font.units_per_EM)
        # the ascender in 26.6 units
        print('Ascender:           ', font.ascender)
        # the descender in 26.6 units
        print('Descender:          ', font.descender)
        # the height in 26.6 units
        print('Height:             ', font.height)
        # maximum horizontal cursor advance
        print('Max adv width:      ', font.max_advance_width)
        # same for vertical layout
        print('Max adv height:     ', font.max_advance_height)
        # vertical position of the underline bar
        print('Underline pos:      ', font.underline_position)
        # vertical thickness of the underline
        print('Underline thickness:', font.underline_thickness)

    for flag in ft.StyleFlags:
        name = flag.name.replace('_', ' ').title() + ':'
        print(f"{name:17}", flag in font.style_flags)

    for flag in ft.FaceFlags:
        name = flag.name.replace('_', ' ').title() + ':'
        print(f"{name:17}", flag in font.face_flags)


.. _sphx_glr_download_gallery_misc_ftface_props.py:

.. only:: html

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

    .. container:: sphx-glr-download sphx-glr-download-jupyter

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

    .. container:: sphx-glr-download sphx-glr-download-python

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: ftface_props.zip <ftface_props.zip>`


.. only:: html

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

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
