
Hello, i’m here to show you my “String Formatting Thing”, yeah pretty small project from me and there’s better alternative, but i gave it my best.
To use it you should:
*Enable “RichText” on your TextLabel, TextButton or TextBox.
*Require Module Script with Module script provided below.
*Call “FormatString” function replacing the text of you TextLabel, TextButton or TextBox.
Example script: (you can see the result in the first screenshot)
local Title = "BitoLog\'s String Formating Thing"
local TitleSettings = {
TextFont = {Face = "Bodoni", Color = Color3.new(128, 0, 128), Weight = 500, Size = 25},
Stroke = {Color = Color3.new(191, 0, 255), Thickness = 1, Transparency = 0.5, Joins = "round"},
Mark = {Color = Color3.new(0,0,255), Transparency = 0.9},
Underline = true
}
script.Parent.Text = SFM.FormatString(Title, TitleSettings)
Full Module script:
local TXT = {}
function TXT.FormatString(FormatingString, Flags)
local StringStart = ""
local StringEnd = ""
if Flags.TextFont ~= nil then
local _Start = "<font"
local _End = ">"
if Flags.TextFont.Face ~= nil then
_Start = _Start.." face=\""..Flags.TextFont.Face.."\""
end
if Flags.TextFont.Color ~= nil then
_Start = _Start..string.format(" color=\"rgb(%d,%d,%d)\"", Flags.TextFont.Color.R, Flags.TextFont.Color.G, Flags.TextFont.Color.B)
end
if Flags.TextFont.Weight ~= nil then
local weight = tonumber(Flags.TextFont.Weight)
if weight and weight >= 100 and weight <= 900 then
_Start = _Start..' weight="'..weight ..'"'
end
end
if Flags.TextFont.Transparency ~= nil then
local _T = tonumber(Flags.TextFont.Transparency)
if _T and _T >= 0 and _T <= 1 then
_Start = _Start.." transparency=\""..Flags.TextFont.Transparency.."\""
end
end
if Flags.TextFont.Size ~= nil then
_Start = _Start.." size=\""..Flags.TextFont.Size.."\""
end
StringStart = StringStart.._Start.._End
StringEnd = "</font>"..StringEnd
end
if Flags.Stroke ~= nil then
local _Start = "<stroke"
local _End = ">"
if Flags.Stroke.Color ~= nil then
_Start = _Start..string.format(" color=\"rgb(%d,%d,%d)\"", Flags.Stroke.Color.R, Flags.Stroke.Color.G, Flags.Stroke.Color.B)
end
if Flags.Stroke.Thickness ~= nil then
_Start = _Start.." th=\""..Flags.Stroke.Thickness.."\""
end
if Flags.Stroke.Transparency ~= nil then
local _T = tonumber(Flags.Stroke.Transparency)
if _T and _T >= 0 and _T <= 1 then
_Start = _Start.." tr=\""..Flags.Stroke.Transparency.."\""
end
end
if Flags.Stroke.Joins ~= nil then
local _a = Flags.Stroke.Joins
if _a == "miter" or _a == "bevel" or _a == "round" then
_Start = _Start.." joins=\""..Flags.Stroke.Joins.."\""
end
end
StringStart = StringStart.._Start.._End
StringEnd = "</stroke>"..StringEnd
end
if Flags.Mark ~= nil then
local _Start = "<mark"
local _End = ">"
if Flags.Mark.Color ~= nil then
_Start = _Start..string.format(" color=\"rgb(%d,%d,%d)\"", Flags.Mark.Color.R, Flags.Mark.Color.G, Flags.Mark.Color.B)
end
if Flags.Mark.Transparency ~= nil then
local _T = tonumber(Flags.Mark.Transparency)
if _T and _T >= 0 and _T <= 1 then
_Start = _Start.." transparency=\""..Flags.Mark.Transparency.."\""
end
end
StringStart = StringStart.._Start.._End
StringEnd = "</mark>"..StringEnd
end
if Flags.Bold ~= nil and Flags.Bold == true then
StringStart = StringStart.."<b>"
StringEnd = "</b>"..StringEnd
end
if Flags.Italic ~= nil and Flags.Italic == true then
StringStart = StringStart.."<i>"
StringEnd = "</i>"..StringEnd
end
if Flags.Underline ~= nil and Flags.Underline == true then
StringStart = StringStart.."<u>"
StringEnd = "</u>"..StringEnd
end
if Flags.Strikethrough ~= nil and Flags.Strikethrough == true then
StringStart = StringStart.."<s>"
StringEnd = "</s>"..StringEnd
end
if Flags.Uppercase ~= nil and Flags.Uppercase == true then
StringStart = StringStart.."<uc>"
StringEnd = "</uc>"..StringEnd
end
if Flags.SmallCaps ~= nil and Flags.SmallCaps == true then
StringStart = StringStart.."<sc>"
StringEnd = "</sc>"..StringEnd
end
return StringStart..""..FormatingString..""..StringEnd
end
return TXT
You can see every setting for RichText here
–sizing for “Stroke” isnt suproted unfortunately
Every Setting below:
local EverySetting = {
TextFont = {Face = Name of Font Face, Color = Color3, Weight = Number,--[[from 100 to 900]] Transparency = Number,--[[from 0 to 1]] Size = Number, },
Stroke = {Color = Color3, Thickness = Number, Transparency = Number,--[[from 0 to 1]] Joins = string --[[miter, bevel or round]]},
Mark = {Color = Color3, Transparency = Number,--[[from 0 to 1]]},
Bold = BoolValue, Italic = BoolValue, Underline = BoolValue, Strikethrough = BoolValue, Uppercase = BoolValue, SmallCaps = BoolValue
}
If you have anything to add feel free to comment. script isn’t that good looking but thats everything that i need for my work.