mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[UI] Render metadata text with book language
Gives the book language to Text*Widget (and XText) when drawing title, authors and other metadata text. Might be needed to properly display a Japanese book title when the UI language is Chinese.
This commit is contained in:
@@ -210,10 +210,18 @@ function BookInfo:show(file, book_props)
|
||||
end
|
||||
table.insert(kv_pairs, { _("Cover image:"), _("Tap to display"), callback=viewCoverImage })
|
||||
|
||||
-- Get a chance to have title, authors... rendered with alternate
|
||||
-- glyphs for the book language (e.g. japanese book in chinese UI)
|
||||
local values_lang = nil
|
||||
if book_props.language and book_props.language ~= "" then
|
||||
values_lang = book_props.language
|
||||
end
|
||||
|
||||
local widget = KeyValuePage:new{
|
||||
title = _("Book information"),
|
||||
value_overflow_align = "right",
|
||||
kv_pairs = kv_pairs,
|
||||
values_lang = values_lang,
|
||||
}
|
||||
UIManager:show(widget)
|
||||
end
|
||||
|
||||
@@ -293,12 +293,20 @@ function BookStatusWidget:genBookInfoGroup()
|
||||
|
||||
local height = img_height
|
||||
local width = screen_width - split_span_width - img_width
|
||||
|
||||
-- Get a chance to have title and authors rendered with alternate
|
||||
-- glyphs for the book language
|
||||
local lang = nil
|
||||
if self.props.language and self.props.language ~= "" then
|
||||
lang = self.props.language
|
||||
end
|
||||
-- title
|
||||
local book_meta_info_group = VerticalGroup:new{
|
||||
align = "center",
|
||||
VerticalSpan:new{ width = height * 0.2 },
|
||||
TextBoxWidget:new{
|
||||
text = self.props.title,
|
||||
lang = lang,
|
||||
width = width,
|
||||
face = self.medium_font_face,
|
||||
alignment = "center",
|
||||
@@ -308,6 +316,7 @@ function BookStatusWidget:genBookInfoGroup()
|
||||
-- author
|
||||
local text_author = TextBoxWidget:new{
|
||||
text = self.props.authors,
|
||||
lang = lang,
|
||||
face = self.small_font_face,
|
||||
width = width,
|
||||
alignment = "center",
|
||||
|
||||
@@ -116,6 +116,7 @@ end
|
||||
local KeyValueItem = InputContainer:new{
|
||||
key = nil,
|
||||
value = nil,
|
||||
value_lang = nil,
|
||||
cface = Font:getFace("smallinfofont"),
|
||||
tface = Font:getFace("smallinfofontbold"),
|
||||
width = nil,
|
||||
@@ -162,6 +163,7 @@ function KeyValueItem:init()
|
||||
text = tvalue,
|
||||
max_width = available_width,
|
||||
face = self.cface,
|
||||
lang = self.value_lang,
|
||||
}
|
||||
local key_w_rendered = key_widget:getWidth()
|
||||
local value_w_rendered = value_widget:getWidth()
|
||||
@@ -288,6 +290,7 @@ function KeyValueItem:onHold()
|
||||
local textviewer = TextViewer:new{
|
||||
title = self.key,
|
||||
text = self.value,
|
||||
lang = self.value_lang,
|
||||
width = self.textviewer_width,
|
||||
height = self.textviewer_height,
|
||||
}
|
||||
@@ -300,6 +303,7 @@ local KeyValuePage = InputContainer:new{
|
||||
title = "",
|
||||
width = nil,
|
||||
height = nil,
|
||||
values_lang = nil,
|
||||
-- index for the first item to show
|
||||
show_page = 1,
|
||||
use_top_page_count = false,
|
||||
@@ -514,6 +518,7 @@ function KeyValuePage:_populateItems()
|
||||
width = self.item_width,
|
||||
key = entry[1],
|
||||
value = entry[2],
|
||||
value_lang = self.values_lang,
|
||||
callback = entry.callback,
|
||||
callback_back = entry.callback_back,
|
||||
textviewer_width = self.textviewer_width,
|
||||
|
||||
@@ -556,8 +556,11 @@ function ListMenuItem:update()
|
||||
end
|
||||
-- BookInfoManager:extractBookInfo() made sure
|
||||
-- to save as nil (NULL) metadata that were an empty string
|
||||
-- We provide the book language to get a chance to render title
|
||||
-- and authors with alternate glyphs for that language.
|
||||
wtitle = TextBoxWidget:new{
|
||||
text = title,
|
||||
lang = bookinfo.language,
|
||||
face = Font:getFace(fontname_title, fontsize_title),
|
||||
width = wmain_width,
|
||||
alignment = "left",
|
||||
@@ -568,6 +571,7 @@ function ListMenuItem:update()
|
||||
if authors then
|
||||
wauthors = TextBoxWidget:new{
|
||||
text = authors,
|
||||
lang = bookinfo.language,
|
||||
face = Font:getFace(fontname_authors, fontsize_authors),
|
||||
width = wmain_width,
|
||||
alignment = "left",
|
||||
|
||||
@@ -108,6 +108,7 @@ local FakeCover = FrameContainer:new{
|
||||
filename_add = nil,
|
||||
title_add = nil,
|
||||
authors_add = nil,
|
||||
book_lang = nil,
|
||||
-- these font sizes will be scaleBySize'd by Font:getFace()
|
||||
authors_font_max = 20,
|
||||
authors_font_min = 6,
|
||||
@@ -225,6 +226,7 @@ function FakeCover:init()
|
||||
if authors then
|
||||
authors_wg = TextBoxWidget:new{
|
||||
text = authors,
|
||||
lang = self.book_lang,
|
||||
face = Font:getFace("cfont", math.max(self.authors_font_max - sizedec, self.authors_font_min)),
|
||||
width = text_width,
|
||||
alignment = "center",
|
||||
@@ -234,6 +236,7 @@ function FakeCover:init()
|
||||
if title then
|
||||
title_wg = TextBoxWidget:new{
|
||||
text = title,
|
||||
lang = self.book_lang,
|
||||
face = Font:getFace("cfont", math.max(self.title_font_max - sizedec, self.title_font_min)),
|
||||
width = text_width,
|
||||
alignment = "center",
|
||||
@@ -243,6 +246,7 @@ function FakeCover:init()
|
||||
if filename then
|
||||
filename_wg = TextBoxWidget:new{
|
||||
text = filename,
|
||||
lang = self.book_lang, -- might as well use it for filename
|
||||
face = Font:getFace("cfont", math.max(self.filename_font_max - sizedec, self.filename_font_min)),
|
||||
width = text_width,
|
||||
alignment = "center",
|
||||
@@ -625,6 +629,7 @@ function MosaicMenuItem:update()
|
||||
authors = not bookinfo.ignore_meta and bookinfo.authors,
|
||||
title_add = not bookinfo.ignore_meta and title_add,
|
||||
authors_add = not bookinfo.ignore_meta and authors_add,
|
||||
book_lang = not bookinfo.ignore_meta and bookinfo.language,
|
||||
file_deleted = self.file_deleted,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user