code: def _load_glyph(f, char, glyphs_dict):
      font = _load_font(f["face"], f["bold"], f["italic"])
      # resize loaded font
      args = [
          None,
          0,
          cf.kCFTypeDictionaryKeyCallBacks,
          cf.kCFTypeDictionaryValueCallBacks,
      ]
      attributes = cf.CFDictionaryCreateMutable(*args)
      desc = ct.CTFontDescriptorCreateWithAttributes(attributes)
      cf.CFRelease(attributes)
      font = ct.CTFontCreateCopyWithAttributes(
          font, f["size"], None, desc
      )
      cf.CFRelease(desc)
      if not font:
          raise RuntimeError("Couldn't load font")
      # Create an attributed string using text and font.
      args = [
          None,
          1,
          cf.kCFTypeDictionaryKeyCallBacks,
          cf.kCFTypeDictionaryValueCallBacks,
      ]
      attributes = cf.CFDictionaryCreateMutable(*args)
      cf.CFDictionaryAddValue(attributes, kCTFontAttributeName, font)
      string = cf.CFAttributedStringCreate(
          None, CFSTR(char), attributes
      )
      # Create a CTLine object to render the string.
      line = ct.CTLineCreateWithAttributedString(string)
      cf.CFRelease(string)
      cf.CFRelease(attributes)
      # Get a bounding rectangle for glyphs in string.
      chars = (UniChar * 1)(*map(ord, char))
      glyphs = (CGGlyph * 1)()
      ct.CTFontGetGlyphsForCharacters(font, chars, glyphs, 1)
      rect = ct.CTFontGetBoundingRectsForGlyphs(
          font, 0, glyphs, None, 1
      )
      # Get advance for all glyphs in string.
      advance = ct.CTFontGetAdvancesForGlyphs(font, 1, glyphs, None, 1)
      width = max(int(np.ceil(rect.size.width) + 1), 1)
      height = max(int(np.ceil(rect.size.height) + 1), 1)
  
      left = rect.origin.x
      baseline = -rect.origin.y
      top = height - baseline
  
      bits_per_component = 8
      bytes_per_row = 4 * width
      color_space = quartz.CGColorSpaceCreateDeviceRGB()
      args = [
          None,
          width,
          height,
          bits_per_component,
          bytes_per_row,
          color_space,
          kCGImageAlphaPremultipliedLast,
      ]
      bitmap = quartz.CGBitmapContextCreate(*args)
      # Draw text to bitmap context.
      quartz.CGContextSetShouldAntialias(bitmap, True)
      quartz.CGContextSetTextPosition(bitmap, -left, baseline)
      ct.CTLineDraw(line, bitmap)
      cf.CFRelease(line)
      # Create an image to get the data out.
      image_ref = quartz.CGBitmapContextCreateImage(bitmap)
      assert quartz.CGImageGetBytesPerRow(image_ref) == bytes_per_row
      data_provider = quartz.CGImageGetDataProvider(image_ref)
      image_data = quartz.CGDataProviderCopyData(data_provider)
      buffer_size = cf.CFDataGetLength(image_data)
      assert buffer_size == width * height * 4
      buffer = (c_byte * buffer_size)()
      byte_range = CFRange(0, buffer_size)
      cf.CFDataGetBytes(image_data, byte_range, buffer)
      quartz.CGImageRelease(image_ref)
      quartz.CGDataProviderRelease(image_data)
      cf.CFRelease(bitmap)
      cf.CFRelease(color_space)
  
      # reshape bitmap (don't know why it's only alpha on OSX...)
      bitmap = np.array(buffer, np.ubyte)
      bitmap.shape = (height, width, 4)
      bitmap = bitmap[:, :, 3].copy()
      glyph = dict(
          char=char,
          offset=(left, top),
          bitmap=bitmap,
          advance=advance,
          kerning={},
      )
      glyphs_dict[char] = glyph
      # Generate kerning
      for other_char, other_glyph in glyphs_dict.items():
          glyph["kerning"][other_char] = (
              _get_k_p_a(font, other_char, char)
              - other_glyph["advance"]
          )
          other_glyph["kerning"][char] = (
              _get_k_p_a(font, char, other_char) - glyph["advance"]
          )
      cf.CFRelease(font)
  
file_path: vispy/vispy/util/fonts/_quartz.py
imports: import numpy
  from ctypes import byref, c_int32, c_byte
  from ...ext.cocoapy import cf, ct, quartz, CFRange, CFSTR, CGGlyph, UniChar, kCTFontFamilyNameAttribute, kCTFontBoldTrait, kCTFontItalicTrait, kCTFontSymbolicTrait, kCTFontTraitsAttribute, kCTFontAttributeName, kCGImageAlphaPremultipliedLast, kCFNumberSInt32Type, ObjCClass
  from ._vispy_fonts import _vispy_fonts, _get_vispy_font_filename
label_desc: Use image node_id 3 for calling a global function with example usage: _load_glyph(f, char, glyphs_dict) without return types