def __nextGoodFontSize(self, font, size, step): info = QFontInfo(font) family = info.family() fontDatabase = QFontDatabase() styleStr = fontDatabase.styleString(font) fontLogger.debug("family=%s, style=%s" % (family, styleStr)) if fontDatabase.isSmoothlyScalable(family, styleStr): sizes = QFontDatabase.standardSizes() else: sizes = fontDatabase.smoothSizes(family, styleStr) fontLogger.debug("looking for %s in %s step %d" % (size, sizes, step)) nSize = size while nSize not in sizes and sizes[0] <= nSize and nSize <= sizes[-1]: nSize += step if nSize < sizes[0]: fontLogger.debug("out of range - returning %s" % sizes[0]) return sizes[0] if sizes[-1] < nSize: fontLogger.debug("out of range - returning %s" % sizes[-1]) return sizes[-1] fontLogger.debug("found %s" % nSize) return nSize
def __nextGoodFontSize(self,font,size,step): info = QFontInfo(font) family = info.family() fontDatabase = QFontDatabase() styleStr = fontDatabase.styleString(font) fontLogger.debug("family=%s, style=%s" % (family,styleStr)) if fontDatabase.isSmoothlyScalable(family,styleStr): sizes = QFontDatabase.standardSizes() else: sizes = fontDatabase.smoothSizes(family,styleStr) fontLogger.debug("looking for %s in %s step %d" % (size,sizes,step)) nSize = size while nSize not in sizes and sizes[0] <= nSize and nSize <= sizes[-1]: nSize += step if nSize < sizes[0]: fontLogger.debug("out of range - returning %s" % sizes[0]) return sizes[0] if sizes[-1] < nSize: fontLogger.debug("out of range - returning %s" % sizes[-1]) return sizes[-1] fontLogger.debug("found %s" % nSize) return nSize
def setCurrentFont(self,font): info = QFontInfo(font) self.setCurrentIndex(self.findText(info.family()))