Scrolling improvements, fixes #13

This commit is contained in:
airstruck
2015-12-21 12:26:07 -05:00
parent 73e9a10b15
commit 147de8e010
7 changed files with 54 additions and 58 deletions

View File

@@ -245,20 +245,4 @@ function Font:getAdvance (text)
return w[0]
end
function Font:getWrappedHeight (text)
--[[
-- TTF_Font *font, const char *text, int wrapLength, int *w, int *h, int *lineCount
local w, h, lineCount = IntOut(), IntOut(), IntOut()
SDL2_ttf.TTF_SizeUTF8_Wrapped(self.sdlFont, text, self.width,
w, h, lineCount)
return self:getLineHeight() * lineCount
--]]
local w, h = IntOut(), IntOut()
SDL2_ttf.TTF_SizeUTF8(self.sdlFont, text, w, h)
return h[0]
end
return Font

View File

@@ -77,7 +77,7 @@ local function renderMulti (self, font, text, color, align, limit)
sdl.setTextureAlphaMod(self.sdlTexture, alphaMod)
end
self.width, self.height = surface.w, surface.h
self.width, self.height = limit, height
end
function Text:constructor (renderer, font, text, color, align, limit)

View File

@@ -50,16 +50,4 @@ function Font:getAdvance (text)
return (self.loveFont:getWidth(text))
end
if love._version_minor < 10 then
function Font:getWrappedHeight (text)
local _, lines = self.loveFont:getWrap(text, self.width)
return lines * self.loveFont:getHeight()
end
else
function Font:getWrappedHeight (text)
local _, lines = self.loveFont:getWrap(text, self.width)
return #lines * self.loveFont:getHeight()
end
end
return Font