mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1 from chrox/master
fix several local calls of Math.round
This commit is contained in:
@@ -3,6 +3,7 @@ local CacheItem = require("cacheitem")
|
||||
local TileCacheItem = require("document/tilecacheitem")
|
||||
local Geom = require("ui/geometry")
|
||||
local Configurable = require("ui/reader/configurable")
|
||||
local Math = require("optmath")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
--[[
|
||||
@@ -118,7 +119,7 @@ function Document:getPageBBox(pageno)
|
||||
--DEBUG("bbox from", pageno)
|
||||
return bbox
|
||||
else
|
||||
local oddEven = math.oddEven(pageno)
|
||||
local oddEven = Math.oddEven(pageno)
|
||||
bbox = self.bbox[oddEven] -- odd/even
|
||||
end
|
||||
if bbox ~= nil then -- last used up to this page
|
||||
|
||||
@@ -4,7 +4,7 @@ local CacheItem = require("cacheitem")
|
||||
local Screen = require("ui/screen")
|
||||
local Geom = require("ui/geometry")
|
||||
local TileCacheItem = require("document/tilecacheitem")
|
||||
local Dbg = require("dbg")
|
||||
local DEBUG = require("dbg")
|
||||
-- TBD: KOPTContext
|
||||
|
||||
local KoptInterface = {
|
||||
@@ -58,6 +58,7 @@ function KoptInterface:createContext(doc, pageno, bbox)
|
||||
lang == "jpn" or lang == "kor" then
|
||||
kc:setCJKChar()
|
||||
end
|
||||
DEBUG("configurable", doc.configurable)
|
||||
kc:setLanguage(lang)
|
||||
kc:setTrim(doc.configurable.trim_page)
|
||||
kc:setWrap(doc.configurable.text_wrap)
|
||||
@@ -76,7 +77,7 @@ function KoptInterface:createContext(doc, pageno, bbox)
|
||||
kc:setLineSpacing(doc.configurable.line_spacing)
|
||||
kc:setWordSpacing(doc.configurable.word_spacing)
|
||||
if bbox then kc:setBBox(bbox.x0, bbox.y0, bbox.x1, bbox.y1) end
|
||||
if Dbg.is_on then kc:setDebug() end
|
||||
if DEBUG.is_on then kc:setDebug() end
|
||||
return kc
|
||||
end
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ local KoptOptions = {
|
||||
name_text = S.AUTO_STRAIGHTEN,
|
||||
toggle = {S.ZERO_DEG, S.FIVE_DEG, S.TEN_DEG},
|
||||
values = {0, 5, 10},
|
||||
default_value = S.DKOPTREADER_CONFIG_AUTOAIGHTEN,
|
||||
default_value = DKOPTREADER_CONFIG_AUTO_STRAIGHTEN,
|
||||
show = false,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ local GestureDetector = require("ui/gesturedetector")
|
||||
local Event = require("ui/event")
|
||||
local TimeVal = require("ui/timeval")
|
||||
local Screen = require("ui/screen")
|
||||
local Math = require("optmath")
|
||||
local Dbg = require("dbg")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
@@ -304,9 +305,9 @@ function Input:init()
|
||||
--@TODO handle coordinates properly after
|
||||
--screen rotate. (houqp)
|
||||
if ev.code == ABS_MT_POSITION_X then
|
||||
ev.value = math.round(ev.value * (600/4095))
|
||||
ev.value = Math.round(ev.value * (600/4095))
|
||||
elseif ev.code == ABS_MT_POSITION_Y then
|
||||
ev.value = math.round(ev.value * (800/4095))
|
||||
ev.value = Math.round(ev.value * (800/4095))
|
||||
end
|
||||
end
|
||||
return ev
|
||||
|
||||
@@ -11,6 +11,7 @@ local HorizontalGroup = require("ui/widget/horizontalgroup")
|
||||
local BBoxWidget = require("ui/widget/bboxwidget")
|
||||
local HorizontalSpan = require("ui/widget/horizontalspan")
|
||||
local Button = require("ui/widget/button")
|
||||
local Math = require("optmath")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
local PageCropDialog = VerticalGroup:new{
|
||||
@@ -112,7 +113,7 @@ function ReaderCropping:onConfirmPageCrop()
|
||||
self.ui:handleEvent(Event:new("BBoxUpdate", new_bbox))
|
||||
local pageno = self.view.state.page
|
||||
self.document.bbox[pageno] = new_bbox
|
||||
self.document.bbox[math.oddEven(pageno)] = new_bbox
|
||||
self.document.bbox[Math.oddEven(pageno)] = new_bbox
|
||||
self:exitPageCrop(true)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ function ReaderDictionary:showDict(results)
|
||||
dialog = self.dialog,
|
||||
results = results,
|
||||
dictionary = self.default_dictionary,
|
||||
width = Screen:getWidth() - screen:scaleByDPI(120),
|
||||
width = Screen:getWidth() - Screen:scaleByDPI(120),
|
||||
height = Screen:getHeight()*0.43,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
local Font = require("ui/font")
|
||||
local Screen = require("ui/screen")
|
||||
local Cache = require("cache")
|
||||
local CacheItem = require("cacheitem")
|
||||
local DEBUG = require("dbg")
|
||||
@@ -72,7 +74,7 @@ function RenderText:getGlyph(face, charcode, bgcolor, fgcolor)
|
||||
if face.ftface:checkGlyph(charcode) == 0 then
|
||||
for index, font in pairs(Font.fallbacks) do
|
||||
-- rescale face size by DPI since it will be scaled in getFace again
|
||||
local fb_face = Font:getFace(font, rescaleByDPI(face.size))
|
||||
local fb_face = Font:getFace(font, Screen:rescaleByDPI(face.size))
|
||||
if fb_face.ftface:checkGlyph(charcode) ~= 0 then
|
||||
rendered_glyph = fb_face.ftface:renderGlyph(charcode, bgcolor, fgcolor)
|
||||
DEBUG("fallback to font", font)
|
||||
|
||||
@@ -4,6 +4,7 @@ local Event = require("ui/event")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("ui/device")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local Math = require("optmath")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
--[[
|
||||
@@ -73,10 +74,10 @@ function BBoxWidget:getScreenBBox(page_bbox)
|
||||
local scale = self.view.state.zoom
|
||||
local screen_offset = self.view.state.offset
|
||||
--DEBUG("screen offset in page_to_screen", screen_offset)
|
||||
bbox.x0 = math.round(page_bbox.x0 * scale + screen_offset.x)
|
||||
bbox.y0 = math.round(page_bbox.y0 * scale + screen_offset.y)
|
||||
bbox.x1 = math.round(page_bbox.x1 * scale + screen_offset.x)
|
||||
bbox.y1 = math.round(page_bbox.y1 * scale + screen_offset.y)
|
||||
bbox.x0 = Math.round(page_bbox.x0 * scale + screen_offset.x)
|
||||
bbox.y0 = Math.round(page_bbox.y0 * scale + screen_offset.y)
|
||||
bbox.x1 = Math.round(page_bbox.x1 * scale + screen_offset.x)
|
||||
bbox.y1 = Math.round(page_bbox.y1 * scale + screen_offset.y)
|
||||
return bbox
|
||||
end
|
||||
|
||||
@@ -86,10 +87,10 @@ function BBoxWidget:getPageBBox(screen_bbox)
|
||||
local scale = self.view.state.zoom
|
||||
local screen_offset = self.view.state.offset
|
||||
--DEBUG("screen offset in screen_to_page", screen_offset)
|
||||
bbox.x0 = math.round((screen_bbox.x0 - screen_offset.x) / scale)
|
||||
bbox.y0 = math.round((screen_bbox.y0 - screen_offset.y) / scale)
|
||||
bbox.x1 = math.round((screen_bbox.x1 - screen_offset.x) / scale)
|
||||
bbox.y1 = math.round((screen_bbox.y1 - screen_offset.y) / scale)
|
||||
bbox.x0 = Math.round((screen_bbox.x0 - screen_offset.x) / scale)
|
||||
bbox.y0 = Math.round((screen_bbox.y0 - screen_offset.y) / scale)
|
||||
bbox.x1 = Math.round((screen_bbox.x1 - screen_offset.x) / scale)
|
||||
bbox.y1 = Math.round((screen_bbox.y1 - screen_offset.y) / scale)
|
||||
return bbox
|
||||
end
|
||||
|
||||
@@ -117,7 +118,7 @@ function BBoxWidget:adjustScreenBBox(ges, relative)
|
||||
left_center, right_center,
|
||||
bottom_left, bottom_center, bottom_right,
|
||||
}
|
||||
local _, nearest = math.tmin(anchors, function(a,b)
|
||||
local _, nearest = Math.tmin(anchors, function(a,b)
|
||||
return a:distance(ges.pos) > b:distance(ges.pos)
|
||||
end)
|
||||
--DEBUG("nearest anchor", nearest)
|
||||
@@ -183,10 +184,10 @@ function BBoxWidget:adjustScreenBBox(ges, relative)
|
||||
end
|
||||
end
|
||||
self.screen_bbox = {
|
||||
x0 = math.round(upper_left.x),
|
||||
y0 = math.round(upper_left.y),
|
||||
x1 = math.round(bottom_right.x),
|
||||
y1 = math.round(bottom_right.y)
|
||||
x0 = Math.round(upper_left.x),
|
||||
y0 = Math.round(upper_left.y),
|
||||
x1 = Math.round(bottom_right.x),
|
||||
y1 = Math.round(bottom_right.y)
|
||||
}
|
||||
|
||||
UIManager.repaint_all = true
|
||||
|
||||
@@ -81,3 +81,5 @@ function ScrollTextWidget:onSwipe(arg, ges)
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
return true
|
||||
end
|
||||
|
||||
return ScrollTextWidget
|
||||
|
||||
Reference in New Issue
Block a user