Update bigfonts.lua
Size fix
This commit is contained in:
@@ -140,7 +140,6 @@ local function makeText(nSize, sString, nFC, nBC, bBlit)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- The following code is related to basalt and has nothing to do with bigfonts, it creates a plugin which will be added to labels:
|
-- The following code is related to basalt and has nothing to do with bigfonts, it creates a plugin which will be added to labels:
|
||||||
local XMLParser = require("xmlParser")
|
|
||||||
return {
|
return {
|
||||||
Label = function(base)
|
Label = function(base)
|
||||||
local fontsize = 1
|
local fontsize = 1
|
||||||
@@ -164,47 +163,25 @@ return {
|
|||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
setText = function(self, text)
|
||||||
|
base.setText(self, text)
|
||||||
|
if(fontsize>1)then
|
||||||
|
if(self:getAutoSize())then
|
||||||
|
self:getBase():setSize(#bigfont[1][1], #bigfont[1]-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
|
||||||
getFontSize = function(self)
|
getFontSize = function(self)
|
||||||
return fontsize
|
return fontsize
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getSize = function(self)
|
|
||||||
local w, h = base.getSize(self)
|
|
||||||
if(fontsize>1)and(self:getAutoSize())then
|
|
||||||
return fontsize==2 and self:getText():len()*3 or math.floor(self:getText():len() * 8.5), fontsize==2 and h * 2 or math.floor(h)
|
|
||||||
else
|
|
||||||
return w, h
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
getWidth = function(self)
|
|
||||||
local w = base.getWidth(self)
|
|
||||||
if(fontsize>1)and(self:getAutoSize())then
|
|
||||||
return fontsize==2 and self:getText():len()*3 or math.floor(self:getText():len() * 8.5)
|
|
||||||
else
|
|
||||||
return w
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
getHeight = function(self)
|
|
||||||
local h = base.getHeight(self)
|
|
||||||
if(fontsize>1)and(self:getAutoSize())then
|
|
||||||
return fontsize==2 and h * 2 or math.floor(h)
|
|
||||||
else
|
|
||||||
return h
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
base.draw(self)
|
base.draw(self)
|
||||||
self:addDraw("bigfonts", function()
|
self:addDraw("bigfonts", function()
|
||||||
if(fontsize>1)then
|
if(fontsize>1)then
|
||||||
local obx, oby = self:getPosition()
|
|
||||||
local parent = self:getParent()
|
|
||||||
local oX, oY = parent:getSize()
|
|
||||||
local cX, cY = #bigfont[1][1], #bigfont[1]
|
local cX, cY = #bigfont[1][1], #bigfont[1]
|
||||||
obx = obx or math.floor((oX - cX) / 2) + 1
|
|
||||||
oby = oby or math.floor((oY - cY) / 2) + 1
|
|
||||||
|
|
||||||
for i = 1, cY do
|
for i = 1, cY do
|
||||||
self:addFg(1, i, bigfont[2][i])
|
self:addFg(1, i, bigfont[2][i])
|
||||||
|
|||||||
Reference in New Issue
Block a user