Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ponywolf/ponyfont
Bitmap font support for Corona SDK
https://github.com/ponywolf/ponyfont
Last synced: 10 days ago
JSON representation
Bitmap font support for Corona SDK
- Host: GitHub
- URL: https://github.com/ponywolf/ponyfont
- Owner: ponywolf
- License: mit
- Created: 2016-04-06T16:36:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-01T21:30:20.000Z (about 4 years ago)
- Last Synced: 2024-07-31T09:10:33.162Z (3 months ago)
- Language: Lua
- Size: 446 KB
- Stars: 17
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-solar2d - ponyfont
README
**ponyfont** -- Modern Bitmap Font Support for Solar 2d (formerly CoronaSDK)
====
Bitmap fonts consist of two files, a PNG texture and a FNT file that describes the glyphs size and placement. This module reads an [Angel Code](http://www.angelcode.com/products/bmfont/) or [ShoeBox](http://renderhjs.net/shoebox/bitmapFont.htm) compatible FNT bitmap font and corresponding PNG texture and returns a displayGroup with each letter in order as the children of that display group. It also monitors properties like text, align, fontSize for changes and re-renders accordingly.There are many partial attempts of a BMF importer, but most rely on deprecated functionality and require additional code to integrate. The goal of **ponyfont** is to have a replacement for display.newText() with similar arguments and rendering.
![alt text](https://raw.githubusercontent.com/ponywolf/ponyfont/master/ponyfont-gif-preview.gif "Ponyfont in action")
*In this example, a bitmap font is shown side by side with it's TrueType counterpart. Size, placement and word wrap are all consistent.*
Syntax
----------
>ponyfont = require "com.ponywolf.ponyfont">local text = ponyfont.newText( options )
This function takes a single argument, options, which is a table that accepts the following parameters:
**text** (required)
String. The text to display.**x, y** (optional)
Numbers. Coordinates for the object's x and y center point.**width** (optional)
Number. Optional parameters to enable multi-line text. Text will be wrapped at width and be cropped at height. The width parameter is required if you use the align property (see below).**font** (required)
String. Name of the font file that contains the Angel Code FNT file. The module will look for the PNG textures specified in that FNT file in the same directory as the FNT file.**fontSize** (optional)
Number. The size of the text in Solar2D content points. The module will scale the glyphs to match the font size as similarly as possible. This may lead to blurry text if the texture is not significantly large enough to support the type size.**align** (optional)
String. This specifies the alignment of the text when a width parameter is supplied. Default value is "left". Valid values are "left", "center", or "right". See the code examples below.Examples
---------Many of the [Solar2D text examples](https://docs.coronalabs.com/api/library/display/newText.html) run as-is, by simply replacing the font parameter with the sample FNT/PNG included in this repository.