Hi.
I found an issue: setIntProperty and setStringProperty invoke propsApply, which resets interline space, gamma, and perhaps some over settings to their defaults. Below a fix for interline space and gamma.
Code:
diff -rupN koreader_orig/base/cre.cpp koreader/base/cre.cpp
--- koreader_orig/base/cre.cpp 2014-10-27 02:37:53.273630266 +0100
+++ koreader/base/cre.cpp 2014-10-27 03:31:56.722246829 +0100
@@ -386,10 +386,18 @@ static int getGammaIndex(lua_State *L) {
}
static int setGammaIndex(lua_State *L) {
- int index = luaL_checkint(L, 1);
+ CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
+ int index = luaL_checkint(L, 2);
fontMan->SetGammaIndex(index);
+ double gamma = fontMan->GetGamma();
+ char value[5];
+ snprintf(value, 5, "%.2f", gamma);
+
+ CRPropRef props = doc->text_view->propsGetCurrent();
+ props->setString("font.gamma", value);
+
return 0;
}
@@ -1382,7 +1390,6 @@ static const struct luaL_Reg cre_func[]
{"newDocView", newDocView},
{"getFontFaces", getFontFaces},
{"getGammaIndex", getGammaIndex},
- {"setGammaIndex", setGammaIndex},
{"registerFont", registerFont},
{"getHyphDictList", getHyphDictList},
{"getSelectedHyphDict", getSelectedHyphDict},
@@ -1423,6 +1430,7 @@ static const struct luaL_Reg credocument
{"setVisiblePageCount", setVisiblePageCount},
{"adjustFontSizes", adjustFontSizes},
{"setBatteryState", setBatteryState},
+ {"setGammaIndex", setGammaIndex},
/* --- control methods ---*/
{"gotoPage", gotoPage},
{"gotoPercent", gotoPercent},
diff -rupN koreader_orig/base/kpvcrlib/crengine/crengine/src/lvdocview.cpp koreader/base/kpvcrlib/crengine/crengine/src/lvdocview.cpp
--- koreader_orig/base/kpvcrlib/crengine/crengine/src/lvdocview.cpp 2014-10-27 03:18:19.839703518 +0100
+++ koreader/base/kpvcrlib/crengine/crengine/src/lvdocview.cpp 2014-10-27 03:41:44.835875863 +0100
@@ -3125,9 +3125,13 @@ static int findBestFit(LVArray<int> & v,
void LVDocView::setDefaultInterlineSpace(int percent) {
LVLock lock(getMutex());
- REQUEST_RENDER("setDefaultInterlineSpace")
+ int oldpercent = m_def_interline_space;
m_def_interline_space = percent;
- _posIsSet = false;
+ if (oldpercent != percent) {
+ propsGetCurrent()->setInt(PROP_INTERLINE_SPACE, m_def_interline_space);
+ _posIsSet = false;
+ REQUEST_RENDER("setDefaultInterlineSpace")
+ }
// goToBookmark( _posBookmark);
// updateBookMarksRanges();
}
diff -rupN koreader_orig/frontend/document/credocument.lua koreader/frontend/document/credocument.lua
--- koreader_orig/frontend/document/credocument.lua 2014-10-27 02:36:29.601678705 +0100
+++ koreader/frontend/document/credocument.lua 2014-10-27 03:33:36.817599779 +0100
@@ -361,7 +361,7 @@ end
function CreDocument:setGammaIndex(index)
DEBUG("CreDocument: set gamma index", index)
- cre.setGammaIndex(index)
+ self._document:setGammaIndex(index)
end
function CreDocument:setStyleSheet(new_css)