Custom Font Generator/Manager

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

16 Likes

Sweet but uh… the module isn’t free to take?

Oh, sorry. It is now!

This is really cool, really nice work. I might use it.
Must add Comic Sans everywhere!

Oohhhh. I’m probably gunna use this for the Runescape fonts. This is cool, excellent work! :]

Does the java program accepts parameters? Would be cool to make a bot and use a linux server to get the data. (I want to put all the Google fonts on ROBLOX…)

Well atm it is in a jar with a few classes in there for the GUI. I can upload a version which allows you to do that though :slight_smile:

Ok I quickly threw this together without any error checking:

(Please don’t judge my messy code :P)

NEON LIGHTS 48

just uploaded so i haven’t tested it yet. still pending review.

[quote] http://www.roblox.com/NEON-LIGHTS-48-item?id=245143211

NEON LIGHTS 48

just uploaded so i haven’t tested it yet. still pending review. [/quote]

The image doesn’t actually have to moderated before you can see it in game as long as you are the one who made it. Just make sure you are signed in to Studio.

i’m getting the error “can’t parse json”

i started with your example code and it’s working, it’s printing all the default fonts you made. so i guess i did something wrong? i copied the contents of NEONLIGHTS48.JSON and pasted into the decal description.
so what i have is

workspace.Part.FontLibrary
workspace.Part.SurfaceGui
workspace.Part.Script

and in the script i have

local FontLibrary = require(script.Parent:WaitForChild("FontLibrary"))


local neonLights = FontLibrary:LoadFont(245143210)  --<<line that errors


local textFrame = FontLibrary:DrawText("ABCDEFGHIJKLMNOPQRSTUVWXYZ", neonLights, 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.SurfaceGui

I’ve been thinking about doing something like this. Is there a significant performance hits with using that many image labels with a spritemap? (like if you wanted a book with a custom font) I guess it would be possible to recycle them if they aren’t visible

I have a bunch of runescape font data from a bot I made if you need it :slight_smile:

I haven’t done extensive testing with large amounts of text but it seems to both generate the labels and display them at high FPS.

[quote] i’m getting the error “can’t parse json”

i started with your example code and it’s working, it’s printing all the default fonts you made. so i guess i did something wrong? i copied the contents of NEONLIGHTS48.JSON and pasted into the decal description.
so what i have is

workspace.Part.FontLibrary
workspace.Part.SurfaceGui
workspace.Part.Script

and in the script i have

[code]
local FontLibrary = require(script.Parent:WaitForChild(“FontLibrary”))

local neonLights = FontLibrary:LoadFont(245143210) --<<line that errors

local textFrame = FontLibrary:DrawText(“ABCDEFGHIJKLMNOPQRSTUVWXYZ”, neonLights, 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.SurfaceGui
[/code] [/quote]

You changed the description of the decal, not the image.

ok, i see now. thx. :smiley:
Beautiful

local neonLights = FontLibrary:LoadFont(245143210)

can you make it so i can choose fonts from a folder, instead of using installed fonts? i have a ton of “commercial friendly” free for commercial use fonts, but they are not installed on my computer, i just have them in a folder that my graphics programs use.

Well atm the program searches for installed fonts. It uses back end Java stuff and I do not know how to read the raw font files, so not right now. For now it is easy enough to right click on the font and click install, isn’t it?

Well atm the program searches for installed fonts. It uses back end Java stuff and I do not know how to read the raw font files, so not right now. For now it is easy enough to right click on the font and click install, isn’t it?[/quote]

Ah, was just going to spin it up on a server to see what I could automate to upload ‘all’ the Google fonts but if it are only installed fonts then it might get tricky. I guess that I’ll inspect your code closely and write an alternative in php or C# so it can use URLs (both local paths and web paths). But I guess it will take some time :confused:

Thanks for the source anyways!

yes it is easy. and it is easy to uninstall them afterwards. i don’t like having a bunch of fonts installed because it takes forever for graphics programs to load. but really, it’s nothing for me to install a font for a few minutes and then uninstall it after i use the generator. i wasn’t trying to suggest that your program is lacking. it’s awesome. i don’t see any need for you to change anything. ty for making it.

Well atm the program searches for installed fonts. It uses back end Java stuff and I do not know how to read the raw font files, so not right now. For now it is easy enough to right click on the font and click install, isn’t it?[/quote]

Ah, was just going to spin it up on a server to see what I could automate to upload ‘all’ the Google fonts but if it are only installed fonts then it might get tricky. I guess that I’ll inspect your code closely and write an alternative in php or C# so it can use URLs (both local paths and web paths). But I guess it will take some time :confused:

Thanks for the source anyways![/quote]

No problem. I have been meaning to get into some web development myself so I may take this on as a first project. If you do something with it be sure to let me know though!