Scrappy Fonts is a simple font management library for Solar2D that allows for easy font naming and access.
As with all my plugins it is free to use however if you find it useful, and are able to, I’d appreciate a coffee.
Image Credit: Writing by ProSymbols from the Noun Project.
In order to use the library you will need to include it in your project, to do so please see this guide.
Initiates the library.
Registers a font.
name ( string ) – The name of the font to register.
filename ( string ) – The font’s filename.
returns – The registered font, or nil if not registered.
Gets a registered font.
name ( string ) – The name of the font to retrieve.
returns – The font, or nil if not found.
Gets a list of the names of all registered fonts.
returns – A list of font names, empty if none registered.
Registers all the system native fonts.
Register and use a font.
-- Register the fonts Scrappy.Fonts:register( "logo", "Sansation_Light.ttf" ) Scrappy.Fonts:register( "tagline", "Sansation_Light_Italic.ttf" ) -- Create the text options, retrieving the font name from the system local options = { text = "SOLAR 2D", x = display.contentCenterX, y = display.contentCenterY, font = Scrappy.Fonts:get( "logo" ), fontSize = 60, width = display.contentWidth, align = "center" } -- Create some text local logo = display.newText( options ) -- Adjust the options for the tagline options.text = "The 2D Game Engine." options.font = Scrappy.Fonts:get( "tagline" ) options.fontSize = options.fontSize * 0.6 -- Create some more text local tagline = display.newText( options ) tagline.y = logo.y + logo.contentHeight * 0.6