mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
use debug to print debug info
This commit is contained in:
@@ -46,7 +46,7 @@ end
|
||||
|
||||
function sizeUtf8Text(x, width, face, text, kerning)
|
||||
if text == nil then
|
||||
print("# sizeUtf8Text called without text");
|
||||
debug("# sizeUtf8Text called without text");
|
||||
return
|
||||
end
|
||||
-- may still need more adaptive pen placement when kerning,
|
||||
@@ -55,7 +55,6 @@ function sizeUtf8Text(x, width, face, text, kerning)
|
||||
local pen_y_top = 0
|
||||
local pen_y_bottom = 0
|
||||
local prevcharcode = 0
|
||||
--print("----------------- text:"..text)
|
||||
for uchar in string.gfind(text, "([%z\1-\127\194-\244][\128-\191]*)") do
|
||||
if pen_x < (width - x) then
|
||||
local charcode = util.utf8charcode(uchar)
|
||||
@@ -63,14 +62,14 @@ function sizeUtf8Text(x, width, face, text, kerning)
|
||||
if kerning and prevcharcode then
|
||||
local kern = face.ftface:getKerning(prevcharcode, charcode)
|
||||
pen_x = pen_x + kern
|
||||
--print("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." kern:"..kern)
|
||||
--debug("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." kern:"..kern)
|
||||
else
|
||||
--print("curr:"..string.char(charcode))
|
||||
--debug("curr:"..string.char(charcode))
|
||||
end
|
||||
pen_x = pen_x + glyph.ax
|
||||
pen_y_top = math.max(pen_y_top, glyph.t)
|
||||
pen_y_bottom = math.max(pen_y_bottom, glyph.bb:getHeight() - glyph.t)
|
||||
--print("ax:"..glyph.ax.." t:"..glyph.t.." r:"..glyph.r.." h:"..glyph.bb:getHeight().." w:"..glyph.bb:getWidth().." yt:"..pen_y_top.." yb:"..pen_y_bottom)
|
||||
--debug("ax:"..glyph.ax.." t:"..glyph.t.." r:"..glyph.r.." h:"..glyph.bb:getHeight().." w:"..glyph.bb:getWidth().." yt:"..pen_y_top.." yb:"..pen_y_bottom)
|
||||
prevcharcode = charcode
|
||||
end
|
||||
end
|
||||
@@ -79,7 +78,7 @@ end
|
||||
|
||||
function renderUtf8Text(buffer, x, y, face, text, kerning)
|
||||
if text == nil then
|
||||
print("# renderUtf8Text called without text");
|
||||
debug("# renderUtf8Text called without text");
|
||||
return 0
|
||||
end
|
||||
-- may still need more adaptive pen placement when kerning,
|
||||
@@ -93,10 +92,10 @@ function renderUtf8Text(buffer, x, y, face, text, kerning)
|
||||
if kerning and prevcharcode then
|
||||
local kern = face.ftface:getKerning(prevcharcode, charcode)
|
||||
pen_x = pen_x + kern
|
||||
--print("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." pen_x:"..pen_x.." kern:"..kern)
|
||||
--debug("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." pen_x:"..pen_x.." kern:"..kern)
|
||||
buffer:addblitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight())
|
||||
else
|
||||
--print(" curr:"..string.char(charcode))
|
||||
--debug(" curr:"..string.char(charcode))
|
||||
buffer:blitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight())
|
||||
end
|
||||
pen_x = pen_x + glyph.ax
|
||||
|
||||
Reference in New Issue
Block a user