Answer the question
In order to leave comments, you need to log in
How to add an outline (stroke) for text in LUA?
There is a GUI written in Lua and the LOVE framework . Depending on the situation, sometimes the fonts blend into the background (the color is all white), so I wanted to add a black stroke to all the texts. But as it turned out, LUA and the LOVE framework do not provide such an opportunity. However, on the net you can find implementation examples when the text is first drawn 8 times in black with offsets in different directions, and then white text is drawn on top. The problem is that I am not at all familiar with this language, and I have no idea how to implement it all correctly.
To initialize all text in general, a separate file is used, in which the following code:
function CFont:Init(name, size)
self.size = size
self.name = name
self.font = lg.newFont( gPaths.fonts .. "/" .. self.name, self.size )
self.font:setLineHeight( gFontLineHeight )
end
function CUIFg:InitBottomText( )
self.bottomText = ""
self.bottomTextSize = 0
self.bottomTextObjPosY = 0
local font = Common:GetFont(10, gUIFonts.default)
self.bottomTextObj = lg.newText(font)
self.bottomTextObjScale = 0
self.bottomTextObjHeight = self.bottomTextObj:getHeight()
self.bottomTextBoxWidth, self.bottomTextBoxHeight = 620, 60
self.bottomTextBoxX0, self.bottomTextBoxY0 = gViewport.width/2 - self.bottomTextBoxWidth/2, self.uiBottomPosY - self.bottomTextBoxHeight/2 - 35
self.bottomTextBoxCenterX, self.bottomTextBoxCenterY = self.bottomTextBoxX0 + self.bottomTextBoxWidth/2, self.uiBottomPosY + 80 - self.bottomTextBoxHeight/2
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question