Hello, my place has a tag game to purchase a tag, there's a problem though, using different fonts break the positions resulting in this

Here is the part of the DefaultChatMessage that adds a different font note: i added the TagFont key to the modules

local tagText = tag.TagText or "???"
		local tagfont = tag.TagFont or BaseMessage.Font
		local formatTagText = string.format("[%s] ", tagText)
		local label = util:AddTagLabelToBaseMessage(BaseMessage, tagColor, formatTagText,tagfont)

Now this is what i do in Util to add a font to it

function methods:AddTagLabelToBaseMessage(BaseMessage, tagColor, formatTagText,fnt)
	if not fnt then
		fnt=BaseMessage.Font
	end
	local tagNameSize = self:GetStringTextBounds(formatTagText, fnt, BaseMessage.TextSize)
	local TagLabel = self:GetFromObjectPool("TextLabel")
	TagLabel.Selectable = false
	TagLabel.Size = UDim2.new(0, tagNameSize.X, 0, tagNameSize.Y)
	TagLabel.Position = UDim2.new(0, 0, 0, 0)
	TagLabel.BackgroundTransparency = 1
	TagLabel.Font = fnt
	TagLabel.TextSize = BaseMessage.TextSize
	TagLabel.TextXAlignment = BaseMessage.TextXAlignment
	TagLabel.TextYAlignment = BaseMessage.TextYAlignment
	TagLabel.TextTransparency = BaseMessage.TextTransparency
	TagLabel.TextStrokeTransparency = BaseMessage.TextStrokeTransparency
	TagLabel.TextColor3 = tagColor
	TagLabel.Text = formatTagText
	TagLabel.Visible = true
	TagLabel.Parent = BaseMessage

	return TagLabel
end

and GetStringTextBounds here

function methods:GetNumberOfSpaces(str, font, textSize)
	local strSize --define the variable in a scope that can be
	--accessed by later lines of code
	if typeof(str)=="string" then --is it a string?
		--if so, treat it like a string.
		strSize = self:GetStringTextBounds(str, font, textSize)
	elseif typeof(str)=="Instance" then --or is it an icon?
		--if so, we can just use the label's AbsoluteSize property.
		strSize = str.AbsoluteSize
	end
	local singleSpaceSize = self:GetStringTextBounds(" ", font, textSize)
	return math.ceil(strSize.X / singleSpaceSize.X)
end

How can i fix this so it's positioned correctly?

PS: the roblox place is here

3 comments

0

Do you have a place file/uncopylocked place I could look at where I could test this?

0

I'll make one with it