View Single Post
Old 12-12-2025, 07:02 AM   #114
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,218
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Manage font dialog will show any font referenced in any CSS rule, with the embedded font having a "✓" sign next to it, as opposed to non embedded fonts. If you want to delete all fonts and all references to them as done in the Manage fonts dialog, you can use this custom action which is based on the remove fonts functionality in "Manage fonts dialog":

Code:
from calibre.ebooks.oeb.polish.fonts import change_font, font_family_data

from calibre_plugins.editor_chains.actions.base import EditorAction

class RemoveAllFonts(EditorAction):

    name = 'Remove All Fonts'
    headless = True

    def run(self, chain, settings, *args, **kwargs):
        container = chain.current_container
        font_data = font_family_data(container)
        for font in font_data.keys():
            change_font(container, font)

    def validate(self, settings):
        return True
You can add the custom action by clicking on Editor Chains menu > Manage Modules > add > copy/paste.

Note: Using the above method, you will lose all the font formatting even if the font is installed on your device, as the function deletes all font-family properties from the epub. This apply to previously embedded as well as non-embedded fonts.

Last edited by capink; 12-12-2025 at 07:09 AM.
capink is offline   Reply With Quote