def get_glyph_cleaned_extents(glyph, glyf_table):
    """Get the vertical extent of glyphs, ignoring single-point contours.

    This is take care of weirdness in the various fonts, who may need the
    single-point contours for hinting or glyph positioning, or may have
    forgotten to clean them up."""

    try:
        return glyph.cleanedYMin, glyph.cleanedYMax
    except AttributeError:
        glyph.expand(glyf_table)

        if glyph.numberOfContours == 0:  # is empty
            glyph.cleanedYMin = None
            glyph.cleanedYMax = None
            return None, None
        elif glyph.numberOfContours == -1:  # has components
            max_height = None
            min_height = None
            for component in glyph.components:
                component_ymin, component_ymax = get_glyph_cleaned_extents(
                    glyf_table.glyphs[component.glyphName],
                    glyf_table)

                if hasattr(component, 'transform'):
                    transform = component.transform
                    assert transform[1][0] == transform[0][1] == 0, (
                        "Can't handle complex transforms")
                else:
                    transform = [[1, 0], [0, 1]]
                max_height = max_with_none(
                    max_height,
                    transform_y(transform, component_ymax) + component.y)
                min_height = min_with_none(
                    min_height,
                    transform_y(transform, component_ymin) + component.y)
        else:
            # Set points_to_ignore to the list of all single-point contours
            points_to_ignore = set()
            previous_end_point = -1
            for end_point in glyph.endPtsOfContours:
                if end_point == previous_end_point + 1:
                    points_to_ignore.add(end_point)

                previous_end_point = end_point

            max_height = None
            min_height = None
            for index, point in enumerate(glyph.coordinates):
                if index in points_to_ignore:
                    continue

                y_value = point[1]
                max_height = max_with_none(max_height, y_value)
                min_height = min_with_none(min_height, y_value)

        glyph.cleanedYMin = min_height
        glyph.cleanedYMax = max_height
        return min_height, max_height
dataset/ETHPy150Open googlei18n/nototools/nototools/render.py/get_glyph_cleaned_extents/original