tiny.filigree.glyphBitmapAlloc
Defined in font.raster.
Rasterizes one glyph.
Source
Source: lib/filigree/src/font/raster.zig:97
zig
/// Rasterizes one glyph. Scratch allocations end before return; `alpha` belongs to/// `output_allocator` and must be released with `GlyphBitmap.deinit` and the same allocator.pub fn glyphBitmapAlloc( output_allocator: std.mem.Allocator, scratch_allocator: std.mem.Allocator, face: face_table.Face, glyph_id: u32, pixel_size: i32,) Error!GlyphBitmap { if (pixel_size <= 0) return error.InvalidPixelSize; const scale = fontScale(face, pixel_size); const advance_x = scaleMetric(face.advanceWidth(glyph_id), scale); var glyph = try outline.glyphAlloc(scratch_allocator, face, glyph_id); defer glyph.deinit(scratch_allocator); if (glyph.points.len == 0 or glyph.bounds.x_max <= glyph.bounds.x_min or glyph.bounds.y_max <= glyph.bounds.y_min) { return blankGlyph(glyph_id, advance_x); } const pixel_bounds = glyphPixelBounds(glyph.bounds, face.ascender, scale); const width = pixel_bounds.width(); const height = pixel_bounds.height(); if (width <= 0 or height <= 0) return blankGlyph(glyph_id, advance_x); var points = std.ArrayListUnmanaged(FloatPoint).empty; defer points.deinit(scratch_allocator); var contours = std.ArrayListUnmanaged(ContourRange).empty; defer contours.deinit(scratch_allocator); try flattenGlyph(scratch_allocator, glyph, face.ascender, pixel_bounds, scale, &points, &contours); const alpha = try output_allocator.alloc(u8, try pixelCount(width, height)); errdefer output_allocator.free(alpha); @memset(alpha, 0); if (points.items.len > 0) { try coverage.rasterizeAlloc(scratch_allocator, alpha, width, height, points.items, contours.items); } return .{ .glyph_id = glyph_id, .width = width, .height = height, .offset_x = pixel_bounds.left, .offset_y = pixel_bounds.top, .advance_x = advance_x, .alpha = alpha, };}Source: lib/filigree/src/root.zig:106
zig
pub const glyphBitmapAlloc = font.glyphBitmapAlloc;Also reachable as
Complete call list
8 direct calls.
lib.filigree.src.font.coverage.rasterizeAlloc[function] — private source atlib/filigree/src/font/coverage.zig:16in nearest public ownerlib.filigree.src.font.coveragetiny.filigree.font.outline.glyphAlloc[function] atlib/filigree/src/font/outline.zig:41lib.filigree.src.font.raster.blankGlyph[function] — private source atlib/filigree/src/font/raster.zig:183in nearest public ownertiny.filigree.font.rasterlib.filigree.src.font.raster.flattenGlyph[function] — private source atlib/filigree/src/font/raster.zig:292in nearest public ownertiny.filigree.font.rasterlib.filigree.src.font.raster.fontScale[function] — private source atlib/filigree/src/font/raster.zig:409in nearest public ownertiny.filigree.font.rasterlib.filigree.src.font.raster.glyphPixelBounds[function] — private source atlib/filigree/src/font/raster.zig:413in nearest public ownertiny.filigree.font.rasterlib.filigree.src.font.raster.pixelCount[function] — private source atlib/filigree/src/font/raster.zig:438in nearest public ownertiny.filigree.font.rasterlib.filigree.src.font.raster.scaleMetric[function] — private source atlib/filigree/src/font/raster.zig:422in nearest public ownertiny.filigree.font.raster
Audit
| Definitions | 1 |
|---|---|
| Public names | 3 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |