code: def _cairo_font_args_from_font_prop(prop):
      """
      Convert a `.FontProperties` or a `.FontEntry` to arguments that can be
      passed to `.Context.select_font_face`.
      """
  
      def attr(field):
          try:
              return getattr(prop, f"get_{field}")()
          except AttributeError:
              return getattr(prop, field)
  
      name = attr("name")
      slant = getattr(cairo, f"FONT_SLANT_{attr('style').upper()}")
      weight = attr("weight")
      weight = (
          cairo.FONT_WEIGHT_NORMAL
          if font_manager.weight_dict.get(weight, weight) < 550
          else cairo.FONT_WEIGHT_BOLD
      )
      return name, slant, weight
  
imports: import functools
  import gzip
  import math
  import numpy
  from ..None import _api, cbook, font_manager
  from matplotlib.backend_bases import _Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase, RendererBase
  from matplotlib.font_manager import ttfFontProperty
  from matplotlib.path import Path
  from matplotlib.transforms import Affine2D
label_desc: Use image node_id 2 for calling a global function with example usage: _cairo_font_args_from_font_prop(prop) and returns: name,  slant,  weight, getattr, getattr