def findSizes(self,font):
        fontLogger.debug("font.key()=%s" % font.key())
        fontDatabase = QFontDatabase()

        self.sizeCombo.blockSignals(True)
        self.sizeCombo.clear()

        self.sizeComboFs.blockSignals(True)
        self.sizeComboFs.clear()

        styleStr = fontDatabase.styleString(font)
        if fontDatabase.isSmoothlyScalable(font.family(),styleStr):
            for size in QFontDatabase.standardSizes():
                self.sizeCombo.addItem(str(size))
                self.sizeComboFs.addItem(str(size))
        else:
            for size in fontDatabase.smoothSizes(font.family(),styleStr):
                self.sizeCombo.addItem(str(size))
                self.sizeComboFs.addItem(str(size))

        self.sizeCombo.blockSignals(False)
        self.sizeComboFs.blockSignals(False)

        currentSize = unicode(QSettings().value("worksheet/fontsize",
                                                QtReduceDefaults.FONTSIZE))
        sizeIndex = self.sizeCombo.findText(currentSize)
        self.sizeCombo.setCurrentIndex(sizeIndex)

        currentSize = unicode(QSettings().value("worksheet/fontsizefs",
                                                QtReduceDefaults.FONTSIZEFS))
        sizeIndex = self.sizeCombo.findText(currentSize)
        self.sizeComboFs.setCurrentIndex(sizeIndex)
Example #2
0
 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
Example #3
0
 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 __init__(self,parent=None):
        super(QtReduceFontComboBox,self).__init__()
        fdb = QFontDatabase()
        l = []
        self.fontDict = {}
        for fam in fdb.families(QFontDatabase.Latin):
            for sty in fdb.styles(fam):
                if not fam in l and fdb.isFixedPitch(fam,sty) \
                and not fdb.bold(fam,sty) and not fdb.italic(fam,sty) \
                and self.__osxHack(fam):
                    fontLogger.debug("family=%s, style=%s, isFixedPitch=%s" %
                                     (fam, sty, fdb.isFixedPitch(fam,sty)))
                    sizes = fdb.smoothSizes(fam,sty)
                    if sizes:
                        font = fdb.font(fam,sty,sizes[0])
                        if not font.exactMatch():
                            fontLogger.debug("no exactMatch for  %s %s %s" %
                                             (fam,sty,sizes[0]))

                        l += [fam]
                        self.fontDict.update({str(fam):font})
        l.sort
        self.addItems(l)
        self.currentIndexChanged.connect(self.currentIndexChangedHandler)