From 0079a7884f0f9fb140c371233e457d2d3248ef55 Mon Sep 17 00:00:00 2001 From: kdchambers Date: Thu, 7 Mar 2024 20:26:19 -0500 Subject: [PATCH] update to zig 0.12.0-dev.3142 --- build.zig | 11 ++--------- src/Atlas.zig | 2 +- src/backends/fontana.zig | 6 +++--- src/backends/freetype.zig | 4 ++-- src/backends/freetype_harfbuzz.zig | 6 +++--- src/otf.zig | 14 +++++++------- src/rasterizer.zig | 6 +++--- 7 files changed, 21 insertions(+), 28 deletions(-) diff --git a/build.zig b/build.zig index df38335..e11c088 100644 --- a/build.zig +++ b/build.zig @@ -1,15 +1,8 @@ const std = @import("std"); -const Builder = std.build.Builder; -const Pkg = std.build.Pkg; +const Build = std.Build; -pub const pkg = Pkg{ - .name = "fontana", - .source = .{ .path = "src/fontana.zig" }, - .dependencies = &{}, -}; - -pub fn build(b: *Builder) void { +pub fn build(b: *Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); diff --git a/src/Atlas.zig b/src/Atlas.zig index 3356b07..7e55176 100644 --- a/src/Atlas.zig +++ b/src/Atlas.zig @@ -59,7 +59,7 @@ pub fn reserve(self: *Atlas, comptime Extent2DPixel: type, alloc: Allocator, wid if (width == 0 and height == 0) return region; // Find the location in our nodes list to insert the new node for this region. - var best_idx: usize = best_idx: { + const best_idx: usize = best_idx: { var best_height: u32 = std.math.maxInt(u32); var best_width: u32 = best_height; var chosen: ?usize = null; diff --git a/src/backends/fontana.zig b/src/backends/fontana.zig index 06187bc..6483eb6 100644 --- a/src/backends/fontana.zig +++ b/src/backends/fontana.zig @@ -62,7 +62,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { self.atlas_entries[codepoint_i].y += 1; self.atlas_entries[codepoint_i].width -= 2; self.atlas_entries[codepoint_i].height -= 2; - var pixel_writer = rasterizer.SubTexturePixelWriter(types.Pixel, types.Extent2DPixel){ + const pixel_writer = rasterizer.SubTexturePixelWriter(types.Pixel, types.Extent2DPixel){ .texture_width = texture_size, .pixels = texture_pixels, .write_extent = self.atlas_entries[codepoint_i], @@ -86,7 +86,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { var cursor = placement; const texture_width_height: f32 = @as(f32, @floatFromInt(self.atlas.size)); var i: usize = 0; - var right_codepoint_opt: ?u8 = null; + const right_codepoint_opt: ?u8 = null; while (i < codepoints.len) : (i += 1) { const codepoint = codepoints[i]; if (codepoint == ' ') { @@ -128,7 +128,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { ) !void { const texture_width_height: f32 = @as(f32, @floatFromInt(self.atlas_ref.size)); var i: usize = 0; - var right_codepoint_opt: ?u8 = null; + const right_codepoint_opt: ?u8 = null; var descent_max: f64 = 0; var ascender_max: f64 = 0; var total_width: f64 = 0; diff --git a/src/backends/freetype.zig b/src/backends/freetype.zig index 5600dd1..b943d2d 100644 --- a/src/backends/freetype.zig +++ b/src/backends/freetype.zig @@ -135,7 +135,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { ); var cursor = placement; const texture_width_height: f32 = @as(f32, @floatFromInt(self.atlas_ref.size)); - var face = self.backend_ref.face; + const face = self.backend_ref.face; const has_kerning = face.face_flags.kerning; @@ -212,7 +212,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { self.points_per_pixel, ); const texture_width_height: f32 = @as(f32, @floatFromInt(self.atlas_ref.size)); - var face = self.backend_ref.face; + const face = self.backend_ref.face; const RenderedTextMetrics = struct { max_ascender: f64, diff --git a/src/backends/freetype_harfbuzz.zig b/src/backends/freetype_harfbuzz.zig index 1e7a2a9..28fd9cb 100644 --- a/src/backends/freetype_harfbuzz.zig +++ b/src/backends/freetype_harfbuzz.zig @@ -172,7 +172,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { ); self.backend_ref.hbFontChanged(self.backend_ref.harfbuzz_font); - var buffer = self.backend_ref.hbBufferCreateFn(); + const buffer = self.backend_ref.hbBufferCreateFn(); defer self.backend_ref.hbBufferDestroyFn(buffer); self.backend_ref.hbBufferAddUTF8Fn(buffer, codepoints.ptr, @as(i32, @intCast(codepoints.len)), 0, -1); @@ -290,7 +290,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { ); self.backend_ref.hbFontChanged(self.backend_ref.harfbuzz_font); - var buffer = self.backend_ref.hbBufferCreateFn(); + const buffer = self.backend_ref.hbBufferCreateFn(); defer self.backend_ref.hbBufferDestroyFn(buffer); self.backend_ref.hbBufferAddUTF8Fn(buffer, codepoints.ptr, @as(i32, @intCast(codepoints.len)), 0, -1); self.backend_ref.hbBufferSetDirectionFn(buffer, .left_to_right); @@ -376,7 +376,7 @@ pub fn PenConfigInternal(comptime options: api.PenConfigOptionsInternal) type { ); self.backend_ref.hbFontChanged(self.backend_ref.harfbuzz_font); - var buffer = self.backend_ref.hbBufferCreateFn(); + const buffer = self.backend_ref.hbBufferCreateFn(); defer self.backend_ref.hbBufferDestroyFn(buffer); self.backend_ref.hbBufferAddUTF8Fn(buffer, codepoints.ptr, @as(i32, @intCast(codepoints.len)), 0, -1); diff --git a/src/otf.zig b/src/otf.zig index e7273d7..ddf9691 100644 --- a/src/otf.zig +++ b/src/otf.zig @@ -594,7 +594,7 @@ pub fn kernAdvanceGpos( try fixed_buffer_stream.seekTo(script_list_offset + offset); const default_lang_offset = try reader.readIntBig(u16); - var lang_count = try reader.readIntBig(u16); + const lang_count = try reader.readIntBig(u16); _ = lang_count; if (std.mem.eql(u8, "DFLT", &tag)) { selected_lang_offset = default_lang_offset + offset; @@ -765,7 +765,7 @@ pub fn generateKernPairsFromGpos( try fixed_buffer_stream.seekTo(script_list_offset + offset); const default_lang_offset = try reader.readIntBig(u16); - var lang_count = try reader.readIntBig(u16); + const lang_count = try reader.readIntBig(u16); _ = lang_count; if (std.mem.eql(u8, "DFLT", &tag)) { selected_lang_offset = default_lang_offset + offset; @@ -930,7 +930,7 @@ pub fn loadFromFile(allocator: std.mem.Allocator, file_path: []const u8) !FontIn const file_size = (try file_handle.stat()).size; - var font_buffer = try allocator.alloc(u8, file_size); + const font_buffer = try allocator.alloc(u8, file_size); _ = try file_handle.readAll(font_buffer); return try parseFromBytes(font_buffer); @@ -1491,7 +1491,7 @@ pub fn rasterizeGlyphAlloc( const pixels = try allocator.alloc(graphics.RGBA(f32), pixel_count); bitmap.pixels = pixels.ptr; @memset(pixels, graphics.RGBA(f32){ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 }); - var pixel_writer = rasterizer.SubTexturePixelWriter(graphics.RGBA(f32)){ + const pixel_writer = rasterizer.SubTexturePixelWriter(graphics.RGBA(f32)){ .texture_width = dimensions.width, .write_extent = .{ .x = 0, @@ -1731,8 +1731,8 @@ fn loadGlyphVertices(allocator: std.mem.Allocator, font: *const FontInfo, glyph_ assert(vertices_count == 0); var i: usize = 0; - var x: i16 = 0; - var y: i16 = 0; + const x: i16 = 0; + const y: i16 = 0; var control1_x: i32 = 0; var control1_y: i32 = 0; @@ -1891,7 +1891,7 @@ fn createOutlines(allocator: std.mem.Allocator, vertices: []Vertex, height: f64, // var i: usize = 1; var accumulator: f64 = 0; - var point_previous = point_from; + const point_previous = point_from; while (i <= 10) : (i += 1) { const point_sampled = segment_ptr.sample(@as(f64, @floatFromInt(i)) * 0.1); accumulator += geometry.distanceBetweenPoints(point_previous, point_sampled); diff --git a/src/rasterizer.zig b/src/rasterizer.zig index 2c0ba28..87f84ff 100644 --- a/src/rasterizer.zig +++ b/src/rasterizer.zig @@ -393,7 +393,7 @@ inline fn minTMiddle(a: f64, b: f64, max: f64) f64 { if (dist_forward < dist_reverse) { return @mod(a + (dist_forward / 2.0), max); } - var middle = @mod(b + (dist_reverse / 2.0), max); + const middle = @mod(b + (dist_reverse / 2.0), max); const result = if (middle >= 0.0) middle else middle + max; std.debug.assert(result >= 0.0); std.debug.assert(result <= max); @@ -689,7 +689,7 @@ fn doAntiAliasing( sampler.init(t_end); var pixel_x = pixel_start; - var fill_anchor_point = Point(f64){ .x = 1.0, .y = point_left.y }; + const fill_anchor_point = Point(f64){ .x = 1.0, .y = point_left.y }; var previous_point = Point(f64){ .x = point_left.x - @as(f64, @floatFromInt(pixel_x)), @@ -703,7 +703,7 @@ fn doAntiAliasing( var coverage: f64 = 0.0; while (true) { - var sampled_point = sampler.nextSample(origin); + const sampled_point = sampler.nextSample(origin); if (sampled_point.x >= 1.0) { const interpolated_point = geometry.interpolateBoundryPoint(previous_point, sampled_point); assertNormalized(interpolated_point);