docs: def com_google_fonts_check_monospace(ttFont, glyph_metrics_stats):
    """Checking correctness of monospaced metadata.
  
    There are various metadata in the OpenType spec to specify if
    a font is monospaced or not. If the font is not trully monospaced,
    then no monospaced metadata should be set (as sometimes
    they mistakenly are...)
  
    Monospace fonts must:
  
    * post.isFixedWidth "Set to 0 if the font is proportionally spaced,
      non-zero if the font is not proportionally spaced (monospaced)"
      www.microsoft.com/typography/otspec/post.htm
  
    * hhea.advanceWidthMax must be correct, meaning no glyph's
      width value is greater.
      www.microsoft.com/typography/otspec/hhea.htm
  
    * OS/2.panose.bProportion must be set to 9 (monospace). Spec says:
      "The PANOSE definition contains ten digits each of which currently
      describes up to sixteen variations. Windows uses bFamilyType,
      bSerifStyle and bProportion in the font mapper to determine
      family type. It also uses bProportion to determine if the font
      is monospaced."
      www.microsoft.com/typography/otspec/os2.htm#pan
      monotypecom-test.monotype.de/services/pan2
  
    * OS/2.xAverageWidth must be set accurately.
      "OS/2.xAverageWidth IS used when rendering monospaced fonts,
      at least by Windows GDI"
      http://typedrawers.com/discussion/comment/15397/#Comment_15397
  
    Also we should report an error for glyphs not of average width
    """
    from fontbakery.constants import (IsFixedWidth,
                                      PANOSE_Proportion)
    failed = False
    # Note: These values are read from the dict here only to
    # reduce the max line length in the check implementation below:
    seems_monospaced = glyph_metrics_stats["seems_monospaced"]
    most_common_width = glyph_metrics_stats["most_common_width"]
    width_max = glyph_metrics_stats['width_max']
  
    if ttFont['hhea'].advanceWidthMax != width_max:
      failed = True
      yield FAIL, Message("bad-advanceWidthMax",
                          ("Value of hhea.advanceWidthMax"
                           " should be set to {} but got"
                           " {} instead."
                           "").format(width_max, ttFont['hhea'].advanceWidthMax))
    if seems_monospaced:
      if ttFont['post'].isFixedPitch == IsFixedWidth.NOT_MONOSPACED:
        failed = True
        yield FAIL, Message("mono-bad-post-isFixedPitch",
                            ("On monospaced fonts, the value of"
                             " post.isFixedPitch must be set to a non-zero value"
                             " (meaning 'fixed width monospaced'),"
                             " but got {} instead."
                             "").format(ttFont['post'].isFixedPitch))
  
      if ttFont['OS/2'].panose.bProportion != PANOSE_Proportion.MONOSPACED:
        failed = True
        yield FAIL, Message("mono-bad-panose-proportion",
                            ("On monospaced fonts, the value of"
                             " OS/2.panose.bProportion must be set to {}"
                             " (proportion: monospaced), but got"
                             " {} instead."
                             "").format(PANOSE_Proportion.MONOSPACED,
                                        ttFont['OS/2'].panose.bProportion))
  
      num_glyphs = len(ttFont['glyf'].glyphs)
      unusually_spaced_glyphs = [
          g for g in ttFont['glyf'].glyphs
          if g not in ['.notdef', '.null', 'NULL'] and
          ttFont['hmtx'].metrics[g][0] != most_common_width
      ]
      outliers_ratio = float(len(unusually_spaced_glyphs)) / num_glyphs
      if outliers_ratio > 0:
        failed = True
        yield WARN, Message("mono-outliers",
                            ("Font is monospaced but {} glyphs"
                             " ({}%) have a different width."
                             " You should check the widths of:"
                             " {}").format(
                                 len(unusually_spaced_glyphs),
                                 100.0 * outliers_ratio, unusually_spaced_glyphs))
      if not failed:
        yield PASS, Message("mono-good", ("Font is monospaced and all"
                                          " related metadata look good."))
    else:
      # it is a non-monospaced font, so lets make sure
      # that all monospace-related metadata is properly unset.
  
      if ttFont['post'].isFixedPitch != IsFixedWidth.NOT_MONOSPACED:
        failed = True
        yield FAIL, Message("bad-post-isFixedPitch",
                            ("On non-monospaced fonts, the"
                             " post.isFixedPitch value must be set to {}"
                             " (not monospaced), but got {} instead."
                             "").format(IsFixedWidth.NOT_MONOSPACED,
                                        ttFont['post'].isFixedPitch))
  
      if ttFont['OS/2'].panose.bProportion == PANOSE_Proportion.MONOSPACED:
        failed = True
        yield FAIL, Message("bad-panose-proportion",
                            ("On non-monospaced fonts, the"
                             " OS/2.panose.bProportion value can be set to "
                             " any value except 9 (proportion: monospaced)"
                             " which is the bad value we got in this font."))
      if not failed:
        yield PASS, Message("good", ("Font is not monospaced and"
                                     " all related metadata look good."))