Glyphic
Bitmap and outline font rendering for Ruby graphics.
Features · Installation · Quick Start
Glyphic loads BDF bitmap fonts and TrueType outlines, measures UTF-8 text, and draws it onto Tessel RGBA8 images.
Features
- BDF bitmap font loading.
- TrueType (.ttf) outline loading and rasterization.
- UTF-8 text measurement, wrapping, and text boxes.
- Fallback chains for missing glyphs.
- Direct rendering into Tessel images.
- A built-in font for examples and tools.
Installation
Add Glyphic to your Gemfile:
gem "glyphic"Then run:
bundle installOr install the released gem:
gem install glyphicRequirements
- Ruby 3.1 or newer.
- Tessel is installed automatically as a runtime dependency.
Quick Start
require "glyphic"
require "tessel"
font = Glyphic.default
image = Tessel::Image.new(240, 40, fill: "#101827")
font.draw(image, 4, 4, "Hello, rbgfx", color: "#ffffff")
image.write("hello.png")Load an external font with Glyphic.load(path). BDF and TrueType
fonts are supported; CFF/OpenType outlines are currently unsupported.
Development
bundle install
bundle exec rake verifyContributing
Bug reports and pull requests are welcome at rbgfx/glyphic.