Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ziglibs/fontaine
A library to support text rendering in arbitrary contexts
https://github.com/ziglibs/fontaine
Last synced: 3 months ago
JSON representation
A library to support text rendering in arbitrary contexts
- Host: GitHub
- URL: https://github.com/ziglibs/fontaine
- Owner: ziglibs
- Created: 2022-10-31T14:31:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-31T14:40:21.000Z (over 2 years ago)
- Last Synced: 2024-08-04T04:07:37.909Z (6 months ago)
- Language: Zig
- Size: 1000 Bytes
- Stars: 32
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-zig - fontaine🗒️A library to support text rendering in arbitrary contexts
README
# Fontaine
> **WARNING: THIS LIBRARY IS NOT FUNCTIONAL YET!**
This library is meant to provide a solid base for font rendering. It's goals are:
- Provide text layouting
- Create a sequence of positioned glyphs for a given input string
- High level text rendering, will handle word wrap, alignment, maximum width, ...
- Provide string layouting
- Create a sequence of positioned glyphs for a given input string
- Bare bones function, will not handle lines or word wrap
- Provide glyph information
- Beziers
- Alpha texture rendering## Example
```zig
const fontaine = @import("fontaine");// the font size is "12 units", renderer has to translate this later on
var font = try fontaine.Font.load("berkeley-mono.ttf", 12.0);
defer font.deinit();const text =
\\My name is Marquise and i'm from France!
\\എന്റെ പേര് മാർക്വിസ്, ഞാൻ ഫ്രാൻസിൽ നിന്നാണ്!
\\私の名前はマルキーズで、フランス出身です!
\\我的名字是侯爵夫人,我来自法国!var iter = fontaine.layoutText(font, text, .{
.alignment = .justify,
.max_width = 200, // units
.max_height = 400, // units
});while(iter.next()) |glyph_desc| {
const bitmap = try glyph_cache.getScaled(glyph_desc.glyph_index, font.size);
renderer.drawBitmap(glyph_desc.x, glyph_desc.y, bitmap);
}
```