Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 06-27-2026, 09:46 PM   #1
jloutsch
Junior Member
jloutsch began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2026
Device: Kindle Oasis, Kindle Paperwhite, Kobo Libra 2
[Conversion Output] kfxgen - open-source python KFX generator

Hi everyone, I'm happy to share a plugin I've been working on since last December.

kfxgen is an open-source Calibre output plugin that generates Kindle KFX files natively in Python — without invoking Amazon's Kindle Previewer. It produces a working in-book table of contents and Kindle navigation pane, and has been tested on Kindle hardware. It also shows images across the books I've tested.

I'm posting it here for others to try and review. Feedback, bug reports, and corrections are very welcome.

A few things up front:
  • License: GPL v3.
  • Credit / derivation: the KFX serialization code (the kfxlib_minimal directory) is a modified subset of John Howell's kfxlib from his KFX plugins, used under the GPL v3 it's licensed under. Full attribution is in the NOTICE file (shipped inside the plugin zip and in the repo). Thanks to jhowell — this wouldn't exist without that work.
  • No DRM involved: kfxgen converts EPUBs you already have into KFX. It does not remove, bypass, or interact with DRM in any way.

Why another KFX plugin
The official KFX Output plugin depends on Kindle Previewer, which is closed-source, Windows/Mac-only (Linux needs Wine), and takes minutes per book. kfxgen runs in pure Python, converts in seconds, works anywhere Calibre runs, and needs no external binaries.

The main reason I built it: custom fonts that actually render. KFX honors the font you've selected on the Kindle — including custom fonts you've installed on the device — and applies that font's OpenType features (ligatures, contextual alternates), which AZW3/MOBI didn't do reliably for me. kfxgen writes override_kindle_font: false so the device font is respected rather than overridden. Note: the font lives on the Kindle, not in the file — kfxgen does not embed font files, so the custom font must be installed on the device.
Building kfx output files via the kindle previewer was slow, and this method drastically speeds up the process.

How it relates to jhowell's "KFX Output"
This is a separate, independent plugin. In Calibre's plugin list it appears as kfxgen (not "KFX Output"). Because both produce the same KFX output format, only one can own the KFX conversion slot at a time — if you have both installed, enable just one. kfxgen is intended as a faster, dependency-free alternative for people who want it; jhowell's plugin remains the reference.

Validation
Every release runs a full pytest suite in CI and is exercised against a 90-book public-domain Project Gutenberg corpus (English, German, Dutch, Latin, Beowulf/Odyssey, heavily illustrated books, the Complete Works of Shakespeare with 1,169 TOC entries, etc.) with per-book correctness metrics. Output has been checked on Kindle devices.

Requirements
  • Calibre 5.0 or newer
  • Windows, macOS, or Linux

Install
  1. Download kfxgen-plugin-5.3.18.zip from the latest release: https://github.com/jloutsch/kfxgen/releases/latest
  2. Calibre → Preferences → Plugins → Load plugin from file → select the zip.
  3. Restart Calibre.
  4. Convert any book with Output format set to KFX.
Command line:
Code:
calibre-customize -a kfxgen-plugin-5.3.18.zip
Known limitations
  • On verse-heavy or image-heavy books, the Calibre conversion path can retain slightly less text than the direct-Python path (Calibre's OEB pipeline normalizes line breaks and alt-text differently).
  • TOC entries that jump within a single file via #anchor (e.g. dictionary A/B/C sub-entries) appear as separate chapters rather than in-page anchors. Reading order and content are preserved.
  • Fonts are not embedded in the file. Custom fonts render via the font installed on the Kindle (see above) — by design, but it means the font must be on the device.
  • Inline emphasis (italic / bold within a paragraph) and most source CSS typography are not yet carried through; paragraph-level styles (font size, line height, alignment, margins, headings) are. KFX supports a subset of CSS, so this is a coverage gap rather than a hard limit — tracked in [#9](https://github.com/jloutsch/kfxgen/issues/9).

I leaned heavily on jhowell's kfx input and kfx output to create this successfully, so many thanks to jhowell!

The plugin may be downloaded here.

The main page is here along with tests and security review information: https://github.com/jloutsch/kfxgen

Tests available here
jloutsch is offline   Reply With Quote
Old 06-27-2026, 10:40 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: 46,347
Karma: 29630884
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Good work. If you are willing to lift the no font embedding limitation I might be willing to merge your plugin into calibre, making it a builtin plugin after it has matured a bit and seen some testing via users.
kovidgoyal is offline   Reply With Quote
Advert
Old Yesterday, 05:12 AM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 83,920
Karma: 153649587
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
You really should properly embed this plugin in your first post like all the other plugins that calibre knows of. make it so the plugin can eventually be installed with calibre.
JSWolf is offline   Reply With Quote
Old Yesterday, 10:46 AM   #4
jloutsch
Junior Member
jloutsch began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2026
Device: Kindle Oasis, Kindle Paperwhite, Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
Good work. If you are willing to lift the no font embedding limitation I might be willing to merge your plugin into calibre, making it a builtin plugin after it has matured a bit and seen some testing via users.
My opinion was that KFX can display any custom fonts installed on the kindle, which would negate the need to embed fonts?
jloutsch is offline   Reply With Quote
Old Yesterday, 10:47 AM   #5
jloutsch
Junior Member
jloutsch began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jun 2026
Device: Kindle Oasis, Kindle Paperwhite, Kobo Libra 2
Quote:
Originally Posted by JSWolf View Post
You really should properly embed this plugin in your first post like all the other plugins that calibre knows of. make it so the plugin can eventually be installed with calibre.
I see that other posts have a zip file attached - is this what you mean by embed?
jloutsch is offline   Reply With Quote
Advert
Old Yesterday, 11:34 AM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,845
Karma: 64181416
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by jloutsch View Post
I see that other posts have a zip file attached - is this what you mean by embed?
Yes.
Beta posts are inline as they are created, then moved to post #1 or removed as relevant after user testing.
You can't edit posts yet as your post count is too low. A forum mod can move to post 1 as needed until then.

Last edited by theducks; Yesterday at 11:35 AM. Reason: note added
theducks is offline   Reply With Quote
Old Yesterday, 11:45 AM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 83,920
Karma: 153649587
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by jloutsch View Post
My opinion was that KFX can display any custom fonts installed on the kindle, which would negate the need to embed fonts?
A lot of eBooks have embedded fonts. So if you want them, they need to be allowed. KFX supports embedded fonts. So your plugin needs to support embedded fonts.

Are you going to be able to keep up with any changes Amazon makes to KFX?
JSWolf is offline   Reply With Quote
Old Yesterday, 02:10 PM   #8
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,378
Karma: 95902893
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
My interest in KFX is mostly in discovering how it works and converting from it to other formats. The KFX Output plugin was originally created to allow me to experiment with the Kindle Previewer's conversion to KPF/KFX in order to reverse engineer different aspects of that e-book format.

I have no interest in replicating the Previewer's capabilities but I do see how having an alternative to using it could be useful to others. This plugin seems like a good idea to me.
jhowell is offline   Reply With Quote
Old Yesterday, 08:27 PM   #9
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: 46,347
Karma: 29630884
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by jloutsch View Post
My opinion was that KFX can display any custom fonts installed on the kindle, which would negate the need to embed fonts?
That would imply that every book is limited to the fonts ont he kindle. Embedded have many use cases, such as showing glyphs from other writing systems, showing stylised text such as handwriting fonts, showing special symbols such as mathematical fonts etc etc
kovidgoyal is offline   Reply With Quote
Reply

Tags
conversion, kfx, plugin


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Conversion Output] KFX Output jhowell Plugins 1778 06-25-2026 12:09 PM
Fixed page KPS to KFX or blank PDF to KFX conversion? jackm8 Conversion 6 02-20-2026 02:02 PM
KFX to EPUB conversion can break page-list, while KFX Input plugin works consistently mallomar Calibre 11 07-20-2025 10:25 PM
Another EPub3/2 generator with single python file tkirke ePub 1 10-24-2012 03:57 PM
Python source for: Open Containing Folder Agama Development 1 08-10-2012 05:13 AM


All times are GMT -4. The time now is 04:34 AM.


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