docs: def set_font(path, columns=None, rows=None, columnFirst=False,
               greyscale=False, altLayout=False):
      """Changes the font to be used for this session.
      This should be called before :any:`tdl.init`
  
      If the font specifies its size in its filename (i.e. font_NxN.png) then this
      function can auto-detect the tileset formatting and the parameters columns
      and rows can be left None.
  
      While it's possible you can change the font mid program it can sometimes
      break in rare circumstances.  So use caution when doing this.
  
      Args:
          path (Text): A file path to a `.bmp` or `.png` file.
          columns (int):
              Number of columns in the tileset.
  
              Can be left None for auto-detection.
          rows (int):
              Number of rows in the tileset.
  
              Can be left None for auto-detection.
          columnFirst (bool):
              Defines if the characer order goes along the rows or colomns.
  
              It should be True if the charater codes 0-15 are in the
              first column, and should be False if the characters 0-15
              are in the first row.
          greyscale (bool):
              Creates an anti-aliased font from a greyscale bitmap.
              Otherwise it uses the alpha channel for anti-aliasing.
  
              Unless you actually need anti-aliasing from a font you
              know uses a smooth greyscale channel you should leave
              this on False.
          altLayout (bool)
              An alternative layout with space in the upper left corner.
              The colomn parameter is ignored if this is True,
              find examples of this layout in the `font/libtcod/`
              directory included with the python-tdl source.
  
      Raises:
          TDLError: Will be raised if no file is found at path or if auto-
                    detection fails.
      """
      # put up some constants that are only used here
      FONT_LAYOUT_ASCII_INCOL = 1
      FONT_LAYOUT_ASCII_INROW = 2
      FONT_TYPE_GREYSCALE = 4
      FONT_LAYOUT_TCOD = 8
      global _fontinitialized
      _fontinitialized = True
      flags = 0
      if altLayout:
          flags |= FONT_LAYOUT_TCOD
      elif columnFirst:
          flags |= FONT_LAYOUT_ASCII_INCOL
      else:
          flags |= FONT_LAYOUT_ASCII_INROW
      if greyscale:
          flags |= FONT_TYPE_GREYSCALE
      if not _os.path.exists(path):
          raise TDLError('Font %r not found.' % _os.path.abspath(path))
      path = _os.path.abspath(path)
  
      # and the rest is the auto-detect script
      imgSize = _getImageSize(path) # try to find image size
      if imgSize:
          fontWidth, fontHeight = None, None
          imgWidth, imgHeight = imgSize
          # try to get font size from filename
          match = _re.match('.*?([0-9]+)[xX]([0-9]+)', _os.path.basename(path))
          if match:
              fontWidth, fontHeight = match.groups()
              fontWidth, fontHeight = int(fontWidth), int(fontHeight)
  
              # estimate correct tileset size
              estColumns, remC = divmod(imgWidth, fontWidth)
              estRows, remR = divmod(imgHeight, fontHeight)
              if remC or remR:
                  _warnings.warn("Font may be incorrectly formatted.")
  
              if not columns:
                  columns = estColumns
              if not rows:
                  rows = estRows
          else:
              # filename doesn't contain NxN, but we can still estimate the fontWidth
              # and fontHeight given number of columns and rows.
              if columns and rows:
                  fontWidth, remC = divmod(imgWidth, columns)
                  fontHeight, remR = divmod(imgHeight, rows)
                  if remC or remR:
                      _warnings.warn("Font may be incorrectly formatted.")
  
              # the font name excluded the fonts size
              if not (columns and rows):
                  # no matched font size and no tileset is given
                  raise TDLError('%s has no font size in filename' % _os.path.basename(path))
  
          if columns and rows:
              # confirm user set options
              if (fontWidth * columns != imgWidth or
                  fontHeight * rows != imgHeight):
                  _warnings.warn("set_font parameters are set as if the image size is (%d, %d) when the detected size is actually (%i, %i)"
                               % (fontWidth * columns, fontHeight * rows,
                                  imgWidth, imgHeight))
      else:
          _warnings.warn("%s is probably not an image." % _os.path.basename(path))
  
      if not (columns and rows):
          # didn't auto-detect
          raise TDLError('Can not auto-detect the tileset of %s' % _os.path.basename(path))
  
      _lib.TCOD_console_set_custom_font(_encodeString(path), flags, columns, rows)