Make dictionary margin depend on font size (#5865)

The default left margin on blockquote and dd is `40px`, but unfortunately that doesn't scale. rem is calculated using a hardcoded16px, so em or % is the best compromise in this case.

PS If we assume 1em = 16px then 40px is actually 2.5em, not 1em. This reduction in indentation is mainly intended for the benefit of smaller E Ink devices.

Closes <https://github.com/koreader/koreader/issues/5859>.
This commit is contained in:
Frans de Jonge
2020-02-15 12:23:22 +01:00
committed by GitHub
parent ecbfb4d44c
commit 159fe03f47

View File

@@ -190,7 +190,20 @@ function DictQuickLookup:getHtmlDictionaryCss()
line-height: 1.3;
]]..css_justify..[[
}
blockquote, dd {
margin: 0 1em;
}
]]
-- MuPDF doesn't currently scale CSS pixels, so we have to use a font-size based measurement.
-- Unfortunately MuPDF doesn't properly support `rem` either, which it bases on a hard-coded
-- value of `16px`, so we have to go with `em` (or `%`).
--
-- These `em`-based margins can vary slightly, but it's the best available compromise.
--
-- We also keep left and right margin the same so it'll display as expected in RTL.
-- Because MuPDF doesn't currently support `margin-start`, this results in a slightly
-- unconventional but hopefully barely noticeable right margin for <dd>.
if self.css then
return css .. self.css