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)
Exemplo n.º 2
0
 def findSizes(self, font):
     fontDatabase = QFontDatabase()
     currentSize = self.sizeComboBox.currentText()
     with Lib.BlockSignals(self.sizeComboBox):
         self.sizeComboBox.clear()
         if fontDatabase.isSmoothlyScalable(font.family(),
                                            fontDatabase.styleString(font)):
             for size in QFontDatabase.standardSizes():
                 self.sizeComboBox.addItem(str(size))
         else:
             for size in fontDatabase.smoothSizes(
                     font.family(), fontDatabase.styleString(font)):
                 self.sizeComboBox.addItem(str(size))
         self.sizeComboBox.setEditable(False)
     sizeIndex = self.sizeComboBox.findText(currentSize)
     if sizeIndex == -1:
         self.sizeComboBox.setCurrentIndex(
             max(0,
                 self.sizeComboBox.count() / 3))
     else:
         self.sizeComboBox.setCurrentIndex(sizeIndex)
Exemplo n.º 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
Exemplo n.º 4
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