Something went wrong. Try again.
Draws glyphs from zig-font onto z2d surfaces from positioned glyph runs, with fontconfig-based font loading and fallback.
Something went wrong. Try again.
2.1 kB · 64 lines
Zig
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! Draws glyphs from fonts decoded by zig-font onto z2d surfaces.//!//! What goes in is positioned glyphs — a `Run`: one `Face` at one size and a//! list of glyph IDs with where each goes — which is what a shaper//! produces. The renderer does no shaping and no I/O: finding fonts is the//! `font_loader` module's job, and turning text into glyphs a shaper's, with//! `simple_layout` standing in for one until there is one.//!//! ```zig//! var f = try font.Font.parse(gpa, bytes, .{});//! defer f.deinit();//! var face = try renderer.Face.init(gpa, &f, .{});//! defer face.deinit(gpa);//!//! var placed = try renderer.simple_layout.layout(gpa, &face, 32, "Hello");//! defer placed.deinit(gpa);//!//! var cache: renderer.GlyphCache = .init(gpa, renderer.GlyphCache.default_budget);//! defer cache.deinit();//! try renderer.drawRun(gpa, &surface, .{ .face = &face, .size = 32, .glyphs = placed.glyphs }, 10, 40, .{//! .cache = &cache,//! });//! ```
pub const Face = @import("Face.zig");pub const GlyphCache = @import("GlyphCache.zig");pub const bitmap = @import("bitmap.zig");pub const colr = @import("colr.zig");pub const color_bitmap = @import("color_bitmap.zig");pub const draw = @import("draw.zig");pub const hint = @import("hint.zig");pub const outline = @import("outline.zig");pub const raster = @import("raster.zig");pub const resample = @import("resample.zig");pub const run = @import("run.zig");pub const simple_layout = @import("simple_layout.zig");pub const svg = @import("svg.zig");
pub const Run = run.Run;pub const Glyph = run.Glyph;pub const Position = run.Position;pub const Image = raster.Image;pub const drawRun = draw.drawRun;pub const DrawOptions = draw.Options;
test { // Every file with tests has to be named here or its tests never run. _ = Face; _ = GlyphCache; _ = bitmap; _ = colr; _ = color_bitmap; _ = draw; _ = hint; _ = outline; _ = raster; _ = resample; _ = run; _ = simple_layout; _ = svg;}