Hello everyone.
I have just finished creating a FontLibrary module which allows for creating custom fonts on ROBLOX easily. Along with the ModuleScript, I have also written a Java program which generates the Font Map images and some other data which the system uses. With this, you can take any font installed on your computer with any font size and generate a font map with it.
Screenshots:
My system uses the MarketPlaceService to view the Description property of ROBLOX Images. The way it works, is the generator will create a .png and .json file. You then upload the .png file as a ROBLOX decal, and find its corresponding ROBLOX image (subtract 1 from the ID). Then, configure your image and copy the JSON data into the description. Now you can take the ID of the image and load it into the FontLibrary module like this:
local FontLibrary = require(some.destination.FontLibrary)
local yourFont = FontLibrary:LoadFont(yourImageID)
From there, you can draw text using your font like so:
local textFrame = FontLibrary:DrawText("Some Text", yourFont, 1, Enum.TextXAlignment.Center, Color3.new(1, 1, 1))
textFrame.Position = UDim2.new(.5, -textFrame.Size.X.Offset/2, .5, -100)
textFrame.Parent = script.Parent.ScreenGui
The LoadFont module returns the created font but also stores it in LoadFont.Fonts[FontName][FontSize], so after a script has loaded it once on that peer, any other script can access that same font using FontLibrary.Fonts.FontName[FontSize] (or use the GetFont(FontName, FontSize) method).
There are five methods and two fields to the module, listed here:
FontLibrary:GetFont(fontName, fontSize)
FontLibrary:ListFonts()
FontLibrary:LoadDefaultFonts()
FontLibrary:LoadFont(id)
FontLibrary:DrawText(text, font, scale, xAlign, color)
FontLibrary.Fonts
FontLibrary.DefaultFonts
I have created five fonts (each in size 12 and 24) with this system so far for testing purposes and have packaged them into the module with the LoadDefaultFonts method. They are: Papyrus, Minecraftia, Calibri, ComicSansMS, CenturyGothic.
Here is one of the assets.
They are officially documented within the ModuleScript which can be found here.
Here is an example use script:
local FontLibrary = require(script.Parent:WaitForChild("FontLibrary"))
FontLibrary:LoadDefaultFonts()
FontLibrary:ListFonts()
local textFrame = FontLibrary:DrawText("ABCDEFGHIJKLMNOPQRSTUVWXYZ", FontLibrary:GetFont("Papyrus", 24), 1, Enum.TextXAlignment.Center, Color3.new(1, 1, 1))
textFrame.Position = UDim2.new(.5, -textFrame.Size.X.Offset/2, .5, -100)
textFrame.Parent = script.Parent.ScreenGui
textFrame = FontLibrary:DrawText("abcdefghijklmnopqrstuvwxyz", FontLibrary:GetFont("ComicSansMS", 24), 1, Enum.TextXAlignment.Center, Color3.new(1, 1, 1))
textFrame.Position = UDim2.new(.5, -textFrame.Size.X.Offset/2, .5, -50)
textFrame.Parent = script.Parent.ScreenGui
textFrame = FontLibrary:DrawText("0123456789", FontLibrary:GetFont("Calibri", 24), 1, Enum.TextXAlignment.Center, Color3.new(1, 1, 1))
textFrame.Position = UDim2.new(.5, -textFrame.Size.X.Offset/2, .5, 0)
textFrame.Parent = script.Parent.ScreenGui
textFrame = FontLibrary:DrawText(". , / ? ! : ; ' $ % ( ) [ ] { } < > \" @ # ^ & * _ - + = \ | ~ `", FontLibrary:GetFont("Minecraftia", 24), 1, Enum.TextXAlignment.Center, Color3.new(1, 1, 1))
textFrame.Position = UDim2.new(.5, -textFrame.Size.X.Offset/2, .5, 50)
textFrame.Parent = script.Parent.ScreenGui
textFrame = FontLibrary:DrawText("The quick brown fox jumps over the lazy dog.", FontLibrary:GetFont("CenturyGothic", 24), 1, Enum.TextXAlignment.Center, Color3.new(1, 1, 1))
textFrame.Position = UDim2.new(.5, -textFrame.Size.X.Offset/2, .5, 100)
textFrame.Parent = script.Parent.ScreenGui
Generator download:
Generator instructions:
[ol]
[li]Download the .jar attachment.[/li]
[li]Place in a folder you do not mind getting cluttered.[/li]
[li]Run the .jar, select a font and size, hit generate. This will create a .png and .json in the same directory as the .jar.[/li]
[li]Follow the steps listed above to upload the font.[/li]
[/ol]
Because we are essentially uploading assets, it could be very helpful if we somehow kept a database of the assets people have uploaded. I suppose we could use a set? For now you could post them here, but let me know if you have a suggestion.
Please leave feedback,
Thanks,
Blake