code: def draw(self, text, scale=1.0, spacing=0):
      if len(text) == 0:
          return np.zeros((0, 0), dtype=np.uint8)
      try:
          spacing = max(0, spacing)
          image = Image.new(
              "L",
              tuple(
                  np.add(
                      self.font.getsize(text),
                      [
                          int(
                              self.char_width * spacing * len(text) * 2
                          ),
                          0,
                      ],
                  )
              ),
              255,
          )
          draw = ImageDraw.Draw(image)
          if spacing == 0 or len(text.strip()) == 0:
              draw.text((0, 0), text, font=self.font)
              image = np.array(image)[self.offset :, :]
  
          else:
              x = 0
              for i, c in enumerate(text):
                  draw.text((x, 0), c, font=self.font)
                  w, h = self.font.getsize(c)
                  x += int(spacing * self.char_width + w)
              image = np.array(image)[self.offset :, :]
  
              sums = np.mean(image, axis=0)
              if np.mean(sums) >= 254:
                  # empty image
                  return np.zeros((0, 0), dtype=np.uint8)
  
              end = len(sums)
              while sums[end - 1] >= 254:
                  end -= 1
              image = image[:, :end]
  
          if scale != 1:
              image = rescale(image, float(scale), preserve_range=True)
  
          return image
      except Exception as e:
          logger.exception(e)
          logger.warning(
              f"Text: {text}, Spacing: {spacing}, Scale: {scale}, Length: {len(text.strip())}"
          )
          raise e
  
imports: from PIL import ImageFont, ImageDraw, Image
  import numpy
  import random
  from skimage.transform import rescale
  from enum import IntEnum
  from collections import namedtuple
  from typing import List
  import logging
  from calamari_ocr.ocr.dataset.datareader.generated_line_dataset import LineGeneratorParams
label_desc: Use image node_id 2 for calling the Font obj's underlying member method code with example usage: obj.draw(text, scale, spacing) and returns: np, image, np