├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── README.md ├── build.zig └── src └── main.zig /.gitattributes: -------------------------------------------------------------------------------- 1 | *.zig text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: MasterQ32 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | zig-cache/ 2 | zig-out/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fontaine 2 | 3 | > **WARNING: THIS LIBRARY IS NOT FUNCTIONAL YET!** 4 | 5 | This library is meant to provide a solid base for font rendering. It's goals are: 6 | 7 | - Provide text layouting 8 | - Create a sequence of positioned glyphs for a given input string 9 | - High level text rendering, will handle word wrap, alignment, maximum width, ... 10 | - Provide string layouting 11 | - Create a sequence of positioned glyphs for a given input string 12 | - Bare bones function, will not handle lines or word wrap 13 | - Provide glyph information 14 | - Beziers 15 | - Alpha texture rendering 16 | 17 | ## Example 18 | 19 | ```zig 20 | const fontaine = @import("fontaine"); 21 | 22 | // the font size is "12 units", renderer has to translate this later on 23 | var font = try fontaine.Font.load("berkeley-mono.ttf", 12.0); 24 | defer font.deinit(); 25 | 26 | const text = 27 | \\My name is Marquise and i'm from France! 28 | \\എന്റെ പേര് മാർക്വിസ്, ഞാൻ ഫ്രാൻസിൽ നിന്നാണ്! 29 | \\私の名前はマルキーズで、フランス出身です! 30 | \\我的名字是侯爵夫人,我来自法国! 31 | 32 | var iter = fontaine.layoutText(font, text, .{ 33 | .alignment = .justify, 34 | .max_width = 200, // units 35 | .max_height = 400, // units 36 | }); 37 | 38 | while(iter.next()) |glyph_desc| { 39 | const bitmap = try glyph_cache.getScaled(glyph_desc.glyph_index, font.size); 40 | 41 | renderer.drawBitmap(glyph_desc.x, glyph_desc.y, bitmap); 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn build(b: *std.build.Builder) void { 4 | const mode = b.standardReleaseOptions(); 5 | 6 | const main_tests = b.addTest("src/main.zig"); 7 | main_tests.setBuildMode(mode); 8 | 9 | const test_step = b.step("test", "Run library tests"); 10 | test_step.dependOn(&main_tests.step); 11 | } 12 | -------------------------------------------------------------------------------- /src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | --------------------------------------------------------------------------------