View Single Post
Old 12-23-2024, 07:46 PM   #1
jackm8
Addict
jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.jackm8 ought to be getting tired of karma fortunes by now.
 
jackm8's Avatar
 
Posts: 335
Karma: 3000000
Join Date: Nov 2015
Device: none
Tutorial: Reducing line spacing in Kindle readers

Default 'Spacing' settings are too wide for many people on its narrowest setting. Here's what I use to fix this. This process is not modifying line spacing, it's achieving the look of smaller line spacing by increasing scale of fonts files. All that's needed is uploading a modified custom font file to the device, selecting it, and it should work on all reflowable books that Amazon supports. This solution works on every book in every format that supports custom fonts. It works on store bought books, and it works on sideloaded books.

It should also work on every reader that supports custom fonts, but it's really not needed on others, because they tend to support custom reading apps that allow smaller line spacing settings, or their default readers support such settings. It's also possible to modify line spacing directly on epub books, because style commands of the "line-height:" family work on them. Kindle simply ignores this setting once epub is converted to one of it's formats. I think that 'line-height' command works on azw3 format, but then you're missing out on a few goodies that kfx format supports, like native cover thumbnails, and it's only viable for sideloaded books.




Requirements:
Spoiler:
- Windows, Linux or Mac and some knowledge on how to work with files.
- FontForge program: https://fontforge.org/en-US/ (freeware)
- Custom font files: Use your favourite fonts. It's also possible to use default Amazon fonts, by downloading them from their site, modifying them and adding them into custom fonts folder.
- Any Kindle that supports custom fonts.



Instructions:
Spoiler:
- Open FontForge:
- File -> Open (Ctrl+O) — Open your font file
- Encoding -> Compact — This will hide empty glyphs, and speed up the process.
- Select all glyphs: Edit -> Select -> Select All (Ctrl+A) — Glyphs must be selected for adjustments to be made.
- Window -> New Metrics Window (Ctrl+K). — I use this to preview changed. Input some text into the smaller top window, and it'll show a preview. Top and bottom of fonts can overlap in preview, we want this. They should not overlap each other in width, though.
- While all Glyphs are selected: Element -> Transform:
— Origin: Glyph Origin (make sure that this dialogue is set to 'Glyph Origin')
— Scale Uniformly (100% means no change, 130% scales font by 30%. I tend to get best results at 120% scaling. With values of around 110-150% also being usable. Higher values mean smaller space between lines. At 200%, lines will certainly overlap on every font.
— transfer all layers (off)
— transform guide layers too (off)
— transform width too (on)
— transform kerning classes too (on)
— transform simple positioning ...... (on)
— round to int (off)
- Even though 'transfer width' automatically changes width of glyphs, it's occasionally still needs to be adjusted a little. Larger scale requires larger width changes. Check 'New Metrics Window' input a few all caps sentences, and a few words to see changes that were made then proceed to the next step if there are problems.
- If fonts overlap, increase width of glyphs: Metrics -> Set Width (Ctrl+Shift+L) — Do this in main FontForge window, not in New Metrics Window. Select "Increment Width by:" 20 to 50 for 130% scale is usually enough. IMPORTANT: This process can be very CPU intensive for font files with many glyphs, and can take minutes on a desktop. Just leave it open until it finishes, then you should see the changes immediately in the 'Metrics Window'. Fine tune fonts with further instances of "Set Width" if needed. Dialogue accepts minus values as well. Metrics -> Auto Width can be used to achieve similar results, I just haven't tested it thoroughly.
- After all gyphs are processed: Element -> Font info (Ctrl+Shift+F). This step names fonts. It's optional, but a good practice in organising fonts. Only change "PS Names" entries. I like to keep modified and original font on my device. I just add scale by which I increased fonts at the end of each "Footname", "Family Name", and "Name for Humans". "Fontname" doesn't accept spaces. After changes are made, you may be asked to auto change XUID, you may retain or auto generate this, it should have no effect on Kindle readers.
- Export font as a new file: File -> Generate Fonts (Ctrl+Shift+G).
— Select 'OpenType (CFF)'
— Name new font. —
— It's not unusual to get errors, just click 'Generate'
— New font will be created in the same directory as the source font.
- Repeat process for Italic and Bold fonts of same font family if needed. Italics tend to be used in books, while bolds are very rare. In case that there is no Italic font family, or there is one but is named incorrectly, Kindle will automatically slant normal fonts. For Serif fonts, this isn't ideal, but San-Serif fonts usually don't look that different, so they're often omitted. Some care needs to be taken when naming Italic and Bold fonts so they all fall under the same font family. Under 'Font info' dialogue, 'Family Name' must be the same. And when fonts are generated, it's best to have Italic and Bold font named exactly the same just with -Italic at the end of the file. -It, -Bold, -BoldIt can also be used. Just use some common sense here, and name fonts in the same way as your source fonts are.
- Copy new fonts to Kindle into Fonts directory, and test them out on a few books. Look at italic passages, how fonts fare with all caps titles, and in different layout settings.

If all goes well, you're now in possession of a Kinde reader that is capable of displaying sensible line spacing.




Drawbacks and notes:

Spoiler:

- With introduction of WinterBreak and ability of installing Koreader on all current kindles, usability of this process is reduced to people that don't want to jailbreak their kindle. Koreader has various font settings that are more practical than modfying fonts.
- This process needs to be done for every font that you use, and for all font family in use. For serif fonts this means at least a regular version and italic version.
- Scaling is automatic, it may cause fonts to look slightly different at times.
- Because font scale is increased, this effects font size setting on the device. Smallest font size settings will be larger, largest will be even larger. The amount of Scaling that is input in FontForge effects this a lot. Going with Scale of 200%, for example, will give some silly results. Though it's possible to get something usable out of them by selecting wider line spacing settings in the device.
- Font names of adjusted fonts in font select window on devices are oversized.
- Spacing between paragraphs is also reduced.
- Wordwise works, but spacing remains the same. Fonts for definitions appear smaller.
- Process isn't perfect. Many fonts have finely tuned glyph widths. Scaling and expanding width of glyphs affects the look of fonts.



Threads that talk about this issue and some links:



Some Before/After screenshots from my Kindle. Because fonts are scaled, font size settings differ. I tried to match some samples, but it was never possible to get them exactly the same. It should give and idea what to expect. There's also a font zip file in attachments with eight fonts, that I've scaled by value of 120 to 130%. All fonts scaled are freeware, or open source. Links to original fonts are provided in the links section.

That's it. I hope someone finds it useful. I may add a few more screenshots and fix some typos, in the meantime, have a Happy Christmas everyone.


POST HISTORY:
1.0 Initial post
1.1 Included Linux as optional requirement
1.2 More fonts, more samples. Clarified width step. I previously stated that all fonts need to have width corrected. It turns out that this is incorrect, as most don't require this step.
Attached Thumbnails
Click image for larger version

Name:	spacing s1.jpg
Views:	330
Size:	521.7 KB
ID:	212628   Click image for larger version

Name:	spacing s2 wordwise.jpg
Views:	281
Size:	411.1 KB
ID:	212629   Click image for larger version

Name:	spacing s3 bookerly.jpg
Views:	276
Size:	449.3 KB
ID:	212630   Click image for larger version

Name:	w happens w no italy.jpg
Views:	276
Size:	365.8 KB
ID:	212631   Click image for larger version

Name:	adobe caslon comp.jpg
Views:	168
Size:	968.3 KB
ID:	212773   Click image for larger version

Name:	chareink comp.jpg
Views:	193
Size:	1.08 MB
ID:	212775   Click image for larger version

Name:	cormorant compared.jpg
Views:	154
Size:	1.41 MB
ID:	212776   Click image for larger version

Name:	bernhard single.jpg
Views:	175
Size:	796.5 KB
ID:	212777   Click image for larger version

Name:	eb garamond.jpg
Views:	164
Size:	978.8 KB
ID:	212778   Click image for larger version

Name:	questrial single.jpg
Views:	149
Size:	802.5 KB
ID:	212779  
Attached Files
File Type: zip Scaled Fonts.zip (5.92 MB, 169 views)

Last edited by jackm8; 01-02-2025 at 01:29 PM.
jackm8 is offline   Reply With Quote