[RTL UI] adds bidi.lua, bootstrap UI mirroring with RTL languages

Set default language (for Harfbuzz to pick up localized glyphs
in a font), default text direction, and UI element mirroring
depending on the UI language.
This commit is contained in:
poire-z
2019-12-06 22:55:33 +01:00
parent 08a5275984
commit 866c9571df
4 changed files with 262 additions and 2 deletions

View File

@@ -30,6 +30,8 @@ io.stdout:flush()
G_reader_settings = require("luasettings"):open(
DataStorage:getDataDir().."/settings.reader.lua")
local lang_locale = G_reader_settings:readSetting("language")
-- Allow quick switching to Arabic for testing RTL/UI mirroring
if os.getenv("KO_RTL") then lang_locale = "ar_AA" end
local _ = require("gettext")
if lang_locale then
_.changeLang(lang_locale)
@@ -147,6 +149,13 @@ SettingsMigration:migrateSettings(G_reader_settings)
local CanvasContext = require("document/canvascontext")
CanvasContext:init(Device)
-- UI mirroring for RTL languages, and text shaping configuration
local Bidi = require("ui/bidi")
Bidi.setup(lang_locale)
-- Avoid loading UIManager and widgets before here, as they may
-- cache Bidi mirroring settings. Check that with:
-- for name, _ in pairs(package.loaded) do print(name) end
-- User fonts override
local fontmap = G_reader_settings:readSetting("fontmap")
if fontmap ~= nil then