mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fix: truncateTextByWidth() should respect kerning and bold (#3139)
This commit is contained in:
@@ -241,7 +241,7 @@ end
|
||||
|
||||
local ellipsis, space = "…", " "
|
||||
local ellipsis_width, space_width
|
||||
function RenderText:truncateTextByWidth(text, face, max_width, prepend_space)
|
||||
function RenderText:truncateTextByWidth(text, face, max_width, kerning, bold, prepend_space)
|
||||
if not ellipsis_width then
|
||||
ellipsis_width = self:sizeUtf8Text(0, max_width, face, ellipsis).x
|
||||
end
|
||||
@@ -249,7 +249,7 @@ function RenderText:truncateTextByWidth(text, face, max_width, prepend_space)
|
||||
space_width = self:sizeUtf8Text(0, max_width, face, space).x
|
||||
end
|
||||
local new_txt_width = max_width - ellipsis_width - space_width
|
||||
local sub_txt = self:getSubTextByWidth(text, face, new_txt_width)
|
||||
local sub_txt = self:getSubTextByWidth(text, face, new_txt_width, kerning, bold)
|
||||
if prepend_space then
|
||||
return space.. sub_txt .. ellipsis
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user