code: def _get_k_p_a(font, left, right):
      """This actually calculates the kerning + advance"""
      # http://lists.apple.com/archives/coretext-dev/2010/Dec/msg00020.html
      # 1) set up a CTTypesetter
      chars = left + right
      args = [
          None,
          1,
          cf.kCFTypeDictionaryKeyCallBacks,
          cf.kCFTypeDictionaryValueCallBacks,
      ]
      attributes = cf.CFDictionaryCreateMutable(*args)
      cf.CFDictionaryAddValue(attributes, kCTFontAttributeName, font)
      string = cf.CFAttributedStringCreate(
          None, CFSTR(chars), attributes
      )
      typesetter = ct.CTTypesetterCreateWithAttributedString(string)
      cf.CFRelease(string)
      cf.CFRelease(attributes)
      # 2) extract a CTLine from it
      range = CFRange(0, 1)
      line = ct.CTTypesetterCreateLine(typesetter, range)
      # 3) use CTLineGetOffsetForStringIndex to get the character positions
      offset = ct.CTLineGetOffsetForStringIndex(line, 1, None)
      cf.CFRelease(line)
      cf.CFRelease(typesetter)
      return offset
  
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 4 for calling a global function with example usage: _get_k_p_a(font, left, right) and returns: offset