mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix cannot get word box in last page of a chapter
This commit is contained in:
@@ -137,18 +137,27 @@ end
|
||||
|
||||
function CreDocument:getWordFromPosition(pos)
|
||||
local word_box = self._document:getWordFromPosition(pos.x, pos.y)
|
||||
DEBUG("CreDocument: get word box", word_box)
|
||||
local text_range = self._document:getTextFromPositions(pos.x, pos.y, pos.x, pos.y)
|
||||
DEBUG("CreDocument: get text range", text_range)
|
||||
local wordbox = {
|
||||
word = text_range.text == "" and word_box.word or text_range.text,
|
||||
page = self._document:getCurrentPage(),
|
||||
}
|
||||
if word_box.word then
|
||||
return {
|
||||
word = text_range.text == "" and word_box.word or text_range.text,
|
||||
page = self._document:getCurrentPage(),
|
||||
sbox = Geom:new{
|
||||
x = word_box.x0, y = word_box.y0,
|
||||
w = word_box.x1 - word_box.x0,
|
||||
h = word_box.y1 - word_box.y0,
|
||||
}
|
||||
wordbox.sbox = Geom:new{
|
||||
x = word_box.x0, y = word_box.y0,
|
||||
w = word_box.x1 - word_box.x0,
|
||||
h = word_box.y1 - word_box.y0,
|
||||
}
|
||||
else
|
||||
-- dummy word box
|
||||
wordbox.sbox = Geom:new{
|
||||
x = pos.x, y = pos.y,
|
||||
w = 20, h = 20,
|
||||
}
|
||||
end
|
||||
return wordbox
|
||||
end
|
||||
|
||||
function CreDocument:getTextFromPositions(pos0, pos1)
|
||||
|
||||
Reference in New Issue
Block a user