def _get_controlPointBounds(self):
        from fontTools.misc.transform import Transform
        # storage
        glyphRects = {}
        componentReferences = {}
        # scan loaded glyphs
        for glyphName, glyph in self._glyphs.items():
            if glyphName in self._scheduledForDeletion:
                continue
            glyphRect = glyph.controlPointBounds
            if glyphRect:
                glyphRects[glyphName] = glyphRect
        # scan glyphs that have not been loaded
        if self.path is not None:
            glyphsPath = os.path.join(self.path, "glyphs")
            for glyphName, fileName in self._glyphSet.contents.items():
                if glyphName in self._glyphs or glyphName in self._scheduledForDeletion:
                    continue
                # get the GLIF text
                glyphPath = os.path.join(glyphsPath, fileName)
                f = open(glyphPath, "rb")
                data = f.read()
                f.close()
                # get the point bounding box
                xMin = None
                xMax = None
                yMin = None
                yMax = None
                for line in controlBoundsPointRE.findall(data):
                    x = controlBoundsPointXRE.findall(line)
                    if not x:
                        continue
                    y = controlBoundsPointYRE.findall(line)
                    if not y:
                        continue
                    x = int(x[0])
                    if xMin is None:
                        xMin = xMax = x
                    if xMin > x:
                        xMin = x
                    if xMax < x:
                        xMax = x
                    y = int(y[0])
                    if yMin is None:
                        yMin = yMax = y
                    if yMin > y:
                        yMin = y
                    if yMax < y:
                        yMax = y
                glyphRect = (xMin, yMin, xMax, yMax)
                if None not in glyphRect:
                    glyphRects[glyphName] = glyphRect
                # get all component references
                for line in controlBoundsComponentRE.findall(data):
                    base = controlBoundsComponentBaseRE.findall(line)
                    if not base:
                        continue
                    base = base[0]
                    # xScale
                    xScale = controlBoundsComponentXScaleRE.findall(line)
                    if not xScale:
                        xScale = [1]
                    xScale = float(xScale[0])
                    # yScale
                    yScale = controlBoundsComponentYScaleRE.findall(line)
                    if not yScale:
                        yScale = [1]
                    yScale = float(yScale[0])
                    # xyScale
                    xyScale = controlBoundsComponentXYScaleRE.findall(line)
                    if not xyScale:
                        xyScale = [0]
                    xyScale = float(xyScale[0])
                    # yxScale
                    yxScale = controlBoundsComponentYXScaleRE.findall(line)
                    if not yxScale:
                        yxScale = [0]
                    yxScale = float(yxScale[0])
                    # xOffset
                    xOffset = controlBoundsComponentXOffsetRE.findall(line)
                    if not xOffset:
                        xOffset = [0]
                    xOffset = int(xOffset[0])
                    # yOffset
                    yOffset = controlBoundsComponentYOffsetRE.findall(line)
                    if not yOffset:
                        yOffset = [0]
                    yOffset = int(yOffset[0])
                    if glyphName not in componentReferences:
                        componentReferences[glyphName] = []
                    componentReferences[glyphName].append((base, xScale, xyScale, yxScale, yScale, xOffset, yOffset))
        # get the transformed component bounding boxes and update the glyphs
        for glyphName, components in componentReferences.items():
            glyphRect = glyphRects.get(glyphName, (None, None, None, None))
            # XXX this doesn't handle nested components
            for base, xScale, xyScale, yxScale, yScale, xOffset, yOffset in components:
                # base glyph doesn't exist
                if base not in glyphRects:
                    continue
                baseRect = glyphRects[base]
                # base glyph has no points
                if None in baseRect:
                    continue
                # transform the base rect
                transform = Transform(xx=xScale, xy=xyScale, yx=yxScale, yy=yScale, dx=xOffset, dy=yOffset)
                xMin, yMin, xMax, yMax = baseRect
                (xMin, yMin), (xMax, yMax) = transform.transformPoints([(xMin, yMin), (xMax, yMax)])
                componentRect = (xMin, yMin, xMax, yMax)
                # update the glyph rect
                if None in glyphRect:
                    glyphRect = componentRect
                else:
                    glyphRect = unionRect(glyphRect, componentRect)
            # store the updated rect
            glyphRects[glyphName] = glyphRect
        # work out the unified rect
        fontRect = None
        for glyphRect in glyphRects.values():
            if fontRect is None:
                fontRect = glyphRect
            elif glyphRect is not None:
                fontRect = unionRect(fontRect, glyphRect)
        # done
        return fontRect
dataset/ETHPy150Open typesupply/defcon/Lib/defcon/objects/font.py/Font._get_controlPointBounds/original