View Single Post
Old 02-15-2024, 11:42 AM   #7
sdothum
Enthusiast
sdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it issdothum knows what time it is
 
Posts: 36
Karma: 2062
Join Date: Oct 2021
Device: Kobo Libra 2
Quote:
Originally Posted by Sonnenfee View Post
Thanks for the clarification and explanation, @pazos.

I will take a look when I getting time for it.
KOReader is always evolving and becomes new functionality so I'm more likely prefering new releases without doing the work of changing it manually every time.

Maybe someday will be the possibility to select and change the font for the Alt status bar and Status bar directly in the KOReader menu

Thanks to jberd for giving me the right way and Frenzie for answering.
i created a couple level 2 user patches (create patches named "2-yourpatchname.lua") that hard code my desired user font for the statusbar and alt-statusbar. Like you, i wanted my reading font to also populate the header and footer portions of the page. (You will have to edit the patches and substitute your own font choice).

For the statusbar..

Code:
local Font = require("ui/font")
for k, v in pairs(Font.fontmap) do
	if k == "ffont" then
		Font.fontmap[k] = "yourfont-regular.ttf"
	elseif k == "smallffont" then
		Font.fontmap[k] = "yourfont-regular.ttf"
	elseif k == "largeffont" then
		Font.fontmap[k] = "yourfont-regular.ttf"
	end
end
A somewhat longer patch for the alt-statusbar required..

Code:
local Screen = require("device").screen
local Event = require("ui/event")
local ReaderFont = require("apps/reader/modules/readerfont")
ReaderFont.onReadSettings = function(self)
	self.font_face = "yourfont"  -- your reading font (text body)
	self.ui.document:setFontFace(self.font_face)
	self.header_font_face = "yourfont"  -- your alt-statusbar font
	self.ui.document:setHeaderFont(self.header_font_face)
	self.ui.document:setFontSize(Screen:scaleBySize(self.configurable.font_size))
	self.ui.document:setFontBaseWeight(self.configurable.font_base_weight)
	self.ui.document:setFontHinting(self.configurable.font_hinting)
	self.ui.document:setFontKerning(self.configurable.font_kerning)
	self.ui.document:setWordSpacing(self.configurable.word_spacing)
	self.ui.document:setWordExpansion(self.configurable.word_expansion)
	self.ui.document:setCJKWidthScaling(self.configurable.cjk_width_scaling)
	self.ui.document:setInterlineSpacePercent(self.configurable.line_spacing)
	self.ui.document:setGammaIndex(self.configurable.font_gamma)
	table.insert(self.ui.postInitCallback, function()
		self.ui:handleEvent(Event:new("UpdatePos"))
	end)
end
This patch is a bit hacky of the function it replaces, omitting self:updateFontFamilyFonts().

You can find my dotfiles here,

i am not sure if there are any negative side effects -- other parts of KOReader that may be impacted by these overrides -- but they work for me.

Last edited by sdothum; 02-16-2024 at 07:23 AM. Reason: Correction to 'header_font"
sdothum is offline   Reply With Quote