Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 03-23-2025, 09:13 PM   #1
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,720
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Fonts issue with calibre 8.0.1

Hi,

People are reporting issues with the Generate Cover plugin when upgrading to 8.0.1. Which I assume are some Qt version related issue (as nothing has been changed in my plugin). Is there a code change I need to make or is this a calibre issue to be sorted?

https://www.mobileread.com/forums/sh...20#post4499620
kiwidude is offline   Reply With Quote
Old 03-23-2025, 10:21 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,173
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
How are you selecting fonts in your plugin? There have been no font related changes in calibre code for calibre 8 so if something has changed it will be in Qt.
kovidgoyal is offline   Reply With Quote
Old 03-23-2025, 11:44 PM   #3
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,720
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
The font selection combos:
Code:
class FontFamilyModel(QAbstractListModel):

    def __init__(self, *args):
        QAbstractListModel.__init__(self, *args)
        from calibre.utils.fonts.scanner import font_scanner
        try:
            self.families = font_scanner.find_font_families()
        except:
            self.families = []
            print('WARNING: Could not load fonts')
            traceback.print_exc()
        # Restrict to Qt families as Qt tends to crash
        self.font = QFont('Arial' if iswindows else 'sansserif')

    def rowCount(self, *args):
        return len(self.families)

    def data(self, index, role):
        try:
            family = self.families[index.row()]
        except:
            traceback.print_exc()
            return None
        if role == Qt.DisplayRole:
            return family
        if role == Qt.FontRole:
            # If a user chooses some non standard font as the interface font,
            # rendering some font names causes Qt to crash, so return what is
            # hopefully a "safe" font
            return self.font
        return None

    def index_of(self, family):
        return self.families.index(family.strip())


class FontComboBox(QComboBox):
    def __init__(self, parent):
        QComboBox.__init__(self, parent)
        self.font_family_model = FontFamilyModel()
        self.setModel(self.font_family_model)

    def select_value(self, value):
        idx = self.findText(value) if value else -1
        self.setCurrentIndex(idx)

    def get_value(self):
        if self.currentIndex() < 0:
            return None
        return unicode(self.currentText()).strip()
Then the code for drawing making use of the font...
Code:
class TextLine(object):

    def __init__(self, text, font_name, font_size,
                 bottom_margin=30, align='center'):
        self.text = force_unicode(text)
        self.bottom_margin = bottom_margin
        try:
            from qt.core import QFont, Qt
        except ImportError:
            from PyQt5.Qt import QFont, Qt
        self.font = QFont(font_name) if font_name else QFont()
        self.font.setPixelSize(font_size)
        self._align = {'center': Qt.AlignHCenter,
                       'left': Qt.AlignLeft, 'right': Qt.AlignRight}[align]
kiwidude is offline   Reply With Quote
Old 03-24-2025, 01:11 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,173
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Looks fine to me.
kovidgoyal is offline   Reply With Quote
Old 03-31-2025, 01:18 PM   #5
MCBastos
Enthusiast
MCBastos is on a distinguished road
 
Posts: 41
Karma: 70
Join Date: Jan 2012
Location: Brazil
Device: Galaxy A16 5G
No news on this front? No workaround?
MCBastos is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fonts advanced settings issue Vetchy Kobo Reader 0 09-21-2022 09:21 AM
Rendering issue with Calibre - all fonts italicized thiago.eec Calibre 16 12-07-2020 12:25 PM
Calibe issue with obfuscated fonts. DNSB Calibre 4 10-15-2019 02:58 PM
Embedding fonts - strange issue sparklemotion Amazon Kindle 152 11-21-2013 08:05 PM
Chinese fonts display issue on kindle 3 leungss Amazon Kindle 2 10-06-2010 12:48 PM


All times are GMT -4. The time now is 01:58 PM.


MobileRead.com is a privately owned, operated and funded community.