Skip to content

Commit

Permalink
update to zig 0.12.0-dev.3142
Browse files Browse the repository at this point in the history
  • Loading branch information
kdchambers committed Mar 8, 2024
1 parent d7fbf97 commit 0079a78
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
11 changes: 2 additions & 9 deletions build.zig
Original file line number Diff line number Diff line change
@@ -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(.{});

Expand Down
2 changes: 1 addition & 1 deletion src/Atlas.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/backends/fontana.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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 == ' ') {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/backends/freetype.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/backends/freetype_harfbuzz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/otf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/rasterizer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)),
Expand All @@ -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);
Expand Down

0 comments on commit 0079a78

Please sign in to comment.