From 6baa2af5fb87b6decb525cd58cf413ee1f647cb3 Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 1 Nov 2019 23:07:41 +0100 Subject: [PATCH] cre: use 'best' (Harfbuzz) as the default kerning method (#5553) It might be slower, but is needed to properly display books in arabic, indic... Also bump crengine: use FreeType "light" hinting algorithm, which hints on the y-axis only (and so avoid messing with advances and kerning on the x-axis). --- base | 2 +- frontend/apps/reader/modules/readerfont.lua | 2 +- frontend/ui/data/creoptions.lua | 4 ++-- spec/unit/readerfooter_spec.lua | 4 ++-- spec/unit/readerhighlight_spec.lua | 6 +++--- spec/unit/readerlink_spec.lua | 4 ++-- spec/unit/readerrolling_spec.lua | 6 +++--- spec/unit/readertoc_spec.lua | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/base b/base index db0f8e31f..8840d09cc 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit db0f8e31feb02710a18352b97113fb49286fe2ae +Subproject commit 8840d09cc8134bfa042f7b0ef5ce38ae592f2987 diff --git a/frontend/apps/reader/modules/readerfont.lua b/frontend/apps/reader/modules/readerfont.lua index 974dae79a..8c1d61371 100644 --- a/frontend/apps/reader/modules/readerfont.lua +++ b/frontend/apps/reader/modules/readerfont.lua @@ -127,7 +127,7 @@ function ReaderFont:onReadSettings(config) self.ui.document:setFontHinting(self.font_hinting) self.font_kerning = config:readSetting("font_kerning") - or G_reader_settings:readSetting("copt_font_kerning") or 1 -- freetype (default in cre.cpp) + or G_reader_settings:readSetting("copt_font_kerning") or 3 -- harfbuzz (slower, but needed for proper arabic) self.ui.document:setFontKerning(self.font_kerning) self.space_condensing = config:readSetting("space_condensing") diff --git a/frontend/ui/data/creoptions.lua b/frontend/ui/data/creoptions.lua index aa9708bdc..f356d0519 100644 --- a/frontend/ui/data/creoptions.lua +++ b/frontend/ui/data/creoptions.lua @@ -385,7 +385,7 @@ Note that your selected font size is not affected by this setting.]]), name_text = S.FONT_KERNING, toggle = {S.OFF, S.FAST, S.GOOD, S.BEST}, values = {0, 1, 2, 3}, - default_value = 1, + default_value = 3, args = {0, 1, 2, 3}, event = "SetFontKerning", name_text_hold_callback = optionsutil.showValues, @@ -394,7 +394,7 @@ Note that your selected font size is not affected by this setting.]]), - off: no kerning. - fast: use FreeType's kerning implementation (no ligatures). - good: use HarfBuzz's light kerning implementation (faster than full but no ligatures and limited support for non-western scripts) -- best: use HarfBuzz's full kerning implementation (slower, but may support ligatures with some fonts). +- best: use HarfBuzz's full kerning implementation (slower, but may support ligatures with some fonts; also needed to properly display joined arabic glyphs and some other scripts). (Font Hinting may need to be adjusted for the best result with either kerning implementation.)]]), }, diff --git a/spec/unit/readerfooter_spec.lua b/spec/unit/readerfooter_spec.lua index 595b9e03f..8ccd64576 100644 --- a/spec/unit/readerfooter_spec.lua +++ b/spec/unit/readerfooter_spec.lua @@ -317,8 +317,8 @@ describe("Readerfooter module", function() assert.are.same(359, footer.text_width) footer:onPageUpdate(100) - assert.are.same(189, footer.progress_bar.width) - assert.are.same(391, footer.text_width) + assert.are.same(197, footer.progress_bar.width) + assert.are.same(383, footer.text_width) end) it("should support chapter markers", function() diff --git a/spec/unit/readerhighlight_spec.lua b/spec/unit/readerhighlight_spec.lua index 34e39294f..32bc41b10 100644 --- a/spec/unit/readerhighlight_spec.lua +++ b/spec/unit/readerhighlight_spec.lua @@ -99,9 +99,9 @@ describe("Readerhighlight module", function() end) it("should response on tap gesture", function() tap_highlight_text(readerui, - Geom:new{ x = 151, y = 115 }, - Geom:new{ x = 300, y = 285 }, - Geom:new{ x = 120, y = 240 }) + Geom:new{ x = 130, y = 100 }, + Geom:new{ x = 350, y = 395 }, + Geom:new{ x = 80, y = 265 }) Screen:shot("screenshots/reader_tap_highlight_text_epub.png") end) end) diff --git a/spec/unit/readerlink_spec.lua b/spec/unit/readerlink_spec.lua index 9d85198b9..e422febc4 100644 --- a/spec/unit/readerlink_spec.lua +++ b/spec/unit/readerlink_spec.lua @@ -18,7 +18,7 @@ describe("ReaderLink module", function() document = DocumentRegistry:openDocument(sample_epub), } readerui.rolling:onGotoPage(4) - readerui.link:onTap(nil, {pos = {x = 340, y = 110}}) + readerui.link:onTap(nil, {pos = {x = 320, y = 120}}) assert.is.same(36, readerui.rolling.current_page) end) @@ -57,7 +57,7 @@ describe("ReaderLink module", function() document = DocumentRegistry:openDocument(sample_epub), } readerui.rolling:onGotoPage(4) - readerui.link:onTap(nil, {pos = {x = 340, y = 110}}) + readerui.link:onTap(nil, {pos = {x = 320, y = 120}}) assert.is.same(36, readerui.rolling.current_page) readerui.link:onGoBackLink() assert.is.same(4, readerui.rolling.current_page) diff --git a/spec/unit/readerrolling_spec.lua b/spec/unit/readerrolling_spec.lua index 5a6b1b74e..aff0ae458 100644 --- a/spec/unit/readerrolling_spec.lua +++ b/spec/unit/readerrolling_spec.lua @@ -186,13 +186,13 @@ describe("Readerrolling module", function() it("should show pages for different word gap", function() readerui.document:setSpaceCondensing(100) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) - assert.are.same(251, readerui.document:getPageCount()) + assert.are.same(231, readerui.document:getPageCount()) readerui.document:setSpaceCondensing(75) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) - assert.are.same(242, readerui.document:getPageCount()) + assert.are.same(229, readerui.document:getPageCount()) readerui.document:setSpaceCondensing(50) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) - assert.are.same(233, readerui.document:getPageCount()) + assert.are.same(225, readerui.document:getPageCount()) end) end) diff --git a/spec/unit/readertoc_spec.lua b/spec/unit/readertoc_spec.lua index 45e2bfdc9..997fda5bf 100644 --- a/spec/unit/readertoc_spec.lua +++ b/spec/unit/readertoc_spec.lua @@ -25,7 +25,7 @@ describe("Readertoc module", function() title = toc:getTocTitleByPage(60) DEBUG("toc", toc.toc) assert.is.equal("SCENE V. A hall in Capulet's house.", title) - title = toc:getTocTitleByPage(187) + title = toc:getTocTitleByPage(177) assert.is.equal("SCENE I. Friar Laurence's cell.", title) end) describe("getTocTicks API", function() @@ -68,12 +68,12 @@ describe("Readertoc module", function() end) it("should get page left of chapter", function() assert.truthy(toc:getChapterPagesLeft(10, 0) > 10) - assert.truthy(toc:getChapterPagesLeft(97, 0) > 10) + assert.truthy(toc:getChapterPagesLeft(90, 0) > 10) assert.are.same(nil, toc:getChapterPagesLeft(290, 0)) end) it("should get page done of chapter", function() assert.truthy(toc:getChapterPagesDone(11, 0) < 5) - assert.truthy(toc:getChapterPagesDone(95, 0) < 5) + assert.truthy(toc:getChapterPagesDone(83, 0) < 5) assert.truthy(toc:getChapterPagesDone(290, 0) > 10) end) describe("collasible TOC", function()