code: def vertical_layout(self, draw, slide):
          
          padding = self.padding
          heading = slide['heading']
  
          width, height = draw.textsize(heading['text'])
          top = padding
          left = padding
  
          # Calculate size and location of heading
          heading.update(dict(
              width = width,
              height = height,
              top = self.padding,
              left = self.padding))
  
          top += height + padding
  
          # count how many rows just text and how many have image
          rows = slide['rows']
          text_rows = 0
          image_rows = 0
  
          # calculate size of all text objects
          total_height = top
          for row in rows:
  
              row_height = 0
  
              images = 0
              for item in row['items']:
                  if item.get('image'):
                      images += 1
  
                  text = item.get('text')
                  
                  if text is None: continue
                      
                  width, height = draw.textsize(text)
  
                  item.update(dict(
                      width = width,
                      height = height))
  
                  row_height = max(row_height, height)
                  
  
              if images:
                  image_rows += 1
                  row['images'] = images
              else:
                  row['height'] = row_height
                  text_rows += 1
  
              total_height += row_height + padding
                  
          # Calculate average height for image rows
          if image_rows:
              
              available = HEIGHT - total_height
  
              image_height = available // image_rows
  
              image_text_offset = image_height // 2
  
          # now spin through rows again setting top
          # (and height for images)
          for row in rows:
              text_top = top
              
              images = row.get('images', 0)
              if images:
                  text_top += image_text_offset
  
              for item in row['items']:
                  if item.get('text') is not None:
                      item['top'] = text_top
                  else:
                      # image
                      item['top'] = top
                      item['height'] = image_height
                      row['height'] = image_height
  
              
              top += row.get('height', 0) + padding
  
          return
docs: Augment slide with vertical layout info