{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Font properties\n\nThis example lists the attributes of an `.FT2Font` object, which describe\nglobal font properties.  For individual character metrics, use the `.Glyph`\nobject, as returned by `.load_char`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import os\n\nimport matplotlib\nimport matplotlib.ft2font as ft\n\nfont = ft.FT2Font(\n    # Use a font shipped with Matplotlib.\n    os.path.join(matplotlib.get_data_path(),\n                 'fonts/ttf/DejaVuSans-Oblique.ttf'))\n\nprint('Num instances:  ', font.num_named_instances)  # number of named instances in file\nprint('Num faces:      ', font.num_faces)            # number of faces in file\nprint('Num glyphs:     ', font.num_glyphs)           # number of glyphs in the face\nprint('Family name:    ', font.family_name)          # face family name\nprint('Style name:     ', font.style_name)           # face style name\nprint('PS name:        ', font.postscript_name)      # the postscript name\nprint('Num fixed:      ', font.num_fixed_sizes)      # number of embedded bitmaps\n\n# the following are only available if face.scalable\nif font.scalable:\n    # the face global bounding box (xmin, ymin, xmax, ymax)\n    print('Bbox:               ', font.bbox)\n    # number of font units covered by the EM\n    print('EM:                 ', font.units_per_EM)\n    # the ascender in 26.6 units\n    print('Ascender:           ', font.ascender)\n    # the descender in 26.6 units\n    print('Descender:          ', font.descender)\n    # the height in 26.6 units\n    print('Height:             ', font.height)\n    # maximum horizontal cursor advance\n    print('Max adv width:      ', font.max_advance_width)\n    # same for vertical layout\n    print('Max adv height:     ', font.max_advance_height)\n    # vertical position of the underline bar\n    print('Underline pos:      ', font.underline_position)\n    # vertical thickness of the underline\n    print('Underline thickness:', font.underline_thickness)\n\nfor flag in ft.StyleFlags:\n    name = flag.name.replace('_', ' ').title() + ':'\n    print(f\"{name:17}\", flag in font.style_flags)\n\nfor flag in ft.FaceFlags:\n    name = flag.name.replace('_', ' ').title() + ':'\n    print(f\"{name:17}\", flag in font.face_flags)"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}